#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;
}
KillTimer(DeathTimer(playerid));
|
Add this on the revive cmd:
Код:
KillTimer(DeathTimer(playerid)); |
KillTimer(DeathTimer(playerid));
new Revived[MAX_PLAYERS];
new Float:InjurLastX[MAX_PLAYERS];
new Float:InjurLastY[MAX_PLAYERS];
new Float:InjurLastZ[MAX_PLAYERS];
//under oonplayerdeath replace these lines
new Float:x, Float:y, Float:z;
GetPlayerPos(playerid, x, y, z);
SetPlayerPos(playerid, x, y, z);
//to these
GetPlayerPos(playerid, InjurLastX[playerid], InjurLastY[playerid], InjurLastZ[playerid]);
SetPlayerPos(playerid, InjurLastX[playerid], InjurLastY[playerid], InjurLastZ[playerid]);
//under onplayerspawn put this code
if(Revived[playerid]== 1) //checks if the player has been revived
{
SetPlayerPos(playerid, InjurLastX[playerid], InjurLastY[playerid], InjurLastZ[playerid]); //if yes then sets player position to the last injured position
}
//in /revive command put add this line it confirms that the player has been revived
Revived[playerid] = 1;