Problem with spawning
#3

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:
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;
}
Reply


Messages In This Thread
Problem with spawning - by Ed2ka49 - 16.01.2011, 22:35
Re: Problem with spawning - by Ed2ka49 - 17.01.2011, 04:50
Re: Problem with spawning - by Joe Staff - 17.01.2011, 06:49
Re: Problem with spawning - by Ed2ka49 - 17.01.2011, 13:31
Re: Problem with spawning - by Ed2ka49 - 17.01.2011, 16:32
Re: Problem with spawning - by Ed2ka49 - 17.01.2011, 18:11

Forum Jump:


Users browsing this thread: 1 Guest(s)