31.12.2016, 11:58
so I made a death system that when you die you get injured and stay on ground 60 sec if no one helped you or admin /revive he get teleported to hospital its working fine when he die he freaze on the ground and apply the animation and when die teleport to the hospital but when I do /revive the player get revived but get teleported back to the hospital why?.
I hop you help me fix it fast
Код:
#define col_grey 0xADADADFF
new pDied[MAX_PLAYERS];
new detht;
that on player spawn:
if(pDied[playerid] == 1)
{
// Spawning at ASGH in Los Santos...
pDied[playerid] = 0;
SetPlayerPos(playerid, 1177.8596, -1324.0876, 14.0915);
// Message and money removal (using -400 at GivePlayerMoney to fine 500 as you automaticly lose $100 when you die).
SendClientMessage(playerid, col_grey, "{639E4D}INFO:{ADADAD} You have just respawned and you lost $300!");
GivePlayerMoney(playerid, -200);
}
that on playerdeath:
{
new Float:x, Float:y, Float:z;
// Resetting their position:
GetPlayerPos(playerid, x, y, z);
SetPlayerPos(playerid, x, y, z);
// Freezing them in death, aka not allowing them to respawn:
TogglePlayerControllable(playerid, 0);
ApplyAnimation(playerid, "CRACK", "crckdeth1", 4.1, 0, 1, 1, 1, 1, 1);
// Informing them and activating timer:
SendClientMessage(playerid, col_grey, "{639E4D}INFO:{ADADAD} You have been brutally Injured,If someone doesn't revive you soon, you will die!");
detht = SetTimerEx("DeathTimer", 70000, false, "i", playerid);
return 1;
}[Note]: there isn't return cause there is more coding underneath it
that the cmd:
if(strcmp(cmd, "/revive", true) == 0)
{
if(!(PlayerInfo[playerid][pAdmin] >= 1))
return SendClientMessage(playerid, COLOR_GRAD2, "You are not authorized to use this command.");
// process command
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_WHITE,"USAGE: /revive [playerid] - to revive a player");
return 1;
}
new
p=1,
ID[64] = " ",
lookupid = ReturnUser(tmp);
if(GetPlayerState(playerid) == PLAYER_STATE_PASSENGER) p=0;
if(lookupid != INVALID_PLAYER_ID)
{
if(lookupid != playerid)
{
if(!gPlayerLogged[lookupid])
return SendClientMessage(playerid, COLOR_GRAD2,"That player hasn't spawned yet.");
}
}
ID = PlayerName(lookupid);
// format string and send to player
TogglePlayerControllable(lookupid, 1);
KillTimer(detht);
pDied[lookupid] = 0;
ClearAnimations(lookupid);
SetPlayerHealth(lookupid, 50.0);
SendClientMessage(playerid, COLOR_YELLOW, "You have been revived by an admin");
format(string, sizeof(string),"Reviving %s",ID);
SendClientMessage(playerid, COLOR_GRAD2,string);
return 1;
}
forward DeathTimer(playerid);
public DeathTimer(playerid)
{
// As seen here: informing them and enabling variable:
SendClientMessage(playerid, COLOR_RED, "{639E4D}INFO:{ADADAD} Nobody managed to save you in time, you died!");
SetPlayerHealth(playerid, 0.0);
pDied[playerid] = 1;
// Spawning at ASGH in Los Santos...
pDied[playerid] = 0;
SetPlayerPos(playerid, 1177.8596, -1324.0876, 14.0915);
// Message and money removal (using -400 at GivePlayerMoney to fine 500 as you automaticly lose $100 when you die).
SendClientMessage(playerid, col_grey, "{639E4D}INFO:{ADADAD} You have just respawned and you lost $300!");
GivePlayerMoney(playerid, -200);
TogglePlayerControllable(playerid, 1);
return 1;
}


