SA-MP Forums Archive
Problem with player spawn After the race. - 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 player spawn After the race. (/showthread.php?tid=577541)



Problem with player spawn After the race. - SpikY_ - 12.06.2015

Hellu,
I have a problem with the player spawn. Sorry i'm posting many threads but yeah i need help.
my problem is : when i finish the race and i type /kill to check whether its bug or not. so when i type /kill i got spawned at the start of the race again after death. I want that if player has finished the race once so set his pos at the end of the race where he finished. not at that starting of race.

here are the codes.:

pawn Код:
public OnPlayerSpawn(playerid)
{
    SetPlayerRaceCheckpoint(playerid, 0,-2264.8501,2312.7566,4.5473,-2271.4414,2351.0659,4.4289,10);
    Stats[playerid] = 1;
    SetPlayerColor(playerid, COLOR_YELLOW);
    SetPlayerTime(playerid,12,0);
    SetPlayerInterior(playerid,0);
    SetCameraBehindPlayer(playerid);
    SendClientMessage(playerid,0xFF0000FF,"{FF0000}» Usage: {FFFFFF}/re to repair your vehicle!");
    SetPlayerHealth(playerid,100);
    SetPlayerArmour(playerid,0);
    new bmx = CreateVehicle(510,-2266.4817,2284.4314,4.4284,0,-1,-1,-1);
    PutPlayerInVehicle(playerid, bmx, 0);
    if(Free == 0)
    {
    TogglePlayerControllable(playerid, 0);
    }
    else if(Free == 1)
    {
    TogglePlayerControllable(playerid, 1);
    }
    return 1;
}

public OnPlayerEnterRaceCheckpoint(playerid)
{

    switch(Stats[playerid])
    {
         case 16: //////////////this is the last checkpoint. Race ending checkpoint
         {
              DisablePlayerRaceCheckpoint(playerid);
              PlayerPlaySound(playerid, 1056, 0.0, 0.0, 10.0);
              SetPlayerRaceCheckpoint(playerid, 1,-2720.3652,982.4440,54.0652,-2720.3652,982.4440,54.0652,10);
              Stats[playerid] = 17;
              return 1;
    }
    return 1;
}



Re: Problem with player spawn After the race. - Huba - 12.06.2015

https://sampwiki.blast.hk/wiki/SetSpawnInfo

Try SetSpawnInfo in OnPlayerDeath with get the position of player:
new Float: x, Float:y, Float:z, Float:a;
GetPlayerPos(playerid, x, y, z);
GetPlayerFacingAngle(playerid, a);
SetSpawnInfo( playerid, 0, 0, x, y, z, a, -1, -1, -1, -1, -1, -1);
Something like that.
If wont work try add SpawnPlayer(playerid) under it in OnPlayerDeath.


Re: Problem with player spawn After the race. - SpikY_ - 12.06.2015

I try to use both methods but still not fixed