(if)PlayerIsSpawned, how to add this command? Plugin/pawno addon?
#1

How may i add this so ican make (if)playerisspawned inside pawno
Thank you for helping me
Reply
#2

pawn Код:
new PlayerSpawned[MAX_PLAYERS];

public OnPlayerSpawn(playerid)
{
    PlayerSpawned[playerid]=true;
    return 1;
}

if(PlayerSpawned[playerid]) ...
Reply
#3

COMMAND:cop(playerid, params[])
{
(140) if(PlayerSpawned[playerid]) return SendClientMessage(playerid,COLOR_WHITE,"You are already on the cop team, relog to change team.");
(141) SetSpawnInfo( playerid, 0, 285, 2047.1105,-2625.3525,13, 26, 29, 28, 150, 0, 0,0 );
(142) SendClientMessage(playerid,COLOR_WHITE,"");
SendClientMessage(playerid,COLOR_WHITE,"");
SendClientMessage(playerid,COLOR_WHITE,"");
SendClientMessage(playerid,COLOR_WHITE,"");
SendClientMessage(playerid,COLOR_WHITE,"");
SendClientMessage(playerid,COLOR_WHITE,"");
SendClientMessage(playerid,COLOR_WHITE,"");
SendClientMessage(playerid,COLOR_WHITE,"");
SendClientMessage(playerid,COLOR_WHITE,"");
SendClientMessage(playerid,COLOR_LIGHTBLUE,"You are now a cop!");
SendClientMessage(playerid,COLOR_VIP,"To see all the commands type /help, /rules for rules.");
SpawnPlayer(playerid);
return 1;
}




ERRORS:

C:\Users\Martin\Desktop\samp\gamemodes\martin.pwn( 140) : error 017: undefined symbol "PlayerSpawned"
C:\Users\Martin\Desktop\samp\gamemodes\martin.pwn( 140) : warning 215: expression has no effect
C:\Users\Martin\Desktop\samp\gamemodes\martin.pwn( 140) : error 001: expected token: ";", but found "]"
C:\Users\Martin\Desktop\samp\gamemodes\martin.pwn( 140) : error 029: invalid expression, assumed zero
C:\Users\Martin\Desktop\samp\gamemodes\martin.pwn( 140) : fatal error 107: too many error messages on one line
Reply
#4

You need to compare the array to an actual number, in this case, 1(true).

pawn Код:
if(PlayerSpawned[playerid]==1) return SendClientMessage(playerid,COLOR_WHITE,"You are already on the cop team, relog to change team.");
Alternatively, you can make it a function (which is what I think you wanted to do)

pawn Код:
stock IsPlayerSpawned(playerid)
{
    if(PlayerSpawned[playerid]==1) return true;
    return false;
}
Reply
#5

Or this?

pawn Код:
stock IsPlayerSpawned(playerid)
{
    if(GetPlayerState(playerid) == PLAYER_STATE_SPAWNED) {
        return true;
    }
    else {
        return false;
    }
   
}
Reply
#6

pawn Код:
IsPlayerSpawned(playerid)
{
    return ((GetPlayerState(playerid) >= 1 && GetPlayerState(playerid) <= 6) || GetPlayerState(playerid) == 8) ? 1 : 0;
}
Reply
#7

C:\Users\Martin\Desktop\samp\gamemodes\martin.pwn( 140) : error 017: undefined symbol "IsPlayerSpawned"
Reply
#8

Are you sure you added the function somewhere in the script?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)