2 registered members (Akow, tomaslolo),
1,536
guests, and 12
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
crash in entities,. help!
#239127
12/02/08 20:20
12/02/08 20:20
|
Joined: Nov 2008
Posts: 42 Philippines
gagamBRYAN
OP
Newbie
|
OP
Newbie
Joined: Nov 2008
Posts: 42
Philippines
|
guys, need your help,. what seems to be the problem in this code? the error message is "invalid arguments in entity" referring to function func_backselectenemy(), the entity mangyanenemy. i can't remove it! The simplified code are shown below:
function func_startbagobo_mangyan() { pan_backselectenemy=pan_create(" pos_x = 0; pos_y = 0; button ( 50, 550, \"cancel.pcx\", \"cancel.pcx\", \"cancel_over.pcx\", func_backselectenemy, NULL, NULL); flags = OVERLAY | VISIBLE; ",11); bagobo_walk.z=60; ent_animate(bagobo_walk, "steady", anim_percentage, ANM_CYCLE); townlevel=ent_create("town.hmp", vector(0,0,-10),NULL); camera.z = 1; camera.tilt = -10; vec_set(camera.x, vector(-500, 0, 100)); mangyanenemy = ent_create("mangyan.mdl", vector(0,-100,-10),NULL); mangyanenemy.pan=-90; mangyanenemy.z=60; mangyanenemy.x=-175; mangyanenemy.y=-150; ent_animate(mangyanenemy, "steady", anim_percentage, ANM_CYCLE); }
function func_backselectenemy() { ent_remove(mangyanenemy); pan_remove(pan_backselectenemy); ent_remove(townlevel); }
can you tell me what is the problem?. thank you so much,. why sometimes the entity won't remove.
Secrets are stolen from deep inside..
|
|
|
Re: crash in entities,. help!
[Re: gagamBRYAN]
#239130
12/02/08 20:29
12/02/08 20:29
|
Joined: Nov 2008
Posts: 25
MrTwiggy101
Newbie
|
Newbie
Joined: Nov 2008
Posts: 25
|
While, I MAY be wrong. These are a few things that might be going wrong.
First, you didn't define the entity. So you should put ENTITY* mangyaenemy at the top if you didn't already.
Also, if you are going to be using mangyaenemy for that function, you should just make it from:
mangyanenemy = ent_create("mangyan.mdl", vector(0,-100,-10),NULL);
to
ent_create("mangyan.mdl", vector(0,-100,-10),func_backselectenemy);
and then turn the mangyaenemy to my.
Also, pan_backselectenemy=pan_create(" doesnt see, to be complete...
Also, remember. Sometimes the engine will point at random lines of code even if there is something else wrong with a different time, like if you forgot to put ; at the end of a line.
|
|
|
Re: crash in entities,. help!
[Re: MrTwiggy101]
#239134
12/02/08 20:50
12/02/08 20:50
|
Joined: Nov 2008
Posts: 42 Philippines
gagamBRYAN
OP
Newbie
|
OP
Newbie
Joined: Nov 2008
Posts: 42
Philippines
|
thanks for the time MrTwiggy ahmmm,. yup, i declared the mangyanenemy as ENTITY* at the top. i cant make the mangyanenemy = ent_create("mangyan.mdl", vector(0,-100,-10),NULL); to ent_create("mangyan.mdl", vector(0,-100,-10),func_backselectenemy); because the entity will be loaded in the environment and the there is a button cancel where i'll put the func_backselectenemy so that it will be back again in the main menu.
Secrets are stolen from deep inside..
|
|
|
Re: crash in entities,. help!
[Re: gagamBRYAN]
#239139
12/02/08 21:26
12/02/08 21:26
|
Joined: Feb 2008
Posts: 3,232 Australia
EvilSOB
Expert
|
Expert
Joined: Feb 2008
Posts: 3,232
Australia
|
To make your code a bit more bulletproof, change your entity declares to this ENTITY* mangyanenemy = NULL; or ENTITY* mangyanenemy = 0; PANEL* pan_backselectenemy = NULL; or PANEL* pan_backselectenemy = 0; Now you can test if the entity is in use or not. To see this test in action, and to possibly fix your problem, change the following too. function func_backselectenemy()
{ if(mangyanenemy!=NULL) ent_remove(mangyanenemy); mangyanenemy=NULL;
if(pan_backselectenemy!=NULL) pan_remove(pan_backselectenemy); pan_backselectenemy=NULL;
if(townlevel!=NULL) ent_remove(townlevel); townlevel=NULL;
} let us know how it goes.
"There is no fate but what WE make." - CEO Cyberdyne Systems Corp. A8.30.5 Commercial
|
|
|
|