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

Help with plugin not using correct time


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ozrich
AlliedModders Donor
Join Date: Oct 2015
Old 03-14-2019 , 23:18   Help with plugin not using correct time
Reply With Quote #1

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);

__________________
ozrich is offline
Lux
Veteran Member
Join Date: Jan 2015
Location: Cat
Old 03-15-2019 , 06:20   Re: Help with plugin not using correct time
Reply With Quote #2

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
__________________
Connect
My Plugins: KlickME
[My GitHub]

Commission me for L4D

Last edited by Lux; 03-15-2019 at 06:21.
Lux is offline
lugui
Senior Member
Join Date: Feb 2016
Location: GetClientAbsOrigin();
Old 03-19-2019 , 10:01   Re: Help with plugin not using correct time
Reply With Quote #3

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;


Last edited by lugui; 03-19-2019 at 10:02.
lugui 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 06:58.


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