SendClientMessage to everyone with value of 1 -
Lz - 15.12.2012
pawn Код:
SendClientMessage(PlayerInfo[pAdmin] ==1, 0xC4C4C4FF, string);
How would i do this? So it only sends the string to who ever has value of 1 in the [pAdmin]
Re: SendClientMessage to everyone with value of 1 -
ReneG - 15.12.2012
using
foreach
pawn Код:
foreach(Player, i)
{
if(PlayerInfo[i][pAdmin]) {
SendClientMessage(i, 0xC4C4C4FF, string);
}
}
Re: SendClientMessage to everyone with value of 1 -
zDevon - 15.12.2012
Or, if you don't have foreach installed (which I would recommend that you do);
pawn Код:
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(PlayerInfo[i][pAdmin]) {
SendClientMessage(i, 0xC4C4C4FF, string);
}
}
Re: SendClientMessage to everyone with value of 1 -
Face9000 - 15.12.2012
Quote:
Originally Posted by zDevon
Or, if you don't have foreach installed (which I would recommend that you do);
pawn Код:
for(new i = 0; i < MAX_PLAYERS; i++) { if(PlayerInfo[i][pAdmin]) { SendClientMessage(i, 0xC4C4C4FF, string); } }
|
Simple:
pawn Код:
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(PlayerInfo[i][pAdmin]) return SendClientMessage(i, 0xC4C4C4FF, string);
}
But why you should use SendClientMessage in a loop? If you want send a message to ALL players, there is SendClientMessageToAll.
Re: SendClientMessage to everyone with value of 1 -
PlayLSX_Founder - 15.12.2012
Quote:
Originally Posted by Logitech90
Simple:
pawn Код:
for(new i = 0; i < MAX_PLAYERS; i++) { if(PlayerInfo[i][pAdmin]) return SendClientMessage(i, 0xC4C4C4FF, string); }
But why you should use SendClientMessage in a loop? If you want send a message to ALL players, there is SendClientMessageToAll.
|
Because he asked how to send to specific players. SendClientMessageToAll will do exactly what it says, there's no way to use it to target specific players.
Re: SendClientMessage to everyone with value of 1 -
Face9000 - 15.12.2012
Quote:
Originally Posted by PlayLSX_Founder
Because he asked how to send to specific players. SendClientMessageToAll will do exactly what it says, there's no way to use it to target specific players.
|
Yes i know, was just giving him a tip.
Re: SendClientMessage to everyone with value of 1 -
maramizo - 15.12.2012
Quote:
Originally Posted by Logitech90
Simple:
pawn Код:
for(new i = 0; i < MAX_PLAYERS; i++) { if(PlayerInfo[i][pAdmin]) return SendClientMessage(i, 0xC4C4C4FF, string); }
|
Wrong! Obviously not simple as you state, should be:
pawn Код:
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(PlayerInfo[i][pAdmin]) SendClientMessage(i, 0xC4C4C4FF, string);
}
Otherwise it would only send to the first admin it finds, based on the online player ID's which is considered random.
Re: SendClientMessage to everyone with value of 1 -
Djole1337 - 16.12.2012
Delete, ****** was right.
Re: SendClientMessage to everyone with value of 1 -
PlayLSX_Founder - 17.12.2012
Quote:
Originally Posted by ******
You mean like the first several replies already said?
|
People will never change on forums, no matter how many people post the correct answer, people on the topic will air their opinion, regardless. It's something that has always confused me, bar people posting at the same time that is.