SA-MP Forums Archive
Timer within command - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Timer within command (/showthread.php?tid=659187)



Timer within command - Alexis17 - 26.09.2018

Hello community samp Today I have a question, Is not there an include or fragment of code that can make a timer within a command?


PHP код:
CMDexample (playeridparams [])
{
    
SendClientMessage (playerid, -1"Hello");
    
After (5// Five minutes
    
{
        
// Does the function
    
}
    return 
1;

After that it will be my stock.


Re: Timer within command - Banditul18 - 26.09.2018

You can achive that with inline timers so you keep all that in the command


Re: Timer within command - Alexis17 - 26.09.2018

Quote:
Originally Posted by Banditul18
Посмотреть сообщение
You can achive that with inline timers so you keep all that in the command
I just do not want to use a timer, since I'll use many timers 1 time only


Re: Timer within command - v1k1nG - 26.09.2018

Use tickcount:
PHP код:

new 
tick,
commandtick;
// somewhere under gamemode/fs init
tick tickcount();
// Your command
CMDexample (playeridparams [])
{
    
SendClientMessage (playerid, -1"Hello");
    
commandtick tickcount(); // Get the milliseconds
    
return 1;
}
// somewhere in your code
if(tick commandtick) >= 300000 /* 300 seconds = 5 mins */ {
    
// Your things




Re: Timer within command - Alexis17 - 26.09.2018

I just want everything in the command

EJ:

PHP код:
CMDengine (playeridparams [])
{
    
SendClientMessage (playerid, -1"Turning on engine ...");
    
After (1// When 1 minute passes
    
{
        
SendClientMessage (playerid, -1"Engine on");
    }




Re: Timer within command - v1k1nG - 26.09.2018

Once the command is executed you need to execute it again to read the code inside it aka you need to postpone your actions in elsewhere using another function.


Re: Timer within command - Alexis17 - 26.09.2018

Quote:
Originally Posted by v1k1nG
Посмотреть сообщение
Once the command is executed you need to execute it again to read the code inside it aka you need to postpone your actions in elsewhere using another function.
Thank You