Why This Code Not Work ! -
TYDS - 29.10.2016
Код:
if(strcmp(params, "die", true) == 0) {
new DieTimer[MAX_PLAYERS];
if(gettime() < DieTimer[playerid])
{
format(string, sizeof(string), "Ban phai doi %d giay moi co the chet.", DieTimer[playerid]-gettime());
SendClientMessageEx(playerid, COLOR_GREY, string);
return 1;
}
DieTimer[playerid] = gettime()+30;
if(GetPVarInt(playerid, "Injured") == 1) {
SendClientMessageEx(playerid, COLOR_WHITE, "You A Dead.");
KillEMSQueue(playerid);
ResetPlayerWeaponsEx(playerid);
SpawnPlayer(playerid);
}
else { SendClientMessageEx(playerid, COLOR_GREY, " u cannot do that right now!"); }
}
when i type /accept die it's no wait for time like the code ??
Re: Why This Code Not Work ! -
StrikerZ - 29.10.2016
PHP код:
if(strcmp(params, "die", true) == 0)
{
new DieTimer[MAX_PLAYERS];
if(gettime() < DieTimer[playerid])
{
format(string, sizeof(string), "Ban phai doi %d giay moi co the chet.", DieTimer[playerid]-gettime());
SendClientMessageEx(playerid, COLOR_GREY, string);
return 1;
}
else
{
DieTimer[playerid] = gettime()+30;
if(GetPVarInt(playerid, "Injured") == 1)
{
SendClientMessageEx(playerid, COLOR_WHITE, "You A Dead.");
KillEMSQueue(playerid);
ResetPlayerWeaponsEx(playerid);
SpawnPlayer(playerid);
}
else
{
SendClientMessageEx(playerid, COLOR_GREY, " u cannot do that right now!");
}
}
}
The reason why your code didn't worked was cuz when you type /accept die then the dietimer gets activated. And then the if statement of gettime() executes making the command stop. So you should use else after the if gettime statement i.e player typed /accept die if timer was there then it will stop else if there was no timer then the timer gets activated along with your code.
Re: Why This Code Not Work ! -
TYDS - 29.10.2016
it's still not work
Re: Why This Code Not Work ! -
Mencent - 29.10.2016
Hello.
Always when you type "/accept die" DieTimer will have the value 0 because you create this variable there.
So you should do it like this:
PHP код:
if(strcmp(params, "die", true) == 0) {
static DieTimer[MAX_PLAYERS];
if(gettime() < DieTimer[playerid])
{
format(string, sizeof(string), "Ban phai doi %d giay moi co the chet.", DieTimer[playerid]-gettime());
SendClientMessageEx(playerid, COLOR_GREY, string);
return 1;
}
DieTimer[playerid] = gettime()+30;
if(GetPVarInt(playerid, "Injured") == 1) {
SendClientMessageEx(playerid, COLOR_WHITE, "You A Dead.");
KillEMSQueue(playerid);
ResetPlayerWeaponsEx(playerid);
SpawnPlayer(playerid);
}
else { SendClientMessageEx(playerid, COLOR_GREY, " u cannot do that right now!"); }
}
Try this. I think static will help you.
Re: Why This Code Not Work ! -
TYDS - 29.10.2016
i want to make it's 30 second so what sould i do ??
Re: Why This Code Not Work ! -
Mencent - 29.10.2016
It's alright like this. Does it not work?
Re: Why This Code Not Work ! -
TYDS - 29.10.2016
i am compling =]]]z i will try it's when compiler is done
Re: Why This Code Not Work ! -
TYDS - 29.10.2016
it's still no work =]]]z
Re: Why This Code Not Work ! -
StrikerZ - 29.10.2016
Then maybe you are missing to set the "Injured" PVarInt.
Re: Why This Code Not Work ! -
HoangNam - 29.10.2016
Try SetTimerEx