pointer... need help

Posted By: Altarius

pointer... need help - 12/15/14 04:44

Hi,

void Attack(){

if(my.STATE_MACHINE == ATTACK
{
return;
}
my.STATE_MACHINE = ATTACK;
}

it work if i acces this function inside a while loop whit:

if(mouse_left == 1) {Attack();}

it crash if i acces this function outside a while loop whit:

on_mouse_left = Attack;

i think the problem its the pointer "my".
Is there a way too keep the "my" pointer there and use on_mouse_left = Attack; wihtout getting crash...

thx
Posted By: Ch40zzC0d3r

Re: pointer... need help - 12/15/14 10:03

Just save the pointer in a self delcared variable:
Code:
ENTITY *pPlayer = NULL; //Global
...
pPlayer = me; //In your entity action



or use the predefined pointer called "player"
© 2024 lite-C Forums