Skip to content

Commit

Permalink
More efficient way to check for negative time
Browse files Browse the repository at this point in the history
  • Loading branch information
sunstep committed Mar 13, 2024
1 parent 82113a8 commit 1b481ad
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions game/addons/sourcemod/scripting/sbpp_main.sp
Original file line number Diff line number Diff line change
Expand Up @@ -545,12 +545,11 @@ public Action CommandBanIp(int client, int args)
}

char adminIp[24], adminAuth[64];
int minutes;

int minutes = StringToInt(time);

if (minutes < 0)
if (!StringToIntEx(time, minutes) || minutes < 0)
{
ReplyToCommand(client, "%sInvalid duration. Duration must be 0 or higher", Prefix);
ReplyToCommand(client, "%sUsage: sm_banip <#userid|name> <time> [reason]", Prefix);
return Plugin_Handled;
}

Expand Down Expand Up @@ -662,7 +661,7 @@ public Action CommandAddBan(int client, int args)

GetCmdArgString(arg_string, sizeof(arg_string));

int len, total_len;
int len, total_len, minutes;

/* Get time */
if ((len = BreakString(arg_string, time, sizeof(time))) == -1)
Expand All @@ -685,11 +684,9 @@ public Action CommandAddBan(int client, int args)

char adminIp[24], adminAuth[64];

int minutes = StringToInt(time);

if (minutes < 0)
if (!StringToIntEx(time, minutes) || minutes < 0)
{
ReplyToCommand(client, "%sInvalid duration. Duration must be 0 or higher", Prefix);
ReplyToCommand(client, "%sUsage: sm_addban <time> <steamid> [reason]", Prefix);
return Plugin_Handled;
}

Expand Down

0 comments on commit 1b481ad

Please sign in to comment.