AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Event for specified time - do every day in xx:xx hours (https://forums.alliedmods.net/showthread.php?t=249493)

Hepaa 10-06-2014 14:04

Event for specified time - do every day in xx:xx hours
 
Hi, do you know if is possible to have event that will run every day in xx : xx time? E.g. in 19:00 every day. Thank you.

FromTheFuture 10-06-2014 14:31

Re: Event for specified time - do every day in xx:xx hours
 
I have this, bit it's need to fix errors.
PHP Code:

stock set_task_runtime(time[11], const func[], id 0, const param[]=""len 0)
{
 
new 
h[5], m[5], s[5]
 
get_time("%H"hcharsmax(h))
get_time("%M"mcharsmax(m))
get_time("%S"scharsmax(s))
 
new 
iCurSeconds = (str_to_num(h) * 3600) + (str_to_num(m) * 60) + str_to_num(s)
 
replace_all(timecharsmax(time), ":" " ")
parse(timehcharsmax(h), mcharsmax(m), scharsmax(s))
 
new 
iRunSeconds = (str_to_num(h) * 3600)+ (str_to_num(m) * 60) + str_to_num(s)
 
new 
iTotal iRunSeconds iCurSeconds
 
if(iTotal<=0iTotal iCurSeconds iRunSeconds
 
return set_task(float(iTotal), funcidparamlen)
 


PHP Code:

set_task_runtime("23:00:00""GoToSleep_Kid"id

If anyone is can fix it, please.

FromTheFuture 10-06-2014 14:55

Re: Event for specified time - do every day in xx:xx hours
 
I fix it =D
Wait...

FromTheFuture 10-06-2014 15:02

Re: Event for specified time - do every day in xx:xx hours
 
PHP Code:

stock set_task_runtime(str_time[11], const func[], id 0, const param[] = ""len 0
{
    new 
h[5], m[5], s[5]; 

    
get_time("%H"hcharsmax(h)); 
    
get_time("%M"mcharsmax(m)); 
    
get_time("%S"scharsmax(s)); 
  
    new 
iCurSeconds = (str_to_num(h) * 3600) + (str_to_num(m) * 60) + str_to_num(s); 
  
    
replace_all(str_timecharsmax(str_time), ":" " "); 
    
parse(str_timehcharsmax(h), mcharsmax(m), scharsmax(s)); 
  
    new 
iRunSeconds = (str_to_num(h) * 3600)+ (str_to_num(m) * 60) + str_to_num(s);
  
    new 
iTotal iRunSeconds iCurSeconds;
  
    if(
iTotal <= 0
    {
        
iTotal = ( 86400 iCurSeconds ) + iRunSeconds;
    }
  
    return 
set_task(float(iTotal), funcidparamlen); 



Hepaa 10-06-2014 15:11

Re: Event for specified time - do every day in xx:xx hours
 
Thank you, i will try that. Where can I specify time what I need? And where can I set action to do when the time come?

FromTheFuture 10-06-2014 15:15

Re: Event for specified time - do every day in xx:xx hours
 
Quote:

Originally Posted by Hepaa (Post 2208000)
Thank you, i will try that. Where can I specify time what I need? And where can I set action to do when the time come?

U must set this in
PHP Code:

set_task_runtime("01:02:00""YourFunction"id

and after all code paste the stock.

fysiks 10-06-2014 21:02

Re: Event for specified time - do every day in xx:xx hours
 
Simply use "Task Scheduler" plugin.

@FromTheFuture, you can't set a task that is longer than mp_timelimit.

FromTheFuture 10-07-2014 04:34

Quote:

Originally Posted by fysiks (Post 2208074)
@FromTheFuture, you can't set a task that is longer than mp_timelimit.

Great, no need to make a check in the stock.

Quote:

Originally Posted by fysiks (Post 2208074)
Simply use "Task Scheduler" plugin.

I think this stock will be better to use.

aron9forever 10-07-2014 07:32

Re: Event for specified time - do every day in xx:xx hours
 
PHP Code:


    
new CurrentTime[9
    
get_time("%H",CurrentTime,8)
    new 
hour str_to_num(CurrentTime)
    if(
hour==19)
{
//event



FromTheFuture 10-07-2014 08:16

Re: Event for specified time - do every day in xx:xx hours
 
Quote:

Originally Posted by aron9forever (Post 2208180)
PHP Code:


    
new CurrentTime[9
    
get_time("%H",CurrentTime,8)
    new 
hour str_to_num(CurrentTime)
    if(
hour==19)
{
//event



No. And u can get hour with
PHP Code:

new htime(h); 



All times are GMT -4. The time now is 17:36.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.