Hi all,
What would be the best way to execute a command on dead players but not execute on spectators?
The following will not execute if a client is in spectate and an admin uses sm_respawn @all. If I remove the code relating to spectate then the plugin works, but if an admin executes on a single client in spectate it says that they were respawned (they weren't actually respawned, plugin just reports in chat that they were)
Code:
public Action:Command_Respawn(client, args)
{
if (args < 1)
{
ReplyToCommand(client, "[SM] Usage: sm_respawn <#userid|name>");
return Plugin_Handled;
}
decl String:arg[65];
GetCmdArg(1, arg, sizeof(arg));
decl String:target_name[MAX_TARGET_LENGTH];
decl target_list[MAXPLAYERS], target_count, bool:tn_is_ml;
if ((target_count = ProcessTargetString(
arg,
client,
target_list,
MAXPLAYERS,
COMMAND_FILTER_DEAD,
target_name,
sizeof(target_name),
tn_is_ml)) <= 0)
{
ReplyToTargetError(client, target_count);
return Plugin_Handled;
}
for (new i = 0; i < target_count; i++)
{
new team = GetClientTeam(target_list[i]);
if (team == TEAM_1 || team == TEAM_2)
RespawnPlayer(client, target_list[i]);
if (team == SPECTATOR_TEAM || team == TEAM_SPEC)
{
PrintToChat(client, "[SM] %t", "Client not on active team");
return Plugin_Handled;
}
}
if (tn_is_ml)
{
ShowActivity2(client, "[SM] ", "%t", "Toggled respawn on target", target_name);
}
else
{
ShowActivity2(client, "[SM] ", "%t", "Toggled respawn on target", "_s", target_name);
}
return Plugin_Handled;
}
How can I allow the use of @all but not have it execute on spectators?
__________________