Admin list Help!!
#1

i want to make a command /admins so tht when we do tht we can see
(No.) Admins are online..
pls help me . +rep
Reply
#2

Learn to script and make things yourself or go to a suitable section and ask there.
Reply
#3

What you need is a simple loop that goes through all players and finds the administrators. Make it increment a variable so after the loop you know how many administrators were found. I'm going to assume you already have a command that finds admins.

pawn Code:
new foundAdmins;
foreach(Player, i) // or for(new i = 0; i != MAX_PLAYERS; i++) with a IsPlayerConnected check
{
    if(IsPlayerAdmin(i))
    {
        foundAdmins ++;
        // display admin name or whatever
    }
}
if(!foundAdmin)
{
    // No admins were found.
}
Reply
#4

pawn Code:
//on Command:/admins
for(new i=0;i!=Max_PLAYERS;i++)
{
        if(IsPlayerConnected(playerid))
        {
                if(IsPlayerAdmin(i))
                {
                      new Name[MAX_PLAYER_NAME];
                       GetPlayerName(i,Name);
                      new Str[256];
                     format(Str,sizeof(Str),"Admin (%d) : %s was online",i,Name);
                      SendClientMessage(playerid,COLOR_WHITE,Str);
                 }
          }
}              
//Try this
Reply
#5

Harish, first of all, the code won't compile, because Max_PLAYERS is not a default definition. MAX_PLAYERS is. And for the sake of some efficiency, redefining it on top of your script would be handy unless your server actually has 500 slots.
pawn Code:
#undef
#define MAX_PLAYERS 100 // for a server with 100 slots
Continuing, in the IsPlayerConnected check, you pass playerid as the parameter! - That is clearly wrong, you need to pass i instead.

Also, you can effectively combine 2 if-checks like this:
pawn Code:
if(IsPlayerConnected(i))
{
    if(IsPlayerAdmin(i))
    {
    }
}
To this:
pawn Code:
if(IsPlayerConnected(i) && IsPlayerAdmin(i))
Ultimately, since IsPlayerAdmin is a native function of the SA-MP server, it already has an INBUILT connection check, so actually, your whole loop can be simplified to:
pawn Code:
for(new i = 0; i != MAX_PLAYERS; i++)
{
    if(IsPlayerAdmin(i))
    {
        // code
    }
}
Continuing, the maximal possible length of "Admin (%d) : %s was online" is definitely not 256. Start off by reading this post (why not to make your strings 256 cells large).

Also, why do you even bother posting when you see that a suitable solution has already been given? Besides your code does not do what he asked for.
Reply
#6

Quote:
Originally Posted by Unte99
View Post
Learn to script and make things yourself or go to a suitable section and ask there.
Stop being so freaking rude. He said: "I want to make......" Not "I want...."
Reply
#7

yuup correct agreed with introzen!
Quote:

//on Command:/admins
for(new i=0;i!=Max_PLAYERS;i++)
{
if(IsPlayerConnected(playerid))
{
if(IsPlayerAdmin(i))
{
new Name[MAX_PLAYER_NAME];
GetPlayerName(i,Name);
new Str[256];
format(Str,sizeof(Str),"Admin (%d) : %s was online",i,Name);
SendClientMessage(playerid,COLOR_WHITE,Str);
}
}
}

is this only for one admin??
Reply
#8

No, it show you only rcon admins connected.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)