Is Player Spawned.
#1

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

Is the callback OnPlayerSpawn called ?
Have you done any debuging ?
Reply
#3

Yes it's called, i have other stuff in there such as player colours and a dialog and they all work
Reply
#4

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 ?
Reply
#5

Variable is never reset, and yes that's in every command.
Reply
#6

Do a printf exactly after you have set the spawn variable to "1"
And then like OnPlayerSpawn or something
Reply
#7

Solved.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)