Why This Code Not Work !
#1

Код:
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 ??
Reply
#2

PHP код:
if(strcmp(params"die"true) == 0)
{
           new 
DieTimer[MAX_PLAYERS];
           if(
gettime() < DieTimer[playerid])
           {
               
format(stringsizeof(string), "Ban phai doi %d giay moi co the chet."DieTimer[playerid]-gettime());
               
SendClientMessageEx(playeridCOLOR_GREYstring);
               return 
1;
           }
           else
           {
               
DieTimer[playerid] = gettime()+30;
               if(
GetPVarInt(playerid"Injured") == 1)
               {
                   
SendClientMessageEx(playeridCOLOR_WHITE"You A Dead.");
                   
KillEMSQueue(playerid);
                   
ResetPlayerWeaponsEx(playerid);
                   
SpawnPlayer(playerid);
                }
                else
                {
                    
SendClientMessageEx(playeridCOLOR_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.
Reply
#3

it's still not work
Reply
#4

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(stringsizeof(string), "Ban phai doi %d giay moi co the chet."DieTimer[playerid]-gettime());
        
SendClientMessageEx(playeridCOLOR_GREYstring);
        return 
1;
    }
    
DieTimer[playerid] = gettime()+30;
    if(
GetPVarInt(playerid"Injured") == 1) {
        
SendClientMessageEx(playeridCOLOR_WHITE"You A Dead.");
        
KillEMSQueue(playerid);
        
ResetPlayerWeaponsEx(playerid);
        
SpawnPlayer(playerid);
    }
    else { 
SendClientMessageEx(playeridCOLOR_GREY" u cannot do that right now!"); }

Try this. I think static will help you.
Reply
#5

i want to make it's 30 second so what sould i do ??
Reply
#6

It's alright like this. Does it not work?
Reply
#7

i am compling =]]]z i will try it's when compiler is done
Reply
#8

it's still no work =]]]z
Reply
#9

Then maybe you are missing to set the "Injured" PVarInt.
Reply
#10

Try SetTimerEx
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)