Raised This Month: $32 Target: $400
 8% 

How to [action here] to every player?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Mr.D
Junior Member
Join Date: Jun 2017
Old 06-19-2017 , 09:15   How to [action here] to every player?
Reply With Quote #1

Hi!

How to perform a certain action (for example, play a sound) to everyone on the server? I tried to look at "sm_play" example but it's not exactly what I need. It uses command's arguments for targets, but I don't want to target specific players in command's arguments. I want a sound to play for everyone on the server, without specifying target's name. Just to everyone. How would I do that in a script?

P.S.
With text it's not a problem, just "PrintToChatAll" and everyone will see that without specifying each person as an argument.

Edit:
More info on what exactly I'm looking for.
I want to show a notification in chat (done) and then play a sound to everyone on the server as soon as that message shows up. How to play a sound to everyone on the server? NOTICE: the plugin shows that notification alone, I don't use a command for it like "/notification Person1, Person2, Person3". So I don't target specific people. It shows to everyone and the sound needs to be played to everyone too.

Last edited by Mr.D; 06-19-2017 at 09:48.
Mr.D is offline
Miu
Veteran Member
Join Date: Nov 2013
Old 06-19-2017 , 09:57   Re: How to [action here] to every player?
Reply With Quote #2

"sm_play @all" should do that.

otherwise you'd want to loop over all the client indices, like

Code:
for (int i = 1; i <= MaxClients; ++i)
{
	if (!IsClientInGame(i))
		continue;
	
	ServerCommand("sm_play %N", i);
}
Miu is offline
Mr.D
Junior Member
Join Date: Jun 2017
Old 06-19-2017 , 12:03   Re: How to [action here] to every player?
Reply With Quote #3

Quote:
Originally Posted by Miu View Post
"sm_play @all" should do that.

otherwise you'd want to loop over all the client indices, like

Code:
for (int i = 1; i <= MaxClients; ++i)
{
	if (!IsClientInGame(i))
		continue;
	
	ServerCommand("sm_play %N", i);
}
Yes, "sm_play @all" works when I type this command on my server. But will this work from a script? Anyway, I'll try both ways later and let you know. Thanks.


Edit:
Both ways work great. Thank you very much.

Last edited by Mr.D; 06-19-2017 at 13:23.
Mr.D is offline
WildCard65
Veteran Member
Join Date: Aug 2013
Location: Canada
Old 06-19-2017 , 20:14   Re: How to [action here] to every player?
Reply With Quote #4

Quote:
Originally Posted by Miu View Post
"sm_play @all" should do that.

otherwise you'd want to loop over all the client indices, like

Code:
for (int i = 1; i <= MaxClients; ++i)
{
	if (!IsClientInGame(i))
		continue;
	
	ServerCommand("sm_play %N", i);
}
You do remember it's extremely unsafe to pass a client's name to ServerCommand correct?
__________________
WildCard65 is offline
Chaosxk
Veteran Member
Join Date: Aug 2010
Location: Westeros
Old 06-19-2017 , 22:10   Re: How to [action here] to every player?
Reply With Quote #5

Changes name to ";exit" ... server shut down.
__________________
Chaosxk is offline
Miu
Veteran Member
Join Date: Nov 2013
Old 06-19-2017 , 22:28   Re: How to [action here] to every player?
Reply With Quote #6

oh yeahhh i was thinking there was something wrong with that as i was writing it but couldn't remember what. good catch!
Miu is offline
Mr.D
Junior Member
Join Date: Jun 2017
Old 06-20-2017 , 02:10   Re: How to [action here] to every player?
Reply With Quote #7

I'm aware of things like that and in my case it's not a problem because it's a VIP plugin which is used by very trusted people only and on my server only They don't even know things like that to be able to do those tricks But good note anyway.

P.S.
I used "sm_play @all" way though.
Mr.D 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 23:15.


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