AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   How to send custom message to all players? (https://forums.alliedmods.net/showthread.php?t=217712)

alter 06-06-2013 11:25

How to send custom message to all players?
 
How to send custom message to all players? (Need right loop, because i want to check each player)

TheDS1337 06-06-2013 11:27

Re: How to send custom message to all players?
 
Code:
for( new i = 1; i <= get_maxplayers(); i++ ) {         // Here your function, replace client index with i }
or replace client index with 0

wickedd 06-06-2013 11:38

Re: How to send custom message to all players?
 
get_players

mottzi 06-06-2013 11:52

Re: How to send custom message to all players?
 
Quote:

Originally Posted by DeagLe.Studio (Post 1965658)
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?

alter 06-06-2013 12:08

Re: How to send custom message to all players?
 
Can you give me right code mottzi?

wickedd 06-06-2013 12:20

Re: How to send custom message to all players?
 
I gave you what you need. With get_players() you can send a message to anyone in the server. Read this.

MPD 06-06-2013 12:24

Re: How to send custom message to all players?
 
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?

TheDS1337 06-06-2013 12:37

Re: How to send custom message to all players?
 
Quote:

Originally Posted by MPD (Post 1965683)
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

Clauu 06-06-2013 12:44

Re: How to send custom message to all players?
 
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.

alter 06-06-2013 12:57

Re: How to send custom message to all players?
 
Thank you.


All times are GMT -4. The time now is 16:22.

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