Raised This Month: $ Target: $400
 0% 

Execute on Dead Players But Not Spectate


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
bobbobagan
SourceMod Donor
Join Date: May 2007
Location: New Zealand
Old 03-24-2014 , 05:15   Execute on Dead Players But Not Spectate
Reply With Quote #1

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?
__________________
bobbobagan is offline
Send a message via Skype™ to bobbobagan
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 10:20.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode