AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   Help with plugin not using correct time (https://forums.alliedmods.net/showthread.php?t=314954)

ozrich 03-14-2019 23:18

Help with plugin not using correct time
 
Hey,

I have a plugin to shutdown the server, however, it's shutting down at the wrong time. The relevant code is below. Do I need to perhaps get the timezone first?

PHP Code:

public OnPluginStart() {
    
PrintToServer("ScheduledShutdown loaded successfully.");
    
CreateConVar("sm_scheduledshutdown_version"PL_VERSION"ScheduledShutdown version."FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY);
    
g_hEnabledHintCreateConVar("sm_scheduledshutdown_hintsay""1""Sets whether messages are shown in the hint area");
    
g_hEnabledChatCreateConVar("sm_scheduledshutdown_chatsay""1""Sets whether messages are shown in chat");
    
g_hEnabledCenter CreateConVar("sm_scheduledshutdown_centersay""1""Sets whether messages are shown in the center of the screen");
    
g_hEnabled CreateConVar("sm_scheduledshutdown""1""Enable ScheduledShutdown."FCVAR_PLUGIN);
    
g_hTime CreateConVar("sm_scheduledshutdown_time""0600""Time to shutdown server."FCVAR_PLUGIN);
    
HookConVarChange(g_hEnabledCvar_enabled);
    
HookConVarChange(g_hTimeCvar_time);
}
public 
OnMapStart() {
    
CreateTimer(60.0CheckTime0TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);
}
public 
OnConfigsExecuted() {
    
g_bEnabled GetConVarBool(g_hEnabled);
    
decl String:iTime[8];
    
GetConVarString(g_hTimeiTimesizeof(iTime));
    
g_iTime StringToInt(iTime);
}
public 
Cvar_enabled(Handle:convar, const String:oldValue[], const String:newValue[]) {
    
g_bEnabled GetConVarBool(g_hEnabled);
}
public 
Cvar_time(Handle:convar, const String:oldValue[], const String:newValue[]) {
    
decl String:iTime[8];
    
GetConVarString(g_hTimeiTimesizeof(iTime));
    
g_iTime StringToInt(iTime);



Lux 03-15-2019 06:20

Re: Help with plugin not using correct time
 
This is not all the relevant code

public Action:CheckTime() are you doing here?

Also Wrong section should be here: https://forums.alliedmods.net/forumdisplay.php?f=107

lugui 03-19-2019 10:01

Re: Help with plugin not using correct time
 
PHP Code:

// Generates GMT Date and compensates for timezones
char GetGmtDate()
{
    
int timestamp GetTime();
    
    
// Fix timezones
    
char offsetstr[10];
    
FormatTime(offsetstrsizeof(offsetstr), "%z"timestamp);
    
timestamp -= (StringToInt(offsetstr) / 100) * 3600;
    
    
// Build sring
    
char GMTTime[40];
    
FormatTime(GMTTimesizeof(GMTTime), "%a, %d %h %Y %H:%M:%S GMT"timestamp);
    
    return 
GMTTime;




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

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