Hi all, so I made this plugin that strips people's weapons and it works fine if I target 1 person but if I want to target in bulk like for example @all or @!me it replies with [SM] Targets not found. I tried to mimic the same method used in kick.sp but I cannot make it work. I'm new to sourcepawn so any help is appreciated.
This is the code when I tried to mimic what was done in kick.sp
PHP Code:
RegAdminCmd("sm_raw", WeaponsRed, ADMFLAG_KICK, "sm_raw <#userid|name>");
public Action WeaponsRed(int client, int args)
{
if (args < 1)
{
ReplyToCommand(client, "[SM] Usage: sm_raw <#userid|name>");
return Plugin_Handled;
}
char arg1[32];
char arg[65];
char target_name[MAX_TARGET_LENGTH];
int target_list[MAXPLAYERS], target_count;
bool tn_is_ml;
GetCmdArg(1, arg1, sizeof(arg1));
int target = FindTarget(client, arg1);
if (target == -1)
{
return Plugin_Handled;
}
if ((target_count = ProcessTargetString(
arg,
client,
target_list,
MAXPLAYERS,
COMMAND_FILTER_CONNECTED,
target_name,
sizeof(target_name),
tn_is_ml)) > 0)
{
if (tn_is_ml)
{
StripWeapons(target_count);
if(red_hooked)
{
Red_UnhookEvents();
}
else
{
Red_HookEvents();
}
return Plugin_Handled;
}
}
StripWeapons(target);
if(red_hooked)
{
Red_UnhookEvents();
}
else
{
Red_HookEvents();
}
return Plugin_Handled;
}
and this is the original code which is less messier
PHP Code:
RegAdminCmd("sm_raw", WeaponsRed, ADMFLAG_KICK, "sm_raw <#userid|name>");
public Action WeaponsRed(int client, int args)
{
if (args < 1)
{
ReplyToCommand(client, "[SM] Usage: sm_raw <#userid|name>");
return Plugin_Handled;
}
char arg1[32];
GetCmdArg(1, arg1, sizeof(arg1));
int target = FindTarget(client, arg1);
if (target == -1)
{
return Plugin_Handled;
}
StripWeapons(target);
if(red_hooked)
{
Red_UnhookEvents();
}
else
{
Red_HookEvents();
}
return Plugin_Handled;
}