Is Player Spawned. - 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: Is Player Spawned. (
/showthread.php?tid=399099)
Is Player Spawned. -
thefatshizms - 12.12.2012
Hello, I'm having some troubles with some commands, in every command i check if the player is spawned, if the spawned variable is equal to 0 he is not spawned and therefore i will send a error. In the public 'OnPlayerConnect' and 'OnPlayerDisconnect' I set the players variable of spawned to 0 (Not spawned). In the public 'OnPlayerSpawn' I've set the variable to of course 1 (Spawned).
The problem is that even when i spawn it still thinks that I'm not...
pawn Code:
public OnPlayerConnect(playerid)
{
Spawned[playerid] = 0;
public OnPlayerDisconnect(playerid, reason)
{
Spawned[playerid] = 0;
public OnPlayerSpawn(playerid)
{
Spawned[playerid] = 1;
if(Spawned[playerid] == 0) return SendClientMessage(playerid, COLOR_RED2, "[ERROR] :{FFFFFF} You need to spawn before you use any commands.");
Re: Is Player Spawned. -
park4bmx - 12.12.2012
Is the callback
OnPlayerSpawn called ?
Have you done any debuging ?
Re: Is Player Spawned. -
thefatshizms - 12.12.2012
Yes it's called, i have other stuff in there such as player colours and a dialog and they all work
Re: Is Player Spawned. -
park4bmx - 12.12.2012
Becouse you haven't provided the full code I'm going to say
Make sure the variable doesn't get reset!
Or not placed after other functions.
Also is
pawn Code:
if(Spawned[playerid] == 0) return SendClientMessage(playerid, COLOR_RED2, "[ERROR] :{FFFFFF} You need to spawn before you use any commands.");
The check for every command ?
Re: Is Player Spawned. -
thefatshizms - 12.12.2012
Variable is never reset, and yes that's in every command.
Re: Is Player Spawned. -
park4bmx - 12.12.2012
Do a
printf exactly after you have set the spawn variable to "1"
And then like
OnPlayerSpawn or something
Re: Is Player Spawned. -
thefatshizms - 12.12.2012
Solved.