diff --git a/valve/addons/amxmodx/scripting/agmodx.sma b/valve/addons/amxmodx/scripting/agmodx.sma index af5db51..33596d0 100644 --- a/valve/addons/amxmodx/scripting/agmodx.sma +++ b/valve/addons/amxmodx/scripting/agmodx.sma @@ -1837,7 +1837,7 @@ public OnVoteMaxSpeed(id, check, argc, arg1[], arg2[]) { return false; } - if (!is_str_num(arg2)) { + if (!is_str_num_ex(arg2)) { console_print(id, "%l", "INVALID_NUMBER"); return false; } @@ -1899,7 +1899,7 @@ public OnVoteTimeLimit(id, check, argc, arg1[], arg2[]) { return false; } - if (!is_str_num(arg2)) { + if (!is_str_num_ex(arg2)) { console_print(id, "%l", "INVALID_NUMBER"); return false; } @@ -2046,7 +2046,7 @@ public OnVoteFragLimit(id, check, argc, arg1[], arg2[]) { return false; } - if (!is_str_num(arg2)) { + if (!is_str_num_ex(arg2)) { console_print(id, "%l", "INVALID_NUMBER"); return false; } @@ -2087,7 +2087,7 @@ public OnVoteSelfGauss(id, check, argc, arg1[], arg2[]) { return false; } - if (!is_str_num(arg2)) { + if (!is_str_num_ex(arg2)) { console_print(id, "%l", "INVALID_NUMBER"); return false; } diff --git a/valve/addons/amxmodx/scripting/include/agmodx_stocks.inc b/valve/addons/amxmodx/scripting/include/agmodx_stocks.inc index 9d14b3f..1fdbd7c 100644 --- a/valve/addons/amxmodx/scripting/include/agmodx_stocks.inc +++ b/valve/addons/amxmodx/scripting/include/agmodx_stocks.inc @@ -290,3 +290,20 @@ stock get_skill_cvar_num(const name[]) { get_skill_cvar_string(name, value, charsmax(value)); return str_to_num(value); } + +// Alternative to is_str_num which supports both positive and negative numbers. +stock bool:is_str_num_ex(const sString[]) { + new i = 0; + new bool:is_negative = false; + + if (sString[0] == '-') { + is_negative = true; + i++; + } + + while (sString[i] && isdigit(sString[i])) { + i++; + } + + return sString[i] == 0 && i != (is_negative ? 1 : 0); +}