Raised This Month: $12 Target: $400
 3% 

Time check


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
jugule
AlliedModders Donor
Join Date: Apr 2020
Old 01-26-2021 , 19:37   Time check
Reply With Quote #1

Hi, does anyone have any idea how to check if it's X time?
if (hour == 20)
{
code
}
thanks
jugule is offline
FAQU
Member
Join Date: Sep 2020
Location: Romania
Old 01-27-2021 , 04:09   Re: Time check
Reply With Quote #2

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
    
}

__________________
FAQU is offline
jugule
AlliedModders Donor
Join Date: Apr 2020
Old 02-06-2021 , 06:08   Re: Time check
Reply With Quote #3

Quote:
Originally Posted by FAQU View Post
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");     
            }
        }
    }


Last edited by jugule; 02-06-2021 at 06:10.
jugule is offline
FAQU
Member
Join Date: Sep 2020
Location: Romania
Old 02-06-2021 , 10:44   Re: Time check
Reply With Quote #4

Quote:
Originally Posted by jugule View Post
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.
__________________
FAQU is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 10:22.


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