12.12.2012, 14:49
A simple function which detects if player is spawned. If you use this, please add those codes under your includes. (On every scripts you use.)
Example:
pawn Код:
new PlayerIsSpawned[MAX_PLAYERS];
stock IsPlayerSpawned(playerid)
{
if(PlayerIsSpawned[playerid] == 1) return true;
else return false;
}
public OnPlayerSpawn(playerid)
{
PlayerIsSpawned[playerid] = 1;
CallLocalFunction("L_OPS", "d", playerid);
return 1;
}
public OnPlayerConnect(playerid)
{
PlayerIsSpawned[playerid] = 0;
CallLocalFunction("L_OPC", "d", playerid);
return 1;
}
#if defined _ALS_OnPlayerSpawn
#undef OnPlayerSpawn
#else
#define _ALS_OnPlayerSpawn
#endif
#define OnPlayerSpawn L_OPS
#if defined _ALS_OnPlayerConnect
#undef OnPlayerConnect
#else
#define _ALS_OnPlayerConnect
#endif
#define OnPlayerConnect L_OPC
forward L_OPS(playerid);
forward L_OPC(playerid);
pawn Код:
CMD:suicide(playerid, params[])
{
if(IsPlayerSpawned(playerid))
{
SetPlayerHealth(playerid, 0.0);
}
else
{
SendClientMessage(playerid, 0xFF0000FF, "You must be spawned to use this command.");
}
return 1;
}