Check spawn
#1

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.
Reply
#2

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
Reply
#3

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)