From 6ba9f4a319e768c3b0f00be1198e57a216fabf2c Mon Sep 17 00:00:00 2001 From: dogan Date: Thu, 30 Jul 2020 02:10:43 +0200 Subject: [PATCH] DefenderMoney: fix reconnect exploit --- _DefenderMoney/scripting/DefenderMoney.sp | 73 ++++++++++++++++++++++- 1 file changed, 70 insertions(+), 3 deletions(-) diff --git a/_DefenderMoney/scripting/DefenderMoney.sp b/_DefenderMoney/scripting/DefenderMoney.sp index 9f75f01d..bdc8e8a1 100644 --- a/_DefenderMoney/scripting/DefenderMoney.sp +++ b/_DefenderMoney/scripting/DefenderMoney.sp @@ -17,15 +17,18 @@ ConVar g_cvarDamageMultiplier = null; #endif bool g_bZRLoaded; +bool g_bMapEnd; int g_iCash[MAXPLAYERS + 1]; +int g_iCashReconnect[256]; +int g_iSteamID[256]; public Plugin myinfo = { name = "Defender Money", author = "Obus + Dogan", - description = "", - version = "1.0.0", + description = "Reward Humans with cash for shooting Zombies", + version = "1.1.0", url = "" }; @@ -41,6 +44,8 @@ public void OnPluginStart() HookEvent("player_death", EventHook_PlayerDeath, EventHookMode_Pre); HookEvent("player_spawn", EventHook_PlayerSpawn, EventHookMode_Post); HookEvent("round_end", EventHook_RoundEnd, EventHookMode_Pre); + + g_bMapEnd = false; } public void OnAllPluginsLoaded() @@ -62,14 +67,76 @@ public void OnLibraryRemoved(const char[] sName) public void OnMapStart() { + for(int i = 0; i < 256; i++) + { + g_iSteamID[i] = 0; + g_iCashReconnect[i] = 0; + } + for(int i = 1; i <= MaxClients; i++) { - g_iCash[i] = 0; + g_iCash[i] = 0; } + + g_bMapEnd = false; +} + +public void OnMapEnd() +{ + g_bMapEnd = true; +} + +public void OnClientPutInServer(int client) +{ + if(IsFakeClient(client) || g_bMapEnd) + return; + + int iSteamID = GetSteamAccountID(client); + + for(int i = 0; i < 256; i++) + { + if(iSteamID == g_iSteamID[i]) + { + g_iCash[client] = g_iCashReconnect[i]; + CreateTimer(3.0, MessageReconnect, client); + break; + } + } +} + +public Action MessageReconnect(Handle timer, int client) +{ + PrintToChat(client, "[SM] Restored your cash: $%d.", g_iCash[client]); + + return Plugin_Handled; } public void OnClientDisconnect(int client) { + if(IsFakeClient(client)) + return; + + int iSteamID = GetSteamAccountID(client); + + for(int i = 0; i < 256; i++) + { + if(iSteamID == g_iSteamID[i]) + { + g_iCashReconnect[i] = GetEntProp(client, Prop_Send, "m_iAccount"); + return; + } + } + + for(int i = 0; i < 256; i++) + { + if(g_iSteamID[i] == 0) + { + g_iSteamID[i] = iSteamID; + g_iCashReconnect[i] = GetEntProp(client, Prop_Send, "m_iAccount"); + break; + } + } + g_iCash[client] = 0; }