17.01.2011, 06:49
Use OnPlayerStateChange when newstate == PLAYER_STATE_SPAWNED instead of OnPlayerSpawn, OnPlayerSpawn is called before the player literally spawns, and thus can't be teleported when the setplayerpos function is used within the callback.
Example:
Example:
pawn Код:
public OnPlayerStateChange(playerid,newstate,oldstate)
{
if(newstate==PLAYER_STATE_SPAWNED)
{
if(GetPVarInt(playerid, "Newbie") == 1)
{
GivePlayerCash(playerid, 5000);
SetPlayerScore(playerid, 1);
SetPlayerSkin(playerid, random(299));
SetPlayerPos(playerid, -2706.5261, 397.7129, 4.3672);
DeletePVar(playerid, "Newbie");
}
else if(GetPVarInt(playerid, "JustLogged") == 1)
{
GivePlayerCash(playerid, pStats[playerid][pMoney]);
SetPlayerScore(playerid, pStats[playerid][pScore]);
SetPlayerSkin(playerid, pStats[playerid][pSkin]);
SetPlayerPos(playerid, pStats[playerid][pPosX], pStats[playerid][pPosY], pStats[playerid][pPosZ]+3);
DeletePVar(playerid, "JustLogged");
}
else if(GetPVarInt(playerid, "JustDied") == 1)
{
SetPlayerPos(playerid, -2706.5261, 397.7129, 4.3672);
SetPlayerSkin(playerid, pStats[playerid][pSkin]);
DeletePVar(playerid, "JustDied");
}
}
return 1;
}