AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   Time check (https://forums.alliedmods.net/showthread.php?t=330264)

jugule 01-26-2021 19:37

Time check
 
Hi, does anyone have any idea how to check if it's X time?
if (hour == 20)
{
code
}
thanks

FAQU 01-27-2021 04:09

Re: Time check
 
PHP Code:

public void OnPluginStart()
{
    
CreateTimer(60.0Timer_Checktime_TIMER_REPEAT);
}

public 
Action Timer_Checktime(Handle timer)
{
    
char time[32];
    
int timestamp GetTime();
    
    
FormatTime(timesizeof(time), "%H:%M"timestamp);
    
    if (
StrEqual(time"17:30"))
    {
        
// do stuff
    
}



jugule 02-06-2021 06:08

Re: Time check
 
Quote:

Originally Posted by FAQU (Post 2734451)
PHP Code:

public void OnPluginStart()
{
    
CreateTimer(60.0Timer_Checktime_TIMER_REPEAT);
}

public 
Action Timer_Checktime(Handle timer)
{
    
char time[32];
    
int timestamp GetTime();
    
    
FormatTime(timesizeof(time), "%H:%M"timestamp);
    
    if (
StrEqual(time"17:30"))
    {
        
// do stuff
    
}



Not working.

PHP Code:

public Action Timer_Checktime(Handle timer)
{
    
char time[32];
    
int timestamp GetTime();
    
    
FormatTime(timesizeof(time), "%H:%M"timestamp);
    
    for (
int i 1<= MaxClientsi++)  
    {  
        if (
IsClientInGame(i))  
        {   
            if(
StrEqual(time"00:00"))
            {
                
SetHudTextParams(-1.00.35.0741693425500.10.10.1);
                
ShowHudText(i5"Clock: 00:00");     
            }
        }
    }



FAQU 02-06-2021 10:44

Re: Time check
 
Quote:

Originally Posted by jugule (Post 2735907)
Not working.

Could you elaborate on what are you trying to achieve with this piece of code ?

Also make sure the server is not running on a different timezone than yours.
00:00 on your timezone might not be 00:00 on the server's timezone.


All times are GMT -4. The time now is 08:09.

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