HappyHour: change hostname and timezone
This commit is contained in:
		
							parent
							
								
									eb3ff338d9
								
							
						
					
					
						commit
						e8b7d77c4e
					
				| @ -17,6 +17,9 @@ ConVar g_cvMorningEnd; | |||||||
| ConVar g_cvNightStart; | ConVar g_cvNightStart; | ||||||
| ConVar g_cvNightEnd; | ConVar g_cvNightEnd; | ||||||
| 
 | 
 | ||||||
|  | ConVar g_cvHostName; | ||||||
|  | char g_sHostName[128]; | ||||||
|  | 
 | ||||||
| public Plugin myinfo = | public Plugin myinfo = | ||||||
| { | { | ||||||
| 	name = "Happy Hour", | 	name = "Happy Hour", | ||||||
| @ -40,12 +43,14 @@ public void OnPluginStart() | |||||||
| 	g_bHappyHourAdmin = false; | 	g_bHappyHourAdmin = false; | ||||||
| 
 | 
 | ||||||
| 	CreateTimer(15.0, Timer_CheckTime, _, TIMER_REPEAT); | 	CreateTimer(15.0, Timer_CheckTime, _, TIMER_REPEAT); | ||||||
| 	CreateTimer(30.0, MessageHappyHour, _, TIMER_REPEAT); | 	CreateTimer(45.0, MessageHappyHour, _, TIMER_REPEAT); | ||||||
| 
 | 
 | ||||||
| 	g_cvMorningStart = CreateConVar("sm_happyhour_morning_start", "1000", "starttime of happy hour in the morning (timezone GMT+1 in summer, GMT+2 in winter)"); | 	g_cvMorningStart = CreateConVar("sm_happyhour_morning_start", "1000", "starttime of happy hour in the morning (timezone UTC+1 in summer, UTC+2 in winter)"); | ||||||
| 	g_cvMorningEnd = CreateConVar("sm_happyhour_morning_end", "1400", "endtime of happy hour in the morning/afternoon (timezone GMT+1 in summer, GMT+2 in winter)"); | 	g_cvMorningEnd = CreateConVar("sm_happyhour_morning_end", "1400", "endtime of happy hour in the morning/afternoon (timezone UTC+1 in summer, UTC+2 in winter)"); | ||||||
| 	g_cvNightStart = CreateConVar("sm_happyhour_night_start", "2300", "starttime of happy hour in the night (timezone GMT+1 in summer, GMT+2 in winter)"); | 	g_cvNightStart = CreateConVar("sm_happyhour_night_start", "2300", "starttime of happy hour in the night (timezone UTC+1 in summer, UTC+2 in winter)"); | ||||||
| 	g_cvNightEnd = CreateConVar("sm_happyhour_night_end", "0300", "endtime of happy hour in the night (timezone GMT+1 in summer, GMT+2 in winter)"); | 	g_cvNightEnd = CreateConVar("sm_happyhour_night_end", "0300", "endtime of happy hour in the night (timezone UTC+1 in summer, UTC+2 in winter)"); | ||||||
|  | 
 | ||||||
|  | 	g_cvHostName = FindConVar("hostname"); | ||||||
| 
 | 
 | ||||||
| 	RegConsoleCmd("sm_hh", Command_DisplayHappyHour, "Shows if happy hour is currently enabled or not"); | 	RegConsoleCmd("sm_hh", Command_DisplayHappyHour, "Shows if happy hour is currently enabled or not"); | ||||||
| 
 | 
 | ||||||
| @ -68,15 +73,24 @@ public void ConVarChange(ConVar convar, char[] oldValue, char[] newValue) | |||||||
| 	GetConVars(); | 	GetConVars(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | public void OnConfigsExecuted() | ||||||
|  | { | ||||||
|  | 	g_cvHostName.GetString(g_sHostName, sizeof(g_sHostName)); | ||||||
|  | } | ||||||
|  | 
 | ||||||
| public Action Timer_CheckTime(Handle timer) | public Action Timer_CheckTime(Handle timer) | ||||||
| { | { | ||||||
|     if(g_bHappyHourAdmin) |     if(g_bHappyHourAdmin) | ||||||
|         return Plugin_Continue; |         return Plugin_Continue; | ||||||
| 
 | 
 | ||||||
|     if((InsideTimeFrame(g_iMorningStart, g_iMorningEnd)) || (InsideTimeFrame(g_iNightStart, g_iNightEnd))) |     if((InsideTimeFrame(g_iMorningStart, g_iMorningEnd)) || (InsideTimeFrame(g_iNightStart, g_iNightEnd))) | ||||||
|  | 	{ | ||||||
| 		g_bHappyHour = true; | 		g_bHappyHour = true; | ||||||
|  | 	} | ||||||
|     else |     else | ||||||
|  | 	{ | ||||||
| 		g_bHappyHour = false; | 		g_bHappyHour = false; | ||||||
|  | 	} | ||||||
| 
 | 
 | ||||||
|     return Plugin_Continue; |     return Plugin_Continue; | ||||||
| } | } | ||||||
| @ -151,7 +165,16 @@ public void ToggleHappyHour(int client) | |||||||
| public Action MessageHappyHour(Handle timer) | public Action MessageHappyHour(Handle timer) | ||||||
| { | { | ||||||
| 	if(g_bHappyHour) | 	if(g_bHappyHour) | ||||||
| 		CPrintToChatAll("{cyan}[UNLOZE] {red}Happy Hour {cyan}is currently active! Everyone gets 50%% Bonus on all rank points!"); | 	{ | ||||||
|  | 		CPrintToChatAll("{cyan}[UNLOZE] {red}Happy Hour {cyan}is currently active! Everyone gets 50%% Bonus on most rank points!"); | ||||||
|  | 		char sBuffer[sizeof(g_sHostName)]; | ||||||
|  | 		Format(sBuffer, sizeof(sBuffer), "[HappyHour] %s", g_sHostName); | ||||||
|  | 		g_cvHostName.SetString(sBuffer); | ||||||
|  | 	} | ||||||
|  | 	else | ||||||
|  | 	{ | ||||||
|  | 		g_cvHostName.SetString(g_sHostName); | ||||||
|  | 	} | ||||||
| 
 | 
 | ||||||
| 	return Plugin_Continue; | 	return Plugin_Continue; | ||||||
| } | } | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user