OnPlayerSpawn - 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: OnPlayerSpawn (
/showthread.php?tid=310237)
OnPlayerSpawn -
Gooday - 11.01.2012
How i can spawn someone to hospital when died? because if someone die spawn at spawnpoint :/
Re : OnPlayerSpawn -
[HiC]TheKiller - 11.01.2012
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;
}
Re: OnPlayerSpawn -
JamesC - 11.01.2012
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");
}
Re: OnPlayerSpawn -
Gooday - 11.01.2012
Thanks