View Full Version : Store actor in a variable

12/11/2017, 08:55 PM
When I try to store an actor ID into a variable it doesn't work properly.

CMD:test(playerid, params[])
if(IsValidActor(pActor[playerid])) DestroyActor(pActor[playerid]);
pActor[playerid] = CreateActor(0, 0.0, 0.0, 0.0, 3.0);
SetActorVirtualWorld(pActor[playerid], playerid);
return 1;

If I type command test the actor is created but if someone else type this command it removes my actor and create just for them.
And I tried to verify IsValidActor(pActor[x]) with x with random values and after I run command /test IsValidActor(pActor[x]) gives true for all x (0-999) even if I created just an actor.

Is there a way to store an Actor id for a player variable?

12/11/2017, 09:25 PM
Yeah, I figured that IsValidActor(x) return if an id is valid not if an actor was created on that id.

I solved setting pActor[playerid] = -1; if an actor wasn't created for that player.