PDA

View Full Version : Am I doing this right?


Xenos
07-20-2007, 14:52
I'm writing a plugin that executes client commands, but I'm still new to SourcePawn. I wrote segments of code for executing commands on individual players, a team, or everyone, but I'm having trouble with pretty much every part except for executing commands on individual players. That's the only one I got right. This code executes a client command on the CT team in Counter-Strike: Source:

public Action:Command_Exec_CT(client, args) // Executes on CTs
{
if (args != 1) // Must have one argument, otherwise won't work
{
ReplyToCommand(client, "[SM] Syntax: sm_exec_ct <command>")
return Plugin_Handled
}

new String:TheCommand[64] // String to hold command, first argument
GetCmdArg(1, TheCommand, sizeof(TheCommand)) // Get argument

/**
* This loop goes through each of the players, and determines if that
* player is a CT. If so, execute the client command. If not, move on.
* NumPlayers is equal to GetMaxClients(), and index is the player index
*/
for(new index=1; index<=NumPlayers; index++)
{
if (!IsClientConnected(index))
{
continue
}

if (IsFakeClient(index))
{
continue
}

if (GetClientTeam(index) == 3) // 3 is for CT
{
FakeClientCommand(index, TheCommand) // Execute
}
}

return Plugin_Handled // Finish executing
}

The problem with this code is that when I type this:

sm_exec_ct "say hey"
Nothing happens to the CTs. The problem is probably something very simple. Any help would be appreciated. Thanks.

Hell Phoenix
07-20-2007, 15:16
You cant exec clientcommands for most things. There is only like 4. The ones I know of are name and play (so you can change their name and so you can play a sound).

Xenos
07-20-2007, 17:18
That came with the last steam update, right? Valve took out cl_restrict_server_commands and cl_restrict_client_commands (I don't know which). Isn't there some workaround to execute client commands, or does this mean I can't continue on the plugin?

sumguy14
07-21-2007, 00:51
You can't execute ANYTHING now unless it is flagged that you can, there are only a few that work now.

BAILOPAN
07-21-2007, 21:57
Yes, use the findflags command in your console to see which are marked.