diff --git a/ZombieRiot/scripting/unloze_zr.sp b/ZombieRiot/scripting/unloze_zr.sp index 4a008e0e..c72d7eda 100644 --- a/ZombieRiot/scripting/unloze_zr.sp +++ b/ZombieRiot/scripting/unloze_zr.sp @@ -81,6 +81,9 @@ bool g_bClientProtection[g_dIndexes]; Handle g_hClientZMCookie; Handle g_hClientHumanCookie; +Handle g_hCheckBotStuck = null; +Handle g_hZombieSounds = null; +Handle g_hFixKNife = null; //---------------------------------------------------------------------------------------------------- // Purpose: @@ -143,6 +146,10 @@ public void OnPluginStart() RegAdminCmd("sm_human", Cmd_Humanize, ADMFLAG_BAN); RegAdminCmd("sm_infect", Cmd_Zombienize, ADMFLAG_BAN); + g_hCheckBotStuck = CreateTimer(2.0, Timer_CheckIfBotsStuck, INVALID_HANDLE, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE); + g_hZombieSounds = CreateTimer(g_fZMSounds, Timer_zombieSounds, INVALID_HANDLE, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE); + g_hFixKNife = CreateTimer(2.0, Timer_FixKNife, INVALID_HANDLE, TIMER_REPEAT); + for (int i = 1; i < MaxClients; i++) { if (IsValidClient(i)) @@ -152,6 +159,16 @@ public void OnPluginStart() } } +public void OnPluginEnd() +{ + if (g_hCheckBotStuck != null) + delete g_hCheckBotStuck; + if (g_hZombieSounds != null) + delete g_hZombieSounds; + if (g_hFixKNife != null) + delete g_hFixKNife; +} + public Action CheckPlayerTeam(Handle timer, any userid) { int client = GetClientOfUserId(userid); @@ -352,35 +369,37 @@ public Action Cmd_Say(int client, int args) getclientteam might be checked unnecesarily this way because its also checking in ZmarketGetWeapon but this way most can be stopped to interferre from triggering cmd_say */ - if (client < 1) - return Plugin_Continue; - - if (GetClientTeam(client) != CS_TEAM_CT || !IsPlayerAlive(client)) - return Plugin_Continue; - char l_cBuffer[g_dLength]; - char l_cBuffer2[g_dLength]; - GetCmdArgString(l_cBuffer, sizeof(l_cBuffer)); - if (StrContains(l_cBuffer, "!") == -1 && StrContains(l_cBuffer, "/") == -1) - return Plugin_Continue; - ReplaceString(l_cBuffer, sizeof(l_cBuffer), "\"", ""); - ReplaceString(l_cBuffer, sizeof(l_cBuffer), "/", ""); - ReplaceString(l_cBuffer, sizeof(l_cBuffer), "!", ""); - if (StrContains(l_cBuffer, "sm_") == -1) - { - Format(l_cBuffer2, sizeof(l_cBuffer2), "sm_"); - StrCat(l_cBuffer2, sizeof(l_cBuffer2), l_cBuffer); - } - for (int i = 0; i <= g_iWeaponIndex; i++) - { - if (strlen(g_cWeaponCommand[i][g_iLength]) < 1) - continue; - if (StrEqual(l_cBuffer, g_cWeaponCommand[i][g_iLength], false) || StrEqual(l_cBuffer2, g_cWeaponCommand[i][g_iLength], false)) - { - ZmarketGetWeapon(client, i); - break; - } - } - return Plugin_Continue; + if (!IsValidClient(client)) + { + return Plugin_Continue; + } + + if (GetClientTeam(client) != CS_TEAM_CT || !IsPlayerAlive(client)) + return Plugin_Continue; + char l_cBuffer[g_dLength]; + char l_cBuffer2[g_dLength]; + GetCmdArgString(l_cBuffer, sizeof(l_cBuffer)); + if (StrContains(l_cBuffer, "!") == -1 && StrContains(l_cBuffer, "/") == -1) + return Plugin_Continue; + ReplaceString(l_cBuffer, sizeof(l_cBuffer), "\"", ""); + ReplaceString(l_cBuffer, sizeof(l_cBuffer), "/", ""); + ReplaceString(l_cBuffer, sizeof(l_cBuffer), "!", ""); + if (StrContains(l_cBuffer, "sm_") == -1) + { + Format(l_cBuffer2, sizeof(l_cBuffer2), "sm_"); + StrCat(l_cBuffer2, sizeof(l_cBuffer2), l_cBuffer); + } + for (int i = 0; i <= g_iWeaponIndex; i++) + { + if (strlen(g_cWeaponCommand[i][g_iLength]) < 1) + continue; + if (StrEqual(l_cBuffer, g_cWeaponCommand[i][g_iLength], false) || StrEqual(l_cBuffer2, g_cWeaponCommand[i][g_iLength], false)) + { + ZmarketGetWeapon(client, i); + break; + } + } + return Plugin_Continue; } //---------------------------------------------------------------------------------------------------- // Purpose: @@ -828,29 +847,30 @@ public void LoadExtraSettings() //---------------------------------------------------------------------------------------------------- public void loadWeapons() { - KeyValues kv = CreateKeyValues("Weapons"); - if (!FileExists(g_cPathsWeapons)) - { - CreateBackUpWeapons(); - } - kv.ImportFromFile(g_cPathsWeapons); - kv.GotoFirstSubKey(); - kv.GetString("weaponentity", g_cWeaponEntity[g_iWeaponIndex][g_iLength], sizeof(g_cWeaponEntity)); - kv.GetString("zmarketname", g_cWeaponNames[g_iWeaponIndex][g_iLength], sizeof(g_cWeaponNames)); - g_iWeaponSlot[g_iWeaponIndex] = kv.GetNum("weaponslot"); - g_iWeaponPrice[g_iWeaponIndex] = kv.GetNum("zmarketprice"); - kv.GetString("zmarketcommand", g_cWeaponCommand[g_iWeaponIndex][g_iLength], sizeof(g_cWeaponCommand)); - g_iWeaponIndex++; - while (kv.GotoNextKey()) - { - kv.GetString("weaponentity", g_cWeaponEntity[g_iWeaponIndex][g_iLength], sizeof(g_cWeaponEntity)); - kv.GetString("zmarketname", g_cWeaponNames[g_iWeaponIndex][g_iLength], sizeof(g_cWeaponNames)); - g_iWeaponSlot[g_iWeaponIndex] = kv.GetNum("weaponslot"); - g_iWeaponPrice[g_iWeaponIndex] = kv.GetNum("zmarketprice"); - kv.GetString("zmarketcommand", g_cWeaponCommand[g_iWeaponIndex][g_iLength], sizeof(g_cWeaponCommand)); - g_iWeaponIndex++; - } - delete kv; + KeyValues kv = CreateKeyValues("Weapons"); + if (!FileExists(g_cPathsWeapons)) + { + CreateBackUpWeapons(); + } + g_iWeaponIndex = 0; //ofc this has to be reset, otherwise it ends up going out of bounds dx + kv.ImportFromFile(g_cPathsWeapons); + kv.GotoFirstSubKey(); + kv.GetString("weaponentity", g_cWeaponEntity[g_iWeaponIndex][g_iLength], sizeof(g_cWeaponEntity)); + kv.GetString("zmarketname", g_cWeaponNames[g_iWeaponIndex][g_iLength], sizeof(g_cWeaponNames)); + g_iWeaponSlot[g_iWeaponIndex] = kv.GetNum("weaponslot"); + g_iWeaponPrice[g_iWeaponIndex] = kv.GetNum("zmarketprice"); + kv.GetString("zmarketcommand", g_cWeaponCommand[g_iWeaponIndex][g_iLength], sizeof(g_cWeaponCommand)); + g_iWeaponIndex++; + while (kv.GotoNextKey()) + { + kv.GetString("weaponentity", g_cWeaponEntity[g_iWeaponIndex][g_iLength], sizeof(g_cWeaponEntity)); + kv.GetString("zmarketname", g_cWeaponNames[g_iWeaponIndex][g_iLength], sizeof(g_cWeaponNames)); + g_iWeaponSlot[g_iWeaponIndex] = kv.GetNum("weaponslot"); + g_iWeaponPrice[g_iWeaponIndex] = kv.GetNum("zmarketprice"); + kv.GetString("zmarketcommand", g_cWeaponCommand[g_iWeaponIndex][g_iLength], sizeof(g_cWeaponCommand)); + g_iWeaponIndex++; + } + delete kv; } //---------------------------------------------------------------------------------------------------- // Purpose: @@ -885,6 +905,8 @@ public Action LoadClasses() delete l_hFileZM; return Plugin_Handled; } + + //first indexes go to human classes, all afterfollowing to zms while (!IsEndOfFile(l_hFile) && ReadFileLine(l_hFile, l_cLine, sizeof(l_cLine))) { @@ -911,9 +933,6 @@ public void OnMapStart() LoadClasses(); LoadExtraSettings(); loadWeapons(); - CreateTimer(2.0, Timer_CheckIfBotsStuck, INVALID_HANDLE, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE); - CreateTimer(g_fZMSounds, Timer_zombieSounds, INVALID_HANDLE, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE); - CreateTimer(2.0, Timer_FixKNife, INVALID_HANDLE, TIMER_REPEAT); } //just checking the knife when they spawn is appereantly not good enough. this is just repeating what Timer_StopProtection does. @@ -923,6 +942,15 @@ public Action Timer_FixKNife(Handle timer, any userid) { if (IsValidClient(client) && IsPlayerAlive(client)) { + //the fucking forwards wont give the bots the client tags. it should obviously work. cause it works on ze. + //too bad! + if (IsFakeClient(client)) + { + char tag[64]; + Format(tag, sizeof(tag), "UNLOZE "); + CS_SetClientClanTag(client, tag); + } + if (GetPlayerWeaponSlot(client, CS_SLOT_KNIFE) == -1) //just making sure everybody has a knife. otherwise giving them one { GivePlayerItem(client, "weapon_knife"); @@ -1034,18 +1062,24 @@ public void Event_roundStart(Handle event, const char[] name, bool dontBroadcast //---------------------------------------------------------------------------------------------------- public Action RetrieveWaveSettings(int wave) { - Handle l_hWave = INVALID_HANDLE; - l_hWave = OpenFile(g_cPathsWaveSettings, "r"); - if (l_hWave == INVALID_HANDLE) - { - CreateDefaultWave(); - delete l_hWave; - return Plugin_Handled; - } - PrintToChatAll("Day %i: %s", wave, g_cDaysTitles[wave - 1]); - LoadWave(wave); - delete l_hWave; - return Plugin_Handled; + Handle l_hWave = INVALID_HANDLE; + l_hWave = OpenFile(g_cPathsWaveSettings, "r"); + if (l_hWave == INVALID_HANDLE) + { + CreateDefaultWave(); + delete l_hWave; + return Plugin_Handled; + } + + char hostname[512]; + Format(hostname, sizeof(hostname), "UNLOZE | FASTDL | Ranking | Day %i: %s", wave, g_cDaysTitles[wave - 1]); + ServerCommand("hostname \"%s\"", hostname); + + + PrintToChatAll("Day %i: %s", wave, g_cDaysTitles[wave - 1]); + LoadWave(wave); + delete l_hWave; + return Plugin_Handled; } //---------------------------------------------------------------------------------------------------- // Purpose: @@ -1846,8 +1880,24 @@ public Action UpdateWaveCount(int client) } else if (GetClientTeam(client) == CS_TEAM_T) { + int zombieCount = 0; + int humanCount = 0; + for (int i = 1; i <= MaxClients; i++) + { + if (IsValidClient(i)) + { + if (GetClientTeam(i) == CS_TEAM_CT) + { + humanCount++; + } + else if (GetClientTeam(i) == CS_TEAM_T) + { + zombieCount++; + } + } + } g_iZMCount--; - PrintHintTextToAll("Day %i: %s\nRemaining Zombies: %i", g_iWave, g_cDaysTitles[g_iWave - 1], g_iZMCount); + PrintHintTextToAll("Day %i: %s\nRemaining Zombies: %i\nHumans: %i\nZombies: %i", g_iWave, g_cDaysTitles[g_iWave - 1], g_iZMCount, humanCount, zombieCount); } if (g_iZMCount == 0 && g_bRoundInProgress) { @@ -1855,6 +1905,19 @@ public Action UpdateWaveCount(int client) CS_TerminateRound(4.0, CSRoundEnd_CTWin, true); g_iWave++; g_bRoundInProgress = false; + + + if (g_iWave > 90) + { + PrintToChatAll("debug: Reseting to Wave 1."); + g_iWave = 1; + } + /* i dont fucking know how g_iWave got out of bounds... + L 01/31/2024 - 10:53:07: [SM] Exception reported: Array index out-of-bounds (index 111, limit 100) + L 01/31/2024 - 10:53:07: [SM] Blaming: unloze_zr.smx + L 01/31/2024 - 10:53:07: [SM] Call stack trace: + L 01/31/2024 - 10:53:07: [SM] [1] Line 1040, unloze_zr.sp::RetrieveWaveSettings + */ } return Plugin_Continue; }