OnPlayerSpawn
#1

How i can spawn someone to hospital when died? because if someone die spawn at spawnpoint :/
Reply
#2

Set a variable on OnPlayerDisconnect and then check if the player has the variable and spawn him at the hospital:

pawn Код:
new died[MAX_PLAYERS];
public OnPlayerDeath(playerid, killerid, reason)
{
    died[playerid] = 1;
    return 1;
}
public OnPlayerSpawn(playerid)
{
    if(died[playerid] == 1)
    {
        //Spawn at hospital
        died[playerid] = 0;
    }
    return 1;
}
Reply
#3

Get the co-ordinates of where you want to spawn the player using /save in game. Then, we need to set a player variable under OnPlayerDeath, this can be done by:

pawn Код:
SetPVarInt(playerid, "Dead", 1);
Now, under OnPlayerSpawn, we need to check if the player was dead before he spawned. We can do this by:

pawn Код:
if(GetPVarInt(playerid, "Dead")) {
    SetPlayerPos(playerid, fX, fY, fZ); // Position of the hospital.
    DeletePVar(playerid, "Dead");
}
Reply
#4

Thanks
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)