Krenair

SourcePunish check time is numeric patch

Nov 17th, 2013
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 2.78 KB | None | 0 0
  1. diff --git a/scripting/sourceirc-sourcepunish.sp b/scripting/sourceirc-sourcepunish.sp
  2. index e5a47f2..db8523e 100644
  3. --- a/scripting/sourceirc-sourcepunish.sp
  4. +++ b/scripting/sourceirc-sourcepunish.sp
  5. @@ -85,6 +85,15 @@ public PunishmentPluginUnloaded() {
  6.         ProcessRegisteredPunishments();
  7.  }
  8.  
  9. +stock IsStringNumeric(const String:StringToCheck[]) {
  10. +       for (new i = 0; i < strlen(StringToCheck); i++) {
  11. +               if (!IsCharNumeric(StringToCheck[i])) {
  12. +                       return false;
  13. +               }
  14. +       }
  15. +       return true;
  16. +}
  17. +
  18.  public Action:IRCCommand_Punish(String:nick[], args) {
  19.         decl String:command[70], String:twoChars[3], String:threeChars[4];
  20.         IRC_GetCmdArg(0, command, sizeof(command));
  21. @@ -149,6 +158,10 @@ public Action:IRCCommand_Punish(String:nick[], args) {
  22.                         new posAfterTime = -1;
  23.                         if (reasonArgumentNum == 3 && pos != -1) {
  24.                                 posAfterTime = BreakString(fullArgString[pos], time, sizeof(time));
  25. +                               if (!IsStringNumeric(time)) {
  26. +                                       IRC_ReplyToCommand(nick, "Given time must be numeric.");
  27. +                                       return Plugin_Handled;
  28. +                               }
  29.                         } else {
  30.                                 strcopy(time, sizeof(time), "0");
  31.                         }
  32. diff --git a/scripting/sourcepunish.sp b/scripting/sourcepunish.sp
  33. index 4fc8595..b3f9dba 100644
  34. --- a/scripting/sourcepunish.sp
  35. +++ b/scripting/sourcepunish.sp
  36. @@ -215,6 +215,15 @@ public ActivePunishmentsLookupComplete(Handle:owner, Handle:query, const String:
  37.         }
  38.  }
  39.  
  40. +stock IsStringNumeric(const String:StringToCheck[]) {
  41. +        for (new i = 0; i < strlen(StringToCheck); i++) {
  42. +                if (!IsCharNumeric(StringToCheck[i])) {
  43. +                        return false;
  44. +                }
  45. +        }
  46. +        return true;
  47. +}
  48. +
  49.  public Action:Command_Punish(client, args) {
  50.         decl String:command[70], String:twoChars[3], String:threeChars[4];
  51.         GetCmdArg(0, command, sizeof(command));
  52. @@ -280,6 +289,10 @@ public Action:Command_Punish(client, args) {
  53.                         new posAfterTime = -1;
  54.                         if (reasonArgumentNum == 3 && pos != -1) {
  55.                                 posAfterTime = BreakString(fullArgString[pos], time, sizeof(time));
  56. +                               if (!IsStringNumeric(time)) {
  57. +                                       ReplyToCommand(client, "Given time must be numeric.");
  58. +                                       return Plugin_Handled;
  59. +                               }
  60.                         } else {
  61.                                 strcopy(time, sizeof(time), "0");
  62.                         }
Advertisement
Add Comment
Please, Sign In to add comment