AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   How do I execute a command on all players? (https://forums.alliedmods.net/showthread.php?t=225659)

ronmelkhior 09-07-2013 13:22

How do I execute a command on all players?
 
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?

thetwistedpanda 09-07-2013 14:01

Re: How do I execute a command on all players?
 
PHP Code:

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

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



friagram 09-07-2013 14:01

Re: How do I execute a command on all players?
 
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
}
}

ronmelkhior 09-07-2013 14:36

Re: How do I execute a command on all players?
 
Thanks to you both! It worked!

Powerlord 09-07-2013 14:47

Re: How do I execute a command on all players?
 
Don't forget to use !IsFakeClient or else you'll get errors when it hits a bot, SourceTV, or replay.

friagram 09-08-2013 01:09

Re: How do I execute a command on all players?
 
Fakeclientcommand works just fine on fakeclients.


All times are GMT -4. The time now is 05:33.

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