From d59edc5d0a6df7dab84804b7b017d350ee7c3b9b Mon Sep 17 00:00:00 2001 From: Asher Baker Date: Wed, 4 Mar 2020 22:07:00 +0000 Subject: [PATCH] Use GetCmdArgInt(Ex) in base plugins (#1203) --- plugins/funcommands/blind.sp | 4 +--- plugins/funcommands/ice.sp | 11 +++-------- plugins/sql-admin-manager.sp | 24 +++++++----------------- plugins/testsuite/cstrike-test.sp | 17 +++++------------ plugins/testsuite/entpropelements.sp | 6 ++---- plugins/testsuite/tf2-test.sp | 26 ++++++-------------------- 6 files changed, 24 insertions(+), 64 deletions(-) diff --git a/plugins/funcommands/blind.sp b/plugins/funcommands/blind.sp index 29bcb480..a1bf2fb3 100644 --- a/plugins/funcommands/blind.sp +++ b/plugins/funcommands/blind.sp @@ -237,9 +237,7 @@ public Action Command_Blind(int client, int args) int amount = 0; if (args > 1) { - char arg2[20]; - GetCmdArg(2, arg2, sizeof(arg2)); - if (StringToIntEx(arg2, amount) == 0) + if (!GetCmdArgIntEx(2, amount)) { ReplyToCommand(client, "[SM] %t", "Invalid Amount"); return Plugin_Handled; diff --git a/plugins/funcommands/ice.sp b/plugins/funcommands/ice.sp index c5c0db98..3f045498 100644 --- a/plugins/funcommands/ice.sp +++ b/plugins/funcommands/ice.sp @@ -492,15 +492,10 @@ public Action Command_Freeze(int client, int args) int seconds = g_Cvar_FreezeDuration.IntValue; - if (args > 1) + if (args > 1 && !GetCmdArgIntEx(2, seconds)) { - char time[20]; - GetCmdArg(2, time, sizeof(time)); - if (StringToIntEx(time, seconds) == 0) - { - ReplyToCommand(client, "[SM] %t", "Invalid Amount"); - return Plugin_Handled; - } + ReplyToCommand(client, "[SM] %t", "Invalid Amount"); + return Plugin_Handled; } char target_name[MAX_TARGET_LENGTH]; diff --git a/plugins/sql-admin-manager.sp b/plugins/sql-admin-manager.sp index 9e354714..6433bba4 100644 --- a/plugins/sql-admin-manager.sp +++ b/plugins/sql-admin-manager.sp @@ -609,15 +609,10 @@ public Action Command_AddGroup(int client, int args) } int immunity; - if (args >= 3) + if (args >= 3 && !GetCmdArgIntEx(3, immunity)) { - char arg3[32]; - GetCmdArg(3, arg3, sizeof(arg3)); - if (!StringToIntEx(arg3, immunity)) - { - ReplyToCommand(client, "[SM] %t", "Invalid immunity"); - return Plugin_Handled; - } + ReplyToCommand(client, "[SM] %t", "Invalid immunity"); + return Plugin_Handled; } Database db = Connect(); @@ -772,15 +767,10 @@ public Action Command_AddAdmin(int client, int args) } int immunity; - if (args >= 5) + if (args >= 5 && !GetCmdArgIntEx(5, immunity)) { - char arg5[32]; - GetCmdArg(5, arg5, sizeof(arg5)); - if (!StringToIntEx(arg5, immunity)) - { - ReplyToCommand(client, "[SM] %t", "Invalid immunity"); - return Plugin_Handled; - } + ReplyToCommand(client, "[SM] %t", "Invalid immunity"); + return Plugin_Handled; } char identity[65]; @@ -804,7 +794,7 @@ public Action Command_AddAdmin(int client, int args) { return DoError(client, db, query, "Admin retrieval query failed"); } - + if (rs.RowCount > 0) { ReplyToCommand(client, "[SM] %t", "SQL Admin already exists"); diff --git a/plugins/testsuite/cstrike-test.sp b/plugins/testsuite/cstrike-test.sp index 19dd462e..cf4d0086 100644 --- a/plugins/testsuite/cstrike-test.sp +++ b/plugins/testsuite/cstrike-test.sp @@ -2,13 +2,6 @@ #include #include -stock GET_ARG_INT( arg, maxSize=64 ) -{ - decl String:tempvar[maxSize]; - GetCmdArg( arg, tempvar, maxSize ); - return StringToInt( tempvar ); -} - public OnPluginStart() { RegConsoleCmd( "get_mvps", get_mvps ); @@ -32,7 +25,7 @@ public Action:get_mvps( client, argc ) public Action:set_mvps( client, argc ) { - new count = GET_ARG_INT( 1 ); + new count = GetCmdArgInt( 1 ); CS_SetMVPCount( client, count ); ReplyToCommand( client, "Set your MVP count to %d", count ); @@ -61,7 +54,7 @@ public Action:set_score( client, argc ) return Plugin_Handled; } - new count = GET_ARG_INT( 1 ); + new count = GetCmdArgInt( 1 ); CS_SetClientContributionScore( client, count ); ReplyToCommand( client, "Set your contribution score to %d", count ); @@ -90,7 +83,7 @@ public Action:set_assists( client, argc ) return Plugin_Handled; } - new count = GET_ARG_INT( 1 ); + new count = GetCmdArgInt( 1 ); CS_SetClientAssists( client, count ); ReplyToCommand( client, "Set your assist count to %d", count ); @@ -131,8 +124,8 @@ public Action:get_teamscore( client, argc ) public Action:set_teamscore( client, argc ) { - new team = GET_ARG_INT( 1 ); - new score = GET_ARG_INT( 2 ); + new team = GetCmdArgInt( 1 ); + new score = GetCmdArgInt( 2 ); if ( team != CS_TEAM_T && team != CS_TEAM_CT ) { diff --git a/plugins/testsuite/entpropelements.sp b/plugins/testsuite/entpropelements.sp index 32355a12..3ec7cf26 100644 --- a/plugins/testsuite/entpropelements.sp +++ b/plugins/testsuite/entpropelements.sp @@ -127,8 +127,7 @@ public Action:sm_setammo(client, argc) new max = GetEntPropArraySize(target, proptype, "m_iAmmo"); - GetCmdArg(1, buffer, sizeof(buffer)); - new ammotype = StringToInt(buffer); + new ammotype = GetCmdArgInt(1); if (ammotype >= max) { @@ -136,8 +135,7 @@ public Action:sm_setammo(client, argc) return Plugin_Handled; } - GetCmdArg(2, buffer, sizeof(buffer)); - new amount = StringToInt(buffer); + new amount = GetCmdArgInt(2); SetEntProp(target, proptype, "m_iAmmo", amount, _, ammotype); diff --git a/plugins/testsuite/tf2-test.sp b/plugins/testsuite/tf2-test.sp index fe14eda9..c4023585 100644 --- a/plugins/testsuite/tf2-test.sp +++ b/plugins/testsuite/tf2-test.sp @@ -41,10 +41,7 @@ public Action:Command_Class(client, args) public Action:Command_Remove(client, args) { - decl String:text[10]; - GetCmdArg(1, text, sizeof(text)); - - new one = StringToInt(text); + new one = GetCmdArgInt(1); TF2_RemoveWeaponSlot(client, one); @@ -64,10 +61,7 @@ public Action:Command_Remove(client, args) public Action:Command_ChangeClass(client, args) { - decl String:text[10]; - GetCmdArg(1, text, sizeof(text)); - - new one = StringToInt(text); + new one = GetCmdArgInt(1); PrintToChat(client, "Current class is :%i", TF2_GetPlayerClass(client)); @@ -104,13 +98,8 @@ public Action:Command_Disguise(client, args) return Plugin_Handled; } - decl String:text[10]; - decl String:text2[10]; - GetCmdArg(1, text, sizeof(text)); - GetCmdArg(2, text2, sizeof(text2)); - - new one = StringToInt(text); - new two = StringToInt(text2); + new one = GetCmdArgInt(1); + new two = GetCmdArgInt(2); TF2_DisguisePlayer(client, TFTeam:one, TFClassType:two); @@ -201,10 +190,7 @@ public Action:Command_SetPowerPlay(client, args) return Plugin_Handled; } - decl String:text[10]; - GetCmdArg(1, text, sizeof(text)); - - new bool:one = bool:StringToInt(text); + new bool:one = GetCmdArgInt(1) != 0; TF2_SetPlayerPowerPlay(client, one); @@ -245,4 +231,4 @@ public Action:Command_Frighten(client, args) TF2_StunPlayer(client, 5.0, _, TF_STUNFLAGS_GHOSTSCARE); return Plugin_Handled; -} \ No newline at end of file +}