add FailNadeFriday
This commit is contained in:
		
							parent
							
								
									6c13d692a0
								
							
						
					
					
						commit
						5a85455187
					
				
							
								
								
									
										179
									
								
								FailNadeFriday/scripting/FailNadeFriday.sp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										179
									
								
								FailNadeFriday/scripting/FailNadeFriday.sp
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,179 @@
 | 
				
			|||||||
 | 
					#pragma semicolon 1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <sourcemod>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "nominations_extended.inc"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#pragma newdecls required
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					char g_sBlacklistedMapsPath[PLATFORM_MAX_PATH];
 | 
				
			||||||
 | 
					char g_sExtraMapsPath[PLATFORM_MAX_PATH];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public Plugin myinfo =
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						name = "Failnade Fridays",
 | 
				
			||||||
 | 
						author = "Obus",
 | 
				
			||||||
 | 
						description = "",
 | 
				
			||||||
 | 
						version = "",
 | 
				
			||||||
 | 
						url = ""
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public void OnPluginStart()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						BuildPath(Path_SM, g_sBlacklistedMapsPath, sizeof(g_sBlacklistedMapsPath), "configs/failnadefridayblacklist.cfg");
 | 
				
			||||||
 | 
						BuildPath(Path_SM, g_sExtraMapsPath, sizeof(g_sExtraMapsPath), "configs/failnadefridayextra.cfg");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (!FileExists(g_sBlacklistedMapsPath))
 | 
				
			||||||
 | 
							LogMessage("configs/failnadefridayblacklist.cfg missing, is this intended?");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (!FileExists(g_sExtraMapsPath))
 | 
				
			||||||
 | 
							LogMessage("configs/failnadefridayextra.cfg missing, is this intended?");
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public void OnClientPutInServer(int client)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						if (IsVoteInProgress())
 | 
				
			||||||
 | 
							return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (!IsItFailnadeTime())
 | 
				
			||||||
 | 
							return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						Panel hNotifyPanel = new Panel(GetMenuStyleHandle(MenuStyle_Radio));
 | 
				
			||||||
 | 
						hNotifyPanel.SetTitle("*** It's Fail Nade Friday! ***");
 | 
				
			||||||
 | 
						hNotifyPanel.DrawItem("", ITEMDRAW_SPACER);
 | 
				
			||||||
 | 
						hNotifyPanel.DrawItem("** Nades have a much higher knockback than usual for today. **", ITEMDRAW_RAWLINE);
 | 
				
			||||||
 | 
						hNotifyPanel.DrawItem("** In addition to that, extra maps have been added to rotation for today! **", ITEMDRAW_RAWLINE);
 | 
				
			||||||
 | 
						hNotifyPanel.DrawItem("", ITEMDRAW_SPACER);
 | 
				
			||||||
 | 
						hNotifyPanel.DrawItem("** Have fun! **", ITEMDRAW_RAWLINE);
 | 
				
			||||||
 | 
						hNotifyPanel.DrawItem("", ITEMDRAW_SPACER);
 | 
				
			||||||
 | 
						hNotifyPanel.DrawItem("1. Got it!", ITEMDRAW_RAWLINE);
 | 
				
			||||||
 | 
						hNotifyPanel.SetKeys(1023);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						hNotifyPanel.Send(client, MenuHandler_NotifyPanel, 0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						delete hNotifyPanel;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					int MenuHandler_NotifyPanel(Menu hMenu, MenuAction iAction, int iParam1, int iParam2)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						switch (iAction)
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							case MenuAction_Select, MenuAction_Cancel:
 | 
				
			||||||
 | 
								delete hMenu;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public void OnConfigsExecuted()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						CreateTimer(5.0, Timer_PostOnConfigsExecuted, TIMER_FLAG_NO_MAPCHANGE, _);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public Action Timer_PostOnConfigsExecuted(Handle hThis)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						if (!FileExists(g_sBlacklistedMapsPath))
 | 
				
			||||||
 | 
							SetFailState("configs/failnadefriday.cfg missing!");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (IsItFailnadeTime())
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							ArrayList hExtraMaps = new ArrayList(ByteCountToCells(PLATFORM_MAX_PATH));
 | 
				
			||||||
 | 
							File hExtraMapsConfig = OpenFile(g_sExtraMapsPath, "r");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							while (!hExtraMapsConfig.EndOfFile())
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								char sLine[128];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								if (!hExtraMapsConfig.ReadLine(sLine, sizeof(sLine)))
 | 
				
			||||||
 | 
									break;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								if (strncmp(sLine, "//", 2) == 0)
 | 
				
			||||||
 | 
									continue;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								int iCurIndex=0;
 | 
				
			||||||
 | 
								while (sLine[iCurIndex] != '\0')
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									if (sLine[iCurIndex] < 0x20 || sLine[iCurIndex] > 0x7F) sLine[iCurIndex] = '\0';
 | 
				
			||||||
 | 
									iCurIndex++;
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								sLine[iCurIndex-1]='\0';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								if (IsMapValid(sLine))
 | 
				
			||||||
 | 
									hExtraMaps.PushString(sLine);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							SortADTArrayCustom(view_as<Handle>(hExtraMaps), SortFuncADTArray_SortAlphabetical);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							PushMapsIntoNominationPool(hExtraMaps);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							delete hExtraMapsConfig;
 | 
				
			||||||
 | 
							delete hExtraMaps;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							char sMap[64];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							GetCurrentMap(sMap, sizeof(sMap));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							File hBlacklistedMapsConfig = OpenFile(g_sBlacklistedMapsPath, "r");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							while (!hBlacklistedMapsConfig.EndOfFile())
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								char sLine[128];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								if (!hBlacklistedMapsConfig.ReadLine(sLine, sizeof(sLine)))
 | 
				
			||||||
 | 
									break;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								if (strncmp(sLine, "//", 2) == 0)
 | 
				
			||||||
 | 
									continue;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								int iCurIndex=0;
 | 
				
			||||||
 | 
								while (sLine[iCurIndex] != '\0')
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									if (sLine[iCurIndex] < 0x20 || sLine[iCurIndex] > 0x7F) sLine[iCurIndex] = '\0';
 | 
				
			||||||
 | 
									iCurIndex++;
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								sLine[iCurIndex-1]='\0';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								if (strcmp(sLine, sMap, false) == 0)
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									delete hBlacklistedMapsConfig;
 | 
				
			||||||
 | 
									return;
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							delete hBlacklistedMapsConfig;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							CreateTimer(3.0, Timer_LoadConfig, _, TIMER_FLAG_NO_MAPCHANGE);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					int SortFuncADTArray_SortAlphabetical(int idx1, int idx2, Handle hExtraMaps, Handle unk)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						char sStr1[PLATFORM_MAX_PATH];
 | 
				
			||||||
 | 
						char sStr2[PLATFORM_MAX_PATH];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						view_as<ArrayList>(hExtraMaps).GetString(idx1, sStr1, sizeof(sStr1));
 | 
				
			||||||
 | 
						view_as<ArrayList>(hExtraMaps).GetString(idx2, sStr2, sizeof(sStr2));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return strcmp(sStr2, sStr1, false);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public Action Timer_LoadConfig(Handle hThis)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						ServerCommand("exec failnadefriday");//2lazy
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					stock bool IsItFailnadeTime()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						int iTime = GetTime();
 | 
				
			||||||
 | 
						int iHour;
 | 
				
			||||||
 | 
						char sTime[32];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						FormatTime(sTime, sizeof(sTime), "%w %H", iTime);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						iHour = StringToInt(sTime[2]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if ((sTime[0] == '5' && iHour >= 6) || (sTime[0] == '6' && iHour < 6))
 | 
				
			||||||
 | 
							return true;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return false;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										1
									
								
								includes/nominations_extended.inc
									
									
									
									
									
										Symbolic link
									
								
							
							
						
						
									
										1
									
								
								includes/nominations_extended.inc
									
									
									
									
									
										Symbolic link
									
								
							@ -0,0 +1 @@
 | 
				
			|||||||
 | 
					../mapchooser_extended/scripting/include/nominations_extended.inc
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user