cmd timer
#3

Here is a mini tutorial: (You can still copy paste but I suggest you to understand it)
PHP код:
//On top of your script
new StealTimer[MAX_PLAYERS]; //Declaring a variable to store the player timers in
new StealCount[MAX_PLAYERS]; //Declaring a variable to check where the timer has reached (counting)
CMD:steal(playerid//A command using ZCMD include
{
    
StealTimer[playerid] = SetTimerEx("StealFromPlayer"1000true"i"playerid); //Here we assigned the variable StealTimer to a player timer which repeats every one second
    
StealCount[playerid] = 5//CHANGE THIS > Assign the time in seconds to do the action after (countdown variable)
    
new counttext[25]; //The following 3 lines just to print to the player a message on where the count has reached
    
format(counttextsizeof(counttext), "~r~~h~%i Seconds Remaining"StealCount);
    
GameTextForPlayer(playeridcounttext10004);
    return 
1;
}
forward StealFromPlayer(playerid); //Forwarded the function of the timer
public StealFromPlayer(playerid)
{
    
StealCount[playerid]--; //We decrese the counter every one second by one
    
if(StealCount[playerid] == 0//This is if 5 seconds passed to the count (reached 0)
    
{
        
KillTimer(StealTimer[playerid]); //Don't forget to kill the timer so it doesn't stay on after you have done your things
        
GameTextForPlayer(playerid"~g~~h~Done"10004);
        
//Robbed from player (YOUR CODES)
    
}
    else 
//If the count didn't reach 0 yet. print him the remaining time
    
{
        new 
counttext[25];
        
format(counttextsizeof(counttext), "~r~~h~%i Seconds Remaining"StealCount);
        
GameTextForPlayer(playeridcounttext10004);
    }
    return 
1;

Reply


Messages In This Thread
cmd timer - by CheckItOut - 20.07.2017, 07:49
Re: cmd timer - by coool - 20.07.2017, 07:55
Re: cmd timer - by FailerZ - 20.07.2017, 08:12
Re: cmd timer - by CheckItOut - 20.07.2017, 08:29
Re: cmd timer - by FailerZ - 20.07.2017, 08:46
Re: cmd timer - by CheckItOut - 20.07.2017, 08:47
Re: cmd timer - by FailerZ - 20.07.2017, 08:50

Forum Jump:


Users browsing this thread: 1 Guest(s)