Store actor in a variable - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Store actor in a variable (
/showthread.php?tid=644713)
Store actor in a variable -
iDark - 12.11.2017
Hello,
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?
Re: Store actor in a variable -
iDark - 12.11.2017
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.