Teleport player to hospital after death
#1

Hey guys!

By default, when a player dies, he is teleported back to the original spawn point. I want to make it so that the player is teleported to the nearest hospital (like in single player). I tried using SetPlayerPos in OnPlayerDeath section to move the player to San Fierro hospital, but it didn't work. Any ideas, guys?

Thanks in advance.
Reply
#2

https://sampwiki.blast.hk/wiki/SetSpawnInfo
Reply
#3

Do it in OnPlayerSpawn, here's an example:
pawn Код:
new bool:HospitalSpawn[MAX_PLAYERS];
public OnPlayerDeath(playerid, killerid, reason)
{
    HospitalSpawn[playerid] = true;
}

public OnPlayerSpawn(playerid)
{
    if(HospitalSpawn[playerid])
    {
        HospitalSpawn[playerid] = false;
        SetPlayerPos(playerid, x, y, z);
    }
    else
    {
        // Your other SetPlayerPos code
    }
}
Reply
#4

Quote:
Originally Posted by Lordzy
Посмотреть сообщение
Thanks
Reply
#5

Quote:
Originally Posted by CalvinC
Посмотреть сообщение
Do it in OnPlayerSpawn, here's an example:
pawn Код:
new bool:HospitalSpawn[MAX_PLAYERS];
public OnPlayerDeath(playerid, killerid, reason)
{
    HospitalSpawn[playerid] = true;
}

public OnPlayerSpawn(playerid)
{
    if(HospitalSpawn[playerid])
    {
        HospitalSpawn[playerid] = false;
        SetPlayerPos(playerid, x, y, z);
    }
    else
    {
        // Your other SetPlayerPos code
    }
}
Thanks a lot for your help
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)