Raised This Month: $ Target: $400
 0% 

How to send custom message to all players?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
alter
Member
Join Date: Jan 2013
Location: Lithuainia
Old 06-06-2013 , 11:25   How to send custom message to all players?
Reply With Quote #1

How to send custom message to all players? (Need right loop, because i want to check each player)
__________________
Class: Programmer Level: Medium
alter is offline
TheDS1337
Veteran Member
Join Date: Jun 2012
Old 06-06-2013 , 11:27   Re: How to send custom message to all players?
Reply With Quote #2

Code:
for( new i = 1; i <= get_maxplayers(); i++ ) {         // Here your function, replace client index with i }
or replace client index with 0

Last edited by TheDS1337; 06-06-2013 at 11:40.
TheDS1337 is offline
mottzi
Veteran Member
Join Date: May 2010
Location: Switzerland
Old 06-06-2013 , 11:52   Re: How to send custom message to all players?
Reply With Quote #3

Quote:
Originally Posted by DeagLe.Studio View Post
Code:
for( new i = 1; i <= get_maxplayers(); i++ ) {         // Here your function, replace client index with i }
or replace client index with 0
I saw it from you many times now....
Please post only good and efficient codes.

You know that get_maxplayers() is called as many times as the loop does get executet right?
mottzi is offline
Send a message via MSN to mottzi
wickedd
Veteran Member
Join Date: Nov 2009
Old 06-06-2013 , 11:38   Re: How to send custom message to all players?
Reply With Quote #4

get_players
__________________
Just buy the fucking game!!!!
I hate No-Steamers and lazy ass people.
wickedd is offline
alter
Member
Join Date: Jan 2013
Location: Lithuainia
Old 06-06-2013 , 12:08   Re: How to send custom message to all players?
Reply With Quote #5

Can you give me right code mottzi?
__________________
Class: Programmer Level: Medium
alter is offline
wickedd
Veteran Member
Join Date: Nov 2009
Old 06-06-2013 , 12:20   Re: How to send custom message to all players?
Reply With Quote #6

I gave you what you need. With get_players() you can send a message to anyone in the server. Read this.
__________________
Just buy the fucking game!!!!
I hate No-Steamers and lazy ass people.
wickedd is offline
MPD
Member
Join Date: May 2013
Location: Lithuania
Old 06-06-2013 , 12:24   Re: How to send custom message to all players?
Reply With Quote #7

I guess this is it:
PHP Code:
new pnumpIDplayers[32];
get_players(playerspnum"c");
for (new 
i=0i<pnumi++) {
    
pID=players[i];        // This is player ID
    //All messaging goes here. exaple.
    
client_print(pIDprint_center"This is a message");

Am I right?

Last edited by MPD; 06-06-2013 at 12:24.
MPD is offline
Send a message via Skype™ to MPD
TheDS1337
Veteran Member
Join Date: Jun 2012
Old 06-06-2013 , 12:37   Re: How to send custom message to all players?
Reply With Quote #8

Quote:
Originally Posted by MPD View Post
I guess this is it:
PHP Code:
new pnumpIDplayers[32];
get_players(playerspnum"c");
for (new 
i=0i<pnumi++) {
    
pID=players[i];        // This is player ID
    //All messaging goes here. exaple.
    
client_print(pIDprint_center"This is a message");

Am I right?
All of them uses loop, better to use get_maxplayers(), it's returns gpGlobals->maxClients
TheDS1337 is offline
YamiKaitou
Has a lovely bunch of coconuts
Join Date: Apr 2006
Location: Texas
Old 06-06-2013 , 14:32   Re: How to send custom message to all players?
Reply With Quote #9

Quote:
Originally Posted by DeagLe.Studio View Post
All of them uses loop, better to use get_maxplayers(), it's returns gpGlobals->maxClients
No. The best way is to use get_players
__________________
ProjectYami Laboratories

I do not browse the forums regularly anymore. If you need me for anything (asking questions or anything else), then PM me (be descriptive in your PM, message containing only a link to a thread will be ignored).
YamiKaitou is offline
Clauu
Senior Member
Join Date: Feb 2008
Location: RO
Old 06-06-2013 , 12:44   Re: How to send custom message to all players?
Reply With Quote #10

Actually the correct way of looping throw all players is the one posted by mpd with the "h" flag also and before doing any action player id must be validated first. Or you can use 0 for the id and will be sent to all players.

Last edited by Clauu; 06-06-2013 at 12:46.
Clauu 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 16:22.


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