Timer for a command
#1

Hi guys,
I want to create a timer so that the player will not abuse that command.In this case it's a heal command
so, if you want the code I will paste it (I think it is unnecessary).
Reply
#2

PHP код:
new Healstop//on top of script
CMD:heal(playeridparams[])//your command here
{
    if(
Healstop gettime())
    {
    
SendClientMessage(playerid, -,"You need to wait 1 minute before using /heal again");
    }
    else
    {
    
//your code here
    
Healstop gettime() + 60;
    }
    return 
1;

Reply
#3

Where should I add "setplayerhealth" then?
Edit:Sorry didn't pay good attention.Thanks!
Reply
#4

Inside command
Reply
#5

PHP код:
CMD:heal(playeridparams[])

    if(
Healstop gettime()) 
    { 
    
SendClientMessage(playerid, -,"You need to wait 1 minute before using /heal again"); 
    } 
    else 
    { 
    
//ADD your command code here setplayerhealth and all other things
    
Healstop gettime() + 60
    } 
    return 
1

Reply
#6

This will block the command for everybody and not per player.
PHP код:
new HealTime[MAX_PLAYERS];

CMD:heal(playeridparams[]) 
{  
    if(
HealTime[playerid] > gettime())  
    {
        
SendClientMessage(playerid, -,"You need to wait 1 minute before using /heal again");  
    }  
    else  
    {  
    
//ADD your command code here setplayerhealth and all other things 
        
HealTime[playerid] = gettime() + 60;  
    }  
    return 
1;  

Reply
#7

Don't you guys read the "Edit"?._., anyways thanks to all
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)