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

Do something beetween 20:30 PM and 07:00 AM


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
kratoss1812
Senior Member
Join Date: May 2018
Location: Romānia
Old 11-08-2018 , 14:34   Do something beetween 20:30 PM and 07:00 AM
Reply With Quote #1

This is supposed to give vip to players for free beetween 200 PM and 7:00 AM.
But I don't know how to check if it's (for example) 20:46 PM or 01:04 AM

Can someone help me?
PHP Code:
#include <sourcemod>
#include <sdktools>
#include <vip_core>
char g_Group[12] = "silver"

#pragma newdecls required

bool bIsEvent;


public 
void OnPluginStart()
{
    
CreateTimer(1.0Timer_Check_TIMER_REPEAT);
    
    
bIsEvent false;
}

public 
Action Timer_Check(Handle pTimer)
{
    
int iCurTime GetTime();
    
char sTime[128];
    
FormatTime(sTimesizeof(sTime), "%I:%M %p"iCurTime);
    
    if(
StrContains(sTime"22:30"false))
    {
        
PrintCenterTextAll("FREE VIP EVENT ON. RECONNECT TO GET FREE VIP");
        
        
bIsEvent true;
        
        
CreateTimer(46800.0Time_RemoveBool);
        
        for(
int iClient 1iClient <= MaxClientsiClient++)
        {
            
VIP_GiveClientVIP(-1iClient14400g_Grouptrue);
        }
    }
}

public 
Action Time_RemoveBool(Handle _Timer)
{
    
bIsEvent false;
}

public 
void OnClientPutInServer(int iClient)
{
    if(
bIsEvent)
    {
        if(!
VIP_IsClientVIP(iClient))
        {
            
VIP_GiveClientVIP(-1iClient14400g_Group);
            
PrintToChat(iClient"[TEST] VIP EVENT ON! YOU HAVE FREE VIP SILVER!");
        }
    }

__________________
kratoss1812 is offline
shanapu
Veteran Member
Join Date: Apr 2015
Location: .de
Old 11-08-2018 , 15:02   Re: Do something beetween 20:30 PM and 07:00 AM
Reply With Quote #2

I would work with a cronjobs plugin like https://forums.alliedmods.net/showthread.php?t=205962
__________________
coding & free software
shanapu is offline
Addie
Junior Member
Join Date: Nov 2018
Old 11-09-2018 , 04:10   Re: Do something beetween 20:30 PM and 07:00 AM
Reply With Quote #3

Pseudo code, kinda awkward though:

PHP Code:
#define START_TIME 20.0
#define END_TIME 7.5

void YourFunction()
{
    
char strHours[3]; strMinutes[3];
    
FormatTime(strHourssizeof(strHours), "%H");
    
FormatTime(strMinutessizeof(strMinutes), "%M");

    
float hours StringToFloat(str_hours)
    
float minutes StringToFloat(str_minutes);

    
hours += (minutes/60)

    if (
hours START_TIME && hours END_TIME)
    {
        
//do stuff
    
}


Last edited by Addie; 11-09-2018 at 04:27.
Addie is offline
kratoss1812
Senior Member
Join Date: May 2018
Location: Romānia
Old 11-09-2018 , 14:05   Re: Do something beetween 20:30 PM and 07:00 AM
Reply With Quote #4

Quote:
Originally Posted by Addie View Post
Pseudo code, kinda awkward though:

PHP Code:
#define START_TIME 20.0
#define END_TIME 7.5

void YourFunction()
{
    
char strHours[3]; strMinutes[3];
    
FormatTime(strHourssizeof(strHours), "%H");
    
FormatTime(strMinutessizeof(strMinutes), "%M");

    
float hours StringToFloat(str_hours)
    
float minutes StringToFloat(str_minutes);

    
hours += (minutes/60)

    if (
hours START_TIME && hours END_TIME)
    {
        
//do stuff
    
}

Thanks you!
__________________
kratoss1812 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:39.


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