SA-MP Forums Archive
Problem with Spawning on death - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Problem with Spawning on death (/showthread.php?tid=568817)



Problem with Spawning on death - Zens - 25.03.2015

For some messed up reason, you spawn at your first SPAWN(once you join, the last saved position upon quitting) position when you die no matter where you are.

Here's the code:
pawn Код:
public OnPlayerSpawn(playerid)
{
    // Skill levels
    SetPlayerSkillLevel(playerid, WEAPONSKILL_PISTOL, 0);
    SetPlayerSkillLevel(playerid, WEAPONSKILL_MICRO_UZI, 0);
    SetPlayerSkillLevel(playerid, WEAPONSKILL_SPAS12_SHOTGUN, 0);

    if (PlayerData[playerid][pHUD])
    {
        TextDrawShowForPlayer(playerid, gServerTextdraws[0]);
        TextDrawShowForPlayer(playerid, gServerTextdraws[1]);
    }
    SetPlayerSkin(playerid, PlayerData[playerid][pSkin]);
    Streamer_ToggleIdleUpdate(playerid, true);

    PlayerData[playerid][pKilled] = 0;

    if (PlayerData[playerid][pBleeding])
    {
        PlayerData[playerid][pBleedTime] = 1;
    }
    if (PlayerData[playerid][pJailTime] > 0)
    {
        if (PlayerData[playerid][pPrisoned])
        {
            SetPlayerInPrison(playerid);
        }
        else
        {
            SetPlayerPos(playerid, 197.6346, 175.3765, 1003.0234);
            SetPlayerInterior(playerid, 3);

            SetPlayerVirtualWorld(playerid, (playerid + 100));
            SetPlayerFacingAngle(playerid, 0.0);

            SetCameraBehindPlayer(playerid);
        }
        ResetWeapons(playerid);

        PlayerTextDrawShow(playerid, PlayerData[playerid][pTextdraws][70]);
        SendServerMessage(playerid, "You have %d seconds of remaining jail time.", PlayerData[playerid][pJailTime]);
    }
    else if (PlayerData[playerid][pHospital] != -1)
    {
        PlayerData[playerid][pHospitalTime] = 0;

        PlayerData[playerid][pHunger] = 50;
        PlayerData[playerid][pThirst] = 50;

        SetPlayerInterior(playerid, 3);
        SetPlayerVirtualWorld(playerid, playerid + 100);

        SetPlayerPos(playerid, -211.0370, -1738.6848, 676.7153);
        SetPlayerFacingAngle(playerid, 82.0000);

        SetPlayerCameraPos(playerid, -214.236602, -1738.812133, 676.648132);
        SetPlayerCameraLookAt(playerid, -203.072738, -1738.656127, 675.768737);

        ApplyAnimation(playerid, "CRACK", "crckdeth2", 4.0, 1, 0, 0, 0, 0);
        ApplyAnimation(playerid, "CRACK", "crckdeth2", 4.0, 1, 0, 0, 0, 0);

        GameTextForPlayer(playerid, "~n~~n~~n~~n~~n~~n~~n~~n~~n~~w~Recovering... 15", 1000, 3);
        TogglePlayerControllable(playerid, 0);
    }
    else if (!PlayerData[playerid][pCreated])
    {
        TogglePlayerControllable(playerid, 0);
        SetPlayerPos(playerid, 216.8005, -99.8691, 1005.2578);
        SetPlayerFacingAngle(playerid, 90.0000);

        SetPlayerInterior(playerid, 15);
        SelectTextDraw(playerid, -1);

        for (new i = 23; i < 34; i ++) {
            PlayerTextDrawShow(playerid, PlayerData[playerid][pTextdraws][i]);
        }
    }
    else
    {
        SetPlayerFacingAngle(playerid, PlayerData[playerid][pPos][3]);

        SetPlayerInterior(playerid, PlayerData[playerid][pInterior]);
        SetPlayerVirtualWorld(playerid, PlayerData[playerid][pWorld]);

        SetCameraBehindPlayer(playerid);
        SetAccessories(playerid);

        if (PlayerData[playerid][pWorld] == PRISON_WORLD)
        {
            SetPlayerPosEx(playerid, PlayerData[playerid][pPos][0], PlayerData[playerid][pPos][1], PlayerData[playerid][pPos][2]);
        }
        else
        {
            if(PlayerData[playerid][pSpawnPoint] == 3 && PlayerData[playerid][pInjured] == 0)
            {
            SetPlayerPos(playerid, PlayerData[playerid][pPos][0], PlayerData[playerid][pPos][1], PlayerData[playerid][pPos][2]);
            }
        }
        if (PlayerData[playerid][pInjured])
        {
            ShowHungerTextdraw(playerid, 0);

            TextDrawShowForPlayer(playerid, gServerTextdraws[2]);
            SendClientMessage(playerid, COLOR_LIGHTRED, "[WARNING]:{FFFFFF} You are injured and require medical attention (/call 911).");

            ApplyAnimation(playerid, "CRACK", "null", 4.0, 0, 0, 0, 1, 0, 1);
            ApplyAnimation(playerid, "CRACK", "crckdeth4", 4.0, 0, 0, 0, 1, 0, 1);
        }
        else
        {
            SetWeapons(playerid);
            ShowHungerTextdraw(playerid, 1);

            SetPlayerHealth(playerid, PlayerData[playerid][pHealth]);
            SetPlayerArmour(playerid, PlayerData[playerid][pArmorStatus]);
        }
    }
    return 1;
}
It works fine when inside an interior. (you spawn injured where you die)


Re: Problem with Spawning on death - Aly - 25.03.2015

Check the lines where you give values to:
Код:
PlayerData[playerid][pPos]



Re: Problem with Spawning on death - Zens - 27.04.2015

I still need some help with this.. I can't seem to get it working.


Re: Problem with Spawning on death - Zens - 28.04.2015

bump!