Raised This Month: $51 Target: $400
 12% 

Am I doing this right?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Xenos
New Member
Join Date: Jul 2007
Old 07-20-2007 , 14:52   Am I doing this right?
Reply With Quote #1

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:

Code:
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:

Code:
 sm_exec_ct "say hey"
Nothing happens to the CTs. The problem is probably something very simple. Any help would be appreciated. Thanks.
Xenos is offline
Hell Phoenix
Senior Member
Join Date: Jan 2005
Old 07-20-2007 , 15:16   Re: Am I doing this right?
Reply With Quote #2

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).
__________________
Hell Phoenix is offline
Xenos
New Member
Join Date: Jul 2007
Old 07-20-2007 , 17:18   Re: Am I doing this right?
Reply With Quote #3

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?
Xenos is offline
sumguy14
Senior Member
Join Date: Apr 2006
Old 07-21-2007 , 00:51   Re: Am I doing this right?
Reply With Quote #4

You can't execute ANYTHING now unless it is flagged that you can, there are only a few that work now.
__________________
Don't think of them as bugs think of them as unexpected features
sumguy14 is offline
BAILOPAN
Join Date: Jan 2004
Old 07-21-2007 , 21:57   Re: Am I doing this right?
Reply With Quote #5

Yes, use the findflags command in your console to see which are marked.
__________________
egg
BAILOPAN is offline
Reply



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 07:08.


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