From 17a8e7f56e9dcf95f656205190f3c9bd046a54e2 Mon Sep 17 00:00:00 2001 From: Vincent HERBET Date: Tue, 25 Jun 2013 11:45:00 +0200 Subject: [PATCH] Fix user_slap/amx_slap unexpected behavior using large negative damage (bug 4975, r=joropito) Former-commit-id: 1e4d0e216eef3d556c68eeca7362562c663e2dd1 --- amxmodx/amxmodx.cpp | 8 ++++++-- plugins/admincmd.sma | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/amxmodx/amxmodx.cpp b/amxmodx/amxmodx.cpp index 06b6f6a4..814285bc 100755 --- a/amxmodx/amxmodx.cpp +++ b/amxmodx/amxmodx.cpp @@ -1540,8 +1540,12 @@ static cell AMX_NATIVE_CALL user_slap(AMX *amx, cell *params) /* 2 param */ if (index < 1 || index > gpGlobals->maxClients) return 0; - - int power = abs((int)params[2]); + + int power = (int)params[2]; + + if (power < 0) + power = 0; + CPlayer* pPlayer = GET_PLAYER_POINTER_I(index); if (pPlayer->ingame && pPlayer->IsAlive()) diff --git a/plugins/admincmd.sma b/plugins/admincmd.sma index 1a9253dc..6a3428fd 100755 --- a/plugins/admincmd.sma +++ b/plugins/admincmd.sma @@ -605,7 +605,7 @@ public cmdSlap(id, level, cid) read_argv(2, spower, 31) - new damage = str_to_num(spower) + new damage = clamp( str_to_num(spower), 0) user_slap(player, damage)