10.02.2015, 21:28
Hello.
Im using admantis afterlife system (https://sampforum.blast.hk/showthread.php?pid=990124#pid990124) on my GM. It works just fine if im alone. After dieing, it counts 30 secs and then spawns me into hospital. The problem is, when multiple players die (at least i think so) and try to revive the timer(SecsToGo[playerid]) glitches and goes negative and it would never ever stop
So heres my code:
.
This is the command to start the afterlife process:
And the define for the Afterlife secounds.
I just dont get it. There is a check that prevents it from going negative....
Im using admantis afterlife system (https://sampforum.blast.hk/showthread.php?pid=990124#pid990124) on my GM. It works just fine if im alone. After dieing, it counts 30 secs and then spawns me into hospital. The problem is, when multiple players die (at least i think so) and try to revive the timer(SecsToGo[playerid]) glitches and goes negative and it would never ever stop
So heres my code:
PHP код:
public AfterLife(playerid)
{
IsAfterLifing[playerid] = 1;
SecsToGo[playerid]--;
new string[128];
format(string,sizeof(string),"~b~ ~h~ ~h~Tu You' ve passed out~n~ ~b~ ~h~ ~h~You're gona be just fine in %d seconds.",SecsToGo[playerid]);
GameTextForPlayer(playerid,string,1100,3);
if (SecsToGo[playerid] <= 0)
{
CleanPlayerChat(playerid);
KillTimer(AfterLifeTimer);
SCM(playerid,COLOR_RED,"--------------------------------------------------------");
SCM(playerid,WHITE,"-");
SCM(playerid,WHITE,"-");
SCM(playerid,WHITE,"-");
SCM(playerid,COLOR_RED,"--------------------------------------------------------");
SetPlayerVirtualWorld(playerid, 0);
SetPlayerPos(playerid, 1598.2131,1172.3086,1025.3767);
SetCameraBehindPlayer(playerid);
TogglePlayerControllable(playerid,true);
return 1;
}
return 1;
}
This is the command to start the afterlife process:
PHP код:
CMD:acceptdeath(playerid, params[])
{
#pragma unused params
if (IsDead[playerid] == 0) { return 0; }
else
{
IsDead[playerid] = 0;
SecsToGo[playerid] = AFTERLIFE_SECONDS;
CleanPlayerChat(playerid);
ResetWeapon(playerid);
SCM(playerid,COLOR_RED,"--------------------------------------------------------");
SCM(playerid,WHITE,"Tu esi miris. Atputies. ");
SCM(playerid,WHITE,"Kad atdzimsi, busi aizmirsis visu, kas notika pedejo 30 min laika.");
SCM(playerid,WHITE,"Ja tevi nogalinaja NeRPiski, zino foruma.");
SCM(playerid,COLOR_RED,"--------------------------------------------------------");
SetPlayerVirtualWorld(playerid, 0);
SetPlayerInterior(playerid, 0);
SetPlayerPos(playerid,1194.5045,-1335.0654,13.3984-15);
SetPlayerCameraPos(playerid,1194.5045,-1335.0654,13.3984);
SetPlayerCameraLookAt(playerid,1178.5105,-1314.2529,14.0983);
AfterLifeTimer = SetTimerEx("AfterLife",1000,true,"i",playerid);
return 1;
}
}
PHP код:
#define AFTERLIFE_SECONDS 30
PHP код:
if (SecsToGo[playerid] <= 0)