Removing an entity

Posted By: oldschoolj

Removing an entity - 09/27/07 00:06

Sounds easy, doesn't it? Well this is becoming a mystery to me, simply because when ever I try to remove my ents, i get an invalid argument. Maybe someone could shed some light on it for me.
I define a model with a string:
STRING* item_model_0000 = "item_sword_00001.mdl";

Now I give it a handle:
item_model_array[0]=handle(item_model_0000);

Now I point to that model:
temp_ent[0] = ptr_for_handle(item_model_array[0]);

And create it:
ent_create(temp_ent[0], player.x, attach_item);

So far, so good. It gets created, and does it's job, but now I need to remove it, because we wont need it anymore:

if (temp_ent[0] != NULL){temp_ent[0] = you; wait (1); ent_remove(you);}

That draws up an "invalid argument", but not just that, I can also do this:
if (temp_ent[0] != NULL)ent_remove(temp_ent[0]);

Still the same results, and I am totally stumped for days...

I know that things are working up untill the ent_remove, because if I do this:
if (temp_ent[0] != NULL)beep();

I get a nice resounding beep, letting me know that the ent is in fact alive.

If anyone has any suggestions, please enlighten me


THANKS!

Jesse
Posted By: oldschoolj

Re: Removing an entity - 09/27/07 02:10

Well it appears I finally solved the problem, and it's really really easy, lol. This is why I wish I were a good programmer, so I didnt have to beat my head against the wall on issues like this.....

Here's the beef:
Added a second ent:
ENTITY* item_temp[25];

edited the ent_create line:
item_temp[0] = ent_create(temp_ent[0], player.x, attach_item);

and changed the ent_remove line:
if (item_temp[0] != NULL)ent_remove (item_temp[0]);

I don't know how it fixed it, but it did, and I think it might havesomething to do with the strings, but I'm unsure, lol....

Until the next issue, happy programming!

Jesse
© 2023 lite-C Forums