diff --git a/InfoMessage/configs/info_messages/event.txt b/InfoMessage/configs/info_messages/event.txt new file mode 100644 index 00000000..351984f9 --- /dev/null +++ b/InfoMessage/configs/info_messages/event.txt @@ -0,0 +1,8 @@ +>> Event #106 || "Challenging and rarely played" << +/n +Maps : +- ze_mist_v1_3 +- ze_undertale_g_v1_2s2 +- ze_grau_s2 +/n +1. Got it diff --git a/InfoMessage/configs/info_messages/falldamage.txt b/InfoMessage/configs/info_messages/falldamage.txt new file mode 100644 index 00000000..f7b8456d --- /dev/null +++ b/InfoMessage/configs/info_messages/falldamage.txt @@ -0,0 +1,6 @@ +>>UNLOZE Falldamage Fun<< +/n +We have enabled fall damage for humans on this map. +Watch out! +/n +1. Got it \ No newline at end of file diff --git a/InfoMessage/configs/info_messages/nemesis.txt b/InfoMessage/configs/info_messages/nemesis.txt new file mode 100644 index 00000000..17699262 --- /dev/null +++ b/InfoMessage/configs/info_messages/nemesis.txt @@ -0,0 +1,12 @@ +>>UNLOZE Nemesis Fun<< +/n +Nemesis Mode is enabled on this map. +This mode has only a few but really strong zombies. +Nemesis zombies do not infect humans, but kill them instead. +They have more health, are faster and have minimal knock-back from guns. +/n +Human Tips: +You have one smoke grenade that will freeze the nemesis for 1.5 seconds. +Your knife is your best option to get rid of a nemesis zombie. +/n +1. Got it \ No newline at end of file diff --git a/InfoMessage/configs/info_messages/test.txt b/InfoMessage/configs/info_messages/test.txt new file mode 100644 index 00000000..87f202f2 --- /dev/null +++ b/InfoMessage/configs/info_messages/test.txt @@ -0,0 +1,10 @@ +Hello this is dog +/n +/n +How did those two lines get there? +/n +What is happening? +I blame Zuff. +/n +/n +1. Got it \ No newline at end of file diff --git a/InfoMessage/configs/info_messages/zmmode.txt b/InfoMessage/configs/info_messages/zmmode.txt new file mode 100644 index 00000000..fa25ed09 --- /dev/null +++ b/InfoMessage/configs/info_messages/zmmode.txt @@ -0,0 +1,12 @@ +>>UNLOZE Zombie Hunting Fun<< +/n +Zombie Hunting is enabled on this map. +Humans need to kill all zombies until the time runs up or zombies win. +Zombies have very low health. +If you die as a zombie you respawn back as a human. +/n +Zombie Tips: +Use !noblock to enable collision for 5 seconds. +This is useful to overcome obstacles by stacking on each other. +/n +1. Got it \ No newline at end of file diff --git a/InfoMessage/scripting/InfoMessage.sp b/InfoMessage/scripting/InfoMessage.sp new file mode 100644 index 00000000..f5ccc2b1 --- /dev/null +++ b/InfoMessage/scripting/InfoMessage.sp @@ -0,0 +1,115 @@ +#include + +#define MAXLINES 20 + +#pragma newdecls required + +/* CONVARS */ +ConVar g_cvInfoMessageFile; + +/* STRINGS */ +char g_sBuffer[MAXLINES][192]; + +//---------------------------------------------------------------------------------------------------- +// Purpose: +//---------------------------------------------------------------------------------------------------- +public Plugin myinfo = +{ + name = "InfoMessage", + author = "Neon", + description = "", + version = "1.0.0", + url = "https://steamcommunity.com/id/n3ontm" +}; + +//---------------------------------------------------------------------------------------------------- +// Purpose: +//---------------------------------------------------------------------------------------------------- +public void OnPluginStart() +{ + g_cvInfoMessageFile = CreateConVar("sm_info_message_file", "null", "", FCVAR_NONE); + HookConVarChange(g_cvInfoMessageFile, Cvar_FileChanged); +} + +//---------------------------------------------------------------------------------------------------- +// Purpose: +//---------------------------------------------------------------------------------------------------- +public void Cvar_FileChanged(ConVar convar, const char[] oldValue, const char[] newValue) +{ + for (int i = 0; i <= (MAXLINES - 1); i++) + g_sBuffer[i] = ""; + + char sFile[PLATFORM_MAX_PATH]; + char sLine[192]; + char sFilename[192]; + GetConVarString(g_cvInfoMessageFile, sFilename, sizeof(sFilename)) + + if (StrEqual(sFilename, "null")) + return; + + BuildPath(Path_SM, sFile, sizeof(sFile), "configs/info_messages/%s.txt", sFilename); + + Handle hFile = OpenFile(sFile, "r"); + + if(hFile != INVALID_HANDLE) + { + int iLine = 0; + while (!IsEndOfFile(hFile)) + { + if (!ReadFileLine(hFile, sLine, sizeof(sLine))) + break; + + TrimString(sLine); + g_sBuffer[iLine] = sLine; + iLine++; + } + + CloseHandle(hFile); + + } + else + LogError("[SM] File not found! (configs/info_messages/%s.txt)", sFilename); +} + +//---------------------------------------------------------------------------------------------------- +// Purpose: +//---------------------------------------------------------------------------------------------------- +int MenuHandler_NotifyPanel(Menu hMenu, MenuAction iAction, int iParam1, int iParam2) +{ + switch (iAction) + { + case MenuAction_Select, MenuAction_Cancel: + delete hMenu; + } +} + +//---------------------------------------------------------------------------------------------------- +// Purpose: +//---------------------------------------------------------------------------------------------------- +public void OnClientPutInServer(int client) +{ + char sFilename[192]; + GetConVarString(g_cvInfoMessageFile, sFilename, sizeof(sFilename)) + + if (StrEqual(sFilename, "null")) + return; + + Panel hNotifyPanel = new Panel(GetMenuStyleHandle(MenuStyle_Radio)); + + for (int i = 0; i <= (MAXLINES - 1); i++) + { + if (StrEqual(g_sBuffer[i], "")) + break; + + if (StrEqual(g_sBuffer[i], "/n")) + { + hNotifyPanel.DrawItem("", ITEMDRAW_SPACER); + } + else + hNotifyPanel.DrawItem(g_sBuffer[i], ITEMDRAW_RAWLINE); + } + + hNotifyPanel.SetKeys(1023); + hNotifyPanel.Send(client, MenuHandler_NotifyPanel, 0); + delete hNotifyPanel; +} \ No newline at end of file