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

How do I execute a command on all players?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ronmelkhior
Member
Join Date: Aug 2013
Old 09-07-2013 , 13:22   How do I execute a command on all players?
Reply With Quote #1

I want to execute a voice command on all players, but when I do this:

Code:
FakeClientCommand(_:TFTeam_Red, "voicemenu 1 4");
FakeClientCommand(_:TFTeam_Blue, "voicemenu 1 4");
It only does it to one player of each team. How can I fix that?
ronmelkhior is offline
thetwistedpanda
Good Little Panda
Join Date: Sep 2008
Old 09-07-2013 , 14:01   Re: How do I execute a command on all players?
Reply With Quote #2

PHP Code:
for(new 1<= MaxClientsi++)
{
  if(!
IsClientInGame(i))
    continue;

  
//Do code per client here. i == client.

__________________

Last edited by thetwistedpanda; 09-07-2013 at 14:01.
thetwistedpanda is offline
friagram
Veteran Member
Join Date: Sep 2012
Location: Silicon Valley
Old 09-07-2013 , 14:01   Re: How do I execute a command on all players?
Reply With Quote #3

You use their client index.. Not the team num.

Loop over the inhame clients

for(new i=1; i<=MaxClients;i++)
{
if(IsClientInGame(i))
{
do stuff
}
}
__________________
Profile - Plugins
Add me on steam if you are seeking sp/map/model commissions.
friagram is offline
ronmelkhior
Member
Join Date: Aug 2013
Old 09-07-2013 , 14:36   Re: How do I execute a command on all players?
Reply With Quote #4

Thanks to you both! It worked!
ronmelkhior is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 09-07-2013 , 14:47   Re: How do I execute a command on all players?
Reply With Quote #5

Don't forget to use !IsFakeClient or else you'll get errors when it hits a bot, SourceTV, or replay.
__________________
Not currently working on SourceMod plugin development.
Powerlord is offline
friagram
Veteran Member
Join Date: Sep 2012
Location: Silicon Valley
Old 09-08-2013 , 01:09   Re: How do I execute a command on all players?
Reply With Quote #6

Fakeclientcommand works just fine on fakeclients.
__________________
Profile - Plugins
Add me on steam if you are seeking sp/map/model commissions.
friagram is offline
Reply


Thread Tools
Display Modes

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 20:36.


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