SendClientMessage to everyone with value of 1
#1

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]
Reply
#2

using foreach
pawn Код:
foreach(Player, i)
{
    if(PlayerInfo[i][pAdmin]) {
        SendClientMessage(i, 0xC4C4C4FF, string);
    }
}
Reply
#3

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);
    }
}
Reply
#4

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.
Reply
#5

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.
Reply
#6

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.
Reply
#7

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.
Reply
#8

Delete, ****** was right.
Reply
#9

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.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)