Use GetCmdArgInt(Ex) in base plugins (#1203)

This commit is contained in:
Asher Baker 2020-03-04 22:07:00 +00:00 committed by GitHub
parent 17440fc4be
commit d59edc5d0a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 24 additions and 64 deletions

View File

@ -237,9 +237,7 @@ public Action Command_Blind(int client, int args)
int amount = 0; int amount = 0;
if (args > 1) if (args > 1)
{ {
char arg2[20]; if (!GetCmdArgIntEx(2, amount))
GetCmdArg(2, arg2, sizeof(arg2));
if (StringToIntEx(arg2, amount) == 0)
{ {
ReplyToCommand(client, "[SM] %t", "Invalid Amount"); ReplyToCommand(client, "[SM] %t", "Invalid Amount");
return Plugin_Handled; return Plugin_Handled;

View File

@ -492,15 +492,10 @@ public Action Command_Freeze(int client, int args)
int seconds = g_Cvar_FreezeDuration.IntValue; int seconds = g_Cvar_FreezeDuration.IntValue;
if (args > 1) if (args > 1 && !GetCmdArgIntEx(2, seconds))
{ {
char time[20]; ReplyToCommand(client, "[SM] %t", "Invalid Amount");
GetCmdArg(2, time, sizeof(time)); return Plugin_Handled;
if (StringToIntEx(time, seconds) == 0)
{
ReplyToCommand(client, "[SM] %t", "Invalid Amount");
return Plugin_Handled;
}
} }
char target_name[MAX_TARGET_LENGTH]; char target_name[MAX_TARGET_LENGTH];

View File

@ -609,15 +609,10 @@ public Action Command_AddGroup(int client, int args)
} }
int immunity; int immunity;
if (args >= 3) if (args >= 3 && !GetCmdArgIntEx(3, immunity))
{ {
char arg3[32]; ReplyToCommand(client, "[SM] %t", "Invalid immunity");
GetCmdArg(3, arg3, sizeof(arg3)); return Plugin_Handled;
if (!StringToIntEx(arg3, immunity))
{
ReplyToCommand(client, "[SM] %t", "Invalid immunity");
return Plugin_Handled;
}
} }
Database db = Connect(); Database db = Connect();
@ -772,15 +767,10 @@ public Action Command_AddAdmin(int client, int args)
} }
int immunity; int immunity;
if (args >= 5) if (args >= 5 && !GetCmdArgIntEx(5, immunity))
{ {
char arg5[32]; ReplyToCommand(client, "[SM] %t", "Invalid immunity");
GetCmdArg(5, arg5, sizeof(arg5)); return Plugin_Handled;
if (!StringToIntEx(arg5, immunity))
{
ReplyToCommand(client, "[SM] %t", "Invalid immunity");
return Plugin_Handled;
}
} }
char identity[65]; char identity[65];
@ -804,7 +794,7 @@ public Action Command_AddAdmin(int client, int args)
{ {
return DoError(client, db, query, "Admin retrieval query failed"); return DoError(client, db, query, "Admin retrieval query failed");
} }
if (rs.RowCount > 0) if (rs.RowCount > 0)
{ {
ReplyToCommand(client, "[SM] %t", "SQL Admin already exists"); ReplyToCommand(client, "[SM] %t", "SQL Admin already exists");

View File

@ -2,13 +2,6 @@
#include <cstrike> #include <cstrike>
#include <sdktools> #include <sdktools>
stock GET_ARG_INT( arg, maxSize=64 )
{
decl String:tempvar[maxSize];
GetCmdArg( arg, tempvar, maxSize );
return StringToInt( tempvar );
}
public OnPluginStart() public OnPluginStart()
{ {
RegConsoleCmd( "get_mvps", get_mvps ); RegConsoleCmd( "get_mvps", get_mvps );
@ -32,7 +25,7 @@ public Action:get_mvps( client, argc )
public Action:set_mvps( client, argc ) public Action:set_mvps( client, argc )
{ {
new count = GET_ARG_INT( 1 ); new count = GetCmdArgInt( 1 );
CS_SetMVPCount( client, count ); CS_SetMVPCount( client, count );
ReplyToCommand( client, "Set your MVP count to %d", count ); ReplyToCommand( client, "Set your MVP count to %d", count );
@ -61,7 +54,7 @@ public Action:set_score( client, argc )
return Plugin_Handled; return Plugin_Handled;
} }
new count = GET_ARG_INT( 1 ); new count = GetCmdArgInt( 1 );
CS_SetClientContributionScore( client, count ); CS_SetClientContributionScore( client, count );
ReplyToCommand( client, "Set your contribution score to %d", count ); ReplyToCommand( client, "Set your contribution score to %d", count );
@ -90,7 +83,7 @@ public Action:set_assists( client, argc )
return Plugin_Handled; return Plugin_Handled;
} }
new count = GET_ARG_INT( 1 ); new count = GetCmdArgInt( 1 );
CS_SetClientAssists( client, count ); CS_SetClientAssists( client, count );
ReplyToCommand( client, "Set your assist count to %d", 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 ) public Action:set_teamscore( client, argc )
{ {
new team = GET_ARG_INT( 1 ); new team = GetCmdArgInt( 1 );
new score = GET_ARG_INT( 2 ); new score = GetCmdArgInt( 2 );
if ( team != CS_TEAM_T && team != CS_TEAM_CT ) if ( team != CS_TEAM_T && team != CS_TEAM_CT )
{ {

View File

@ -127,8 +127,7 @@ public Action:sm_setammo(client, argc)
new max = GetEntPropArraySize(target, proptype, "m_iAmmo"); new max = GetEntPropArraySize(target, proptype, "m_iAmmo");
GetCmdArg(1, buffer, sizeof(buffer)); new ammotype = GetCmdArgInt(1);
new ammotype = StringToInt(buffer);
if (ammotype >= max) if (ammotype >= max)
{ {
@ -136,8 +135,7 @@ public Action:sm_setammo(client, argc)
return Plugin_Handled; return Plugin_Handled;
} }
GetCmdArg(2, buffer, sizeof(buffer)); new amount = GetCmdArgInt(2);
new amount = StringToInt(buffer);
SetEntProp(target, proptype, "m_iAmmo", amount, _, ammotype); SetEntProp(target, proptype, "m_iAmmo", amount, _, ammotype);

View File

@ -41,10 +41,7 @@ public Action:Command_Class(client, args)
public Action:Command_Remove(client, args) public Action:Command_Remove(client, args)
{ {
decl String:text[10]; new one = GetCmdArgInt(1);
GetCmdArg(1, text, sizeof(text));
new one = StringToInt(text);
TF2_RemoveWeaponSlot(client, one); TF2_RemoveWeaponSlot(client, one);
@ -64,10 +61,7 @@ public Action:Command_Remove(client, args)
public Action:Command_ChangeClass(client, args) public Action:Command_ChangeClass(client, args)
{ {
decl String:text[10]; new one = GetCmdArgInt(1);
GetCmdArg(1, text, sizeof(text));
new one = StringToInt(text);
PrintToChat(client, "Current class is :%i", TF2_GetPlayerClass(client)); PrintToChat(client, "Current class is :%i", TF2_GetPlayerClass(client));
@ -104,13 +98,8 @@ public Action:Command_Disguise(client, args)
return Plugin_Handled; return Plugin_Handled;
} }
decl String:text[10]; new one = GetCmdArgInt(1);
decl String:text2[10]; new two = GetCmdArgInt(2);
GetCmdArg(1, text, sizeof(text));
GetCmdArg(2, text2, sizeof(text2));
new one = StringToInt(text);
new two = StringToInt(text2);
TF2_DisguisePlayer(client, TFTeam:one, TFClassType:two); TF2_DisguisePlayer(client, TFTeam:one, TFClassType:two);
@ -201,10 +190,7 @@ public Action:Command_SetPowerPlay(client, args)
return Plugin_Handled; return Plugin_Handled;
} }
decl String:text[10]; new bool:one = GetCmdArgInt(1) != 0;
GetCmdArg(1, text, sizeof(text));
new bool:one = bool:StringToInt(text);
TF2_SetPlayerPowerPlay(client, one); TF2_SetPlayerPowerPlay(client, one);
@ -245,4 +231,4 @@ public Action:Command_Frighten(client, args)
TF2_StunPlayer(client, 5.0, _, TF_STUNFLAGS_GHOSTSCARE); TF2_StunPlayer(client, 5.0, _, TF_STUNFLAGS_GHOSTSCARE);
return Plugin_Handled; return Plugin_Handled;
} }