SA-MP Forums Archive
Check spawn - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Check spawn (/showthread.php?tid=123436)



Check spawn - potato - 25.01.2010

Is there a better way to check if player is spawned?
Currently I have spawned=true; inside OnPlayerSpawn, but there is a problem with it...
not always it seem to go back from false (inside OnPlayerDeath) and that causes problems :/
I do recall some function like GetPlayerPos that returns false if player isn't spawned (if(GetPlayerPos(playerid, x, y, z))...), but I could be wrong and mixing up 2 games.


Re: Check spawn - KnooL - 25.01.2010

On top of your script:
new spawned[MAX_PLAYERS]; // this will make a slot for each player connected to the server.

OnPlayerSpawn:
spawned[playerid] = true;

Function:
if(spawned[playerid] == 0) return SendClientMessage(playerid,color,"You are not spawned");

OnPlayerDisconnect/Connect:
spawned[playerid] = false;

if you do: new spawned; it'll be just one slot and it won't be for everyone that's why it is mixing up



Re: Check spawn - potato - 25.01.2010

Sorry, forgot to add the [MAX_PLAYERS], but I already have it in the script.
Actually that isn't the point.
I do think that this is because of IsPlayerConnected on the top, but that helps me avoiding crashes.
So the problem mainly is because some parts of script doesn't simply execute, most likely due lag.
That's why I wanted to know if there is a better way to get this done.