DefenderMoney: fix reconnect exploit
This commit is contained in:
		
							parent
							
								
									65fe0f846b
								
							
						
					
					
						commit
						6ba9f4a319
					
				@ -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;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user