if(IsAdminConnected)
#1

Im using SendClientMessageToAdmins Strock,

So how I can make a strock which check if the player (ADMIN) is connected)

im using SendClientMessageToAdmins
Reply
#2

The only way i cn think of doing this is by doing
pawn Код:
if(IsPlayerConnected)
{
          if(IsPlayerAdmin)
          {
                  SendClientMessageToAdmins....
          }
}
Because there is no actual fuction to do that


EDIT: Sorry i didnt think you ment that sorry fot the n00b post
Reply
#3

I think thats wrong
It'll be:

If the player is connected & is rcon send the message to him.....
Reply
#4

pawn Код:
forward SendClientMessageToAdmins(color,const string[]);
public SendClientMessageToAdmins(color,const string[])
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i) == 1)
        {
            if(PlayerInfo[i][Level] >= 1 || IsPlayerAdmin(i))
            {
                SendClientMessage(i, COLOR_HERE, string);
            }
        }
    }
    return 1;
}
Change PlayerInfo to yours, like Info, pInfo, etc... Unless you don't have one, then just delete it and make the line

if(IsPlayerAdmin(i))

Then when you want a message to be sent to admins, use SendClientMessageToAdmins(color,string);
Reply
#5

Can it be this:

pawn Код:
stock AdminConnected(playerid)
{
    for(new a, g = GetMaxPlayers(); a < g; a++)
        if(IsPlayerConnected(a) && IsPlayerAdmin(a))
}
Reply
#6

Quote:
Originally Posted by Alex_Obando
Посмотреть сообщение
Can it be this:

pawn Код:
stock AdminConnected(playerid)
{
    for(new a, g = GetMaxPlayers(); a < g; a++)
        if(IsPlayerConnected(a) && IsPlayerAdmin(a))
}
Yes but you haven't returned a value or done anything so how are you supposed to know?

Simply edit the function to return a value as expected, for example:

pawn Код:
stock AdminConnected()
{
    for(new a, g = GetMaxPlayers(); a < g; a++)
        if(IsPlayerConnected(a) && IsPlayerAdmin(a)) return 1;
    return 0;
}
Now it will return 1 when an administrator is connected and 0 when there are no administrators connected.

Additionally, why do you create two variables in the loop? You only really need one:
pawn Код:
stock AdminConnected()
{
    for(new a = 0; a < GetMaxPlayers(); a++)
        if(IsPlayerConnected(a) && IsPlayerAdmin(a)) return 1;
    return 0;
}
Reply
#7

Holy cow, an admin replied me xD, Thanks sir...
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)