Skip to content
Permalink
Browse files

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

  • Loading branch information
asherkin committed Mar 4, 2020
1 parent 17440fc commit d59edc5d0a6df7dab84804b7b017d350ee7c3b9b
@@ -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;
@@ -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];
@@ -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");
@@ -2,13 +2,6 @@
#include <cstrike>
#include <sdktools>

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 )
{
@@ -127,17 +127,15 @@ 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)
{
ReplyToCommand(client, "Ammotype out of bounds");
return Plugin_Handled;
}

GetCmdArg(2, buffer, sizeof(buffer));
new amount = StringToInt(buffer);
new amount = GetCmdArgInt(2);

SetEntProp(target, proptype, "m_iAmmo", amount, _, ammotype);

@@ -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;
}
}

0 comments on commit d59edc5

Please sign in to comment.
You can’t perform that action at this time.