diff --git a/addons/sourcemod/scripting/szf/sdkhook.sp b/addons/sourcemod/scripting/szf/sdkhook.sp index f959597d..c0b9bf82 100644 --- a/addons/sourcemod/scripting/szf/sdkhook.sp +++ b/addons/sourcemod/scripting/szf/sdkhook.sp @@ -1,5 +1,6 @@ static int g_iOffsetDisguiseCompleteTime; static float g_flDisguiseCompleteTime; +static bool g_bLunchboxTouched[MAXPLAYERS + 1]; void SDKHook_OnEntityCreated(int iEntity, const char[] sClassname) { @@ -34,6 +35,8 @@ void SDKHook_HookClient(int iClient) SDKHook(iClient, SDKHook_OnTakeDamage, Client_OnTakeDamage); SDKHook(iClient, SDKHook_GetMaxHealth, Client_GetMaxHealth); SDKHook(iClient, SDKHook_WeaponSwitchPost, Client_WeaponSwitchPost); + + g_bLunchboxTouched[iClient] = false; } void SDKHook_UnhookClient(int iClient) @@ -320,18 +323,35 @@ public Action Pickup_SandvichTouch(int iEntity, int iToucher) if (iOwner == iToucher || g_nInfected[iToucher] == Infected_Tank) return Plugin_Handled; + //Don't stack lunchbox damages + if (g_bLunchboxTouched[iToucher]) + return Plugin_Handled; + if (IsSurvivor(iToucher)) { //Kill it and deal damage RemoveEntity(iEntity); DealDamage(iOwner, iToucher, 55.0); + g_bLunchboxTouched[iToucher] = true; + CreateTimer(2.0, Timer_ResetLunchboxTouched, GetClientUserId(iToucher)); + return Plugin_Handled; } return Plugin_Continue; } +public Action Timer_ResetLunchboxTouched(Handle hTimer, int iUserId) +{ + int iClient = GetClientOfUserId(iUserId); + if (iClient == 0) + return Plugin_Continue; + + g_bLunchboxTouched[iClient] = false; + return Plugin_Continue; +} + public Action Pickup_BananaTouch(int iEntity, int iToucher) { //Check if toucher is valid client @@ -342,6 +362,10 @@ public Action Pickup_BananaTouch(int iEntity, int iToucher) if (g_nInfected[iToucher] == Infected_Tank) return Plugin_Handled; + //Don't stack lunchbox damages + if (g_bLunchboxTouched[iToucher]) + return Plugin_Handled; + if (IsSurvivor(iToucher)) { int iOwner = GetEntPropEnt(iEntity, Prop_Send, "m_hOwnerEntity"); @@ -350,6 +374,9 @@ public Action Pickup_BananaTouch(int iEntity, int iToucher) RemoveEntity(iEntity); DealDamage(iOwner, iToucher, 30.0); + g_bLunchboxTouched[iToucher] = true; + CreateTimer(1.0, Timer_ResetLunchboxTouched, GetClientUserId(iToucher)); + return Plugin_Handled; }