AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   Do something beetween 20:30 PM and 07:00 AM (https://forums.alliedmods.net/showthread.php?t=311930)

kratoss1812 11-08-2018 14:34

Do something beetween 20:30 PM and 07:00 AM
 
This is supposed to give vip to players for free beetween 20:30 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!");
        }
    }



shanapu 11-08-2018 15:02

Re: Do something beetween 20:30 PM and 07:00 AM
 
I would work with a cronjobs plugin like https://forums.alliedmods.net/showthread.php?t=205962

Addie 11-09-2018 04:10

Re: Do something beetween 20:30 PM and 07:00 AM
 
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
    
}



kratoss1812 11-09-2018 14:05

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

Originally Posted by Addie (Post 2623214)
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!


All times are GMT -4. The time now is 20:49.

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