Online and Offline admins
#1

Hi, i wonder how can i create something that will with /admins command allow players to see all admins online and offline ones, for example if i type command /admins, i'll get something like this..


Admin_Name [Admin Level 1] [ON]
Admin_Name2[Admin Level 4] [OFF]
Admin_Name3[Admin Level 5] [ON - DUTY]

you know something like that, and yes i'm using mysql for saving...
Reply
#2

Theres a ton of them out there, not same but similar to what you want. Use the search function
Reply
#3

I did, can't find anything..
Reply
#4

loop through all of the existing players and check wether one of the players is an admin and if he does retreive his ame and format a message, then sendclientmessage with the information and you're done.
Reply
#5

How to loop trought mysql database, and also how can i check if admin is online or ofline
Reply
#6

Well if you are already using mysql than you just need to use a simple select query and check if the player is an admin
Reply
#7

Ok, but how to check if the admin is offline or onlyne, and where to store that selected informations from db ?
Reply
#8

You could add an extra online parameter in your mysql table and update it on OnPlayerConnect / Disconnect (you could store the playerid in the table while he is online and set it to something invalid if he is offline)
Or you check each row if the name is online by looping through all players (well that is kind of inefficient)
Reply
#9

still don't get it
Reply
#10

Try this

pawn Код:
CMD:offline( playerid, params[ ] )
{
    LevelCheck( playerid, 1 );
    GameTextForPlayer(playerid, "~g~ACCOUNT STATUS: ~r~ OFFLINE", 5000, 3);
    PlayerInfo[ playerid ] [ Offline ] = 1;
    return 1;
}
CMD:online( playerid, params[ ] )
{
    LevelCheck( playerid, 1 );
    GameTextForPlayer(playerid, "~g~ACCOUNT STATUS: ~r~ ONLINE", 5000, 3);
    PlayerInfo[ playerid ] [ Offline ] = 0;
    return 1;
}
Make sure you included zcmd.
Reply
#11

Nope, that's not it, you just copied it from somewhere, even LevelCheck is not included, just not it, but thanks anyway.
Reply
#12

Check for a Admin level greater than 1 in the database, then loop through the ids and/or names(of admins) and check if they are online.

I'd recommend you look for MySQL tutorials and get some more knowledge
Reply
#13

I'd recommend creating a file and keeping a list of all admins inside it, - or doing the same kind of thing with SQL/Databases, how-ever make sure the file stays updated/current. Cheers.
Reply
#14

This is something that i want it to look alike, i found the picture online

Reply
#15

Quote:
Originally Posted by ShoortyFl
Посмотреть сообщение
This is something that i want it to look alike, i found the picture online

Here is mine:

pawn Код:
CMD:admins(playerid, params[])
{
    new count = 0, name[24], stringON[128], stringOFF[258];
    SendClientMessage(playerid, COLOR_LIGHTBLUE, ""SERVER_NAME" Administrators Online");
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i) && PlayerInfo[i][pAdminLevel] >= 1)
        {
            if(aDuty[i] == 1)
            {
                GetPlayerName(i, name, sizeof(name));
                format(stringON, sizeof(stringON), "%s %s [ID: %i] [{33FF00}ON-DUTY{FFFFFF}]", GetAdminRankCOLOR(i), GetName(i), i);
                SendClientMessage(playerid, -1, stringON);
                count ++;
            }
            else if(aDuty[i] == 0)
            {
                GetPlayerName(i, name, sizeof(name));
                format(stringOFF, sizeof(stringOFF), "%s %s [ID: %i] [{FF0000}OFF-DUTY{FFFFFF}]", GetAdminRankCOLOR(i), GetName(i), i);
                SendClientMessage(playerid, -1, stringOFF);
                count ++;
            }
        }
    }

    if(count == 0)
    {
        SendClientMessage(playerid, COLOR_LIGHTBLUE, "[!] No Administrators Online");
    }
    return 1;
}
pawn Код:
stock GetAdminRankCOLOR(i)
{
    new tmpString[32];
    switch(PlayerInfo[i][pAdminLevel])
    {
        case 0: format(tmpString, sizeof(tmpString), "Player");
        case 1: format(tmpString, sizeof(tmpString), "{FF0000}A1{FFFFFF}");
        case 2: format(tmpString, sizeof(tmpString), "{FF0000}A2{FFFFFF}");
        case 3: format(tmpString, sizeof(tmpString), "{FF0000}A3{FFFFFF}");
        case 4: format(tmpString, sizeof(tmpString), "{FF0000}A4{FFFFFF}");
        case 5: format(tmpString, sizeof(tmpString), "{FF0000}A5{FFFFFF}");
        case 6: format(tmpString, sizeof(tmpString), "{FF0000}A6{FFFFFF}");
        case 7: format(tmpString, sizeof(tmpString), "{FF0000}A7{FFFFFF}");
        default: format(tmpString, sizeof(tmpString), "Undefined Admin");
    }
    return tmpString;
}
pawn Код:
stock GetName(playerid)
{
    new pName[MAX_PLAYER_NAME];
    GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
    return pName;
}
Reply
#16

I do have that, but thats only for online admins, image shows offline admins [OFF] and online [ON] or if on but afk then [AFK].
Reply
#17

pawn Код:
// top of gm
#define MAX_ADMINS  10
new AdminNames[MAX_ADMINS][MAX_PLAYER_NAME char];
new AdminsInGame;
pawn Код:
// Creating list of admins in OnGameModeInit
new len;
new File:F = fopen("Admins.ini",io_read);
while((len = fread(F,str)) && AdminsInGame < MAX_ADMINS)
{
    str[len - 2] = EOS;
    strpack(AdminNames[AdminsInGame++],str,sizeof(AdminNames[]));
}
fclose(F);
/*In file
Nick1
Nick2
Nick3 and after last nick must be enter key*/
you can use mysql without file for storing names


pawn Код:
// cmd /admins
new bool:found,count;
static tempAdmins[MAX_ADMINS][MAX_PLAYER_NAME char];
new name[MAX_PLAYER_NAME + 1];
for(new i=0; i != MAX_PLAYERS; i++)
    if(IsPlayerConnected(i) && IsAdmin(i) && count < MAX_ADMINS)
    {
        GetPlayerName(i,name,sizeof(name));
        strpack(tempAdmins[count++],name,sizeof(tempAdmins[]));
    }

new str[(MAX_PLAYER_NAME + 11) * MAX_ADMINS];
static status[][] = {"offline","online"};
for(new i=0,d; i != AdminsInGame; i++)
{
    found = false;
    for(d=0; d != count; d++)
        if(!strcmp(AdminNames[i],tempAdmins[d]))
        {
            found = true;
            break;
        }
    }

    strunpack(name,AdminNames[i]);
    format(str,sizeof(str),"%s%s (%s)\n",str,name,status[found]);
}
// ShowPlayerDialog(...);
Reply
#18

Quote:
Originally Posted by Ox1gEN
Посмотреть сообщение
loop through all of the existing players and check wether one of the players is an admin and if he does retreive his ame and format a message, then sendclientmessage with the information and you're done.
I agree.
For Example:

pawn Код:
for(new i = 0;i < MAX_PLAYERS; i++)
{
     if(IsPlayerAdmin(i))
     {
           new name[MAX_PLAYER_NAME],str[256];
           GetPlayerName(i,Name,sizeof(Name));
           format(str,sizeof(str)),"Admin %s is online.",name);
           SendClientMessage(playerid,0,str);
     }
}
Reply
#19

Yeah, I do understand that, but, I know how to select Admin and Level from db. But how to loop data from mysql ?
Reply
#20

at least show me ur mysql admin enum So I can do anything
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)