22.07.2011, 13:15
pawn Код:
forward DEAD1(playerid);
forward RespawnHospital(playerid);
new gPlayerDied[MAX_PLAYERS];
public OnPlayerDeath(playerid,killerid,reason)
{
gPlayerDied[playerid]=1;// this flags that player has died, we will need it OnPlayerSpawn
SetTimerEx("RespawnHospital", 3500, 0,"d",playerid);// this will happen after 3.5 sec, why SetTimerEx check https://sampwiki.blast.hk/wiki/SetTimerEx
//... whatever is in your code.
return 1;// once program comes to this code, he automaticly goes to OnPlayerSpawn. We don't want player to be spawned somewhere random, do we?
}
public OnPlayerSpawn(playerid)
{// once player attempts to spawn, we don't allow him with this code.
if(gPlayerDied[playerid] == 1)// this checks if he died, if so it enters this if clause
{
gPlayerDied[playerid]=0;// we are setting this variable to default because we don't need it anymore.
return 0;// this prevents player from spawning and exits the callback.
}
//... whatever is in your code
return 1;
}
public RespawnHospital(playerid)
{
SendClientMessage(playerid, COLOUR_YELLOW, "You're being rushed to the hospital!");
SetPlayerPos(playerid, 1221.7010,-1328.6449,13.4821);
SetPlayerCameraPos(playerid, 1204.3781,-1313.3323,16.3984);
SetPlayerCameraLookAt(playerid, 1174.7167,-1323.4485,14.5938);
TogglePlayerControllable(playerid,0);
SetTimerEx("DEAD1", 50000, 0,"d",playerid);
return 1;
}
public DEAD1(playerid)
{
SetPlayerHealth(playerid,100);
SetPlayerPos(playerid,1172.6569,-1323.2815,15.4025);
TogglePlayerControllable(playerid,1);
SetCameraBehindPlayer(playerid);
return 1;
}