SA-MP Forums Archive
Online and Offline admins - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Online and Offline admins (/showthread.php?tid=540561)



Online and Offline admins - ShoortyFl - 05.10.2014

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


Re: Online and Offline admins - ZBits - 05.10.2014

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


Re: Online and Offline admins - ShoortyFl - 05.10.2014

I did, can't find anything..


Re: Online and Offline admins - Ox1gEN - 05.10.2014

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.


Re: Online and Offline admins - ShoortyFl - 05.10.2014

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


AW: Online and Offline admins - Nero_3D - 05.10.2014

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


Re: Online and Offline admins - ShoortyFl - 05.10.2014

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


AW: Online and Offline admins - Nero_3D - 05.10.2014

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)


Re: Online and Offline admins - ShoortyFl - 05.10.2014

still don't get it


Re: Online and Offline admins - Shady - 05.10.2014

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.


Re: Online and Offline admins - ShoortyFl - 05.10.2014

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


Re: Online and Offline admins - ZBits - 05.10.2014

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


Re: Online and Offline admins - Abagail - 06.10.2014

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.


Re: Online and Offline admins - ShoortyFl - 06.10.2014

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




Re: Online and Offline admins - MillenniumG - 06.10.2014

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;
}



Re: Online and Offline admins - ShoortyFl - 06.10.2014

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


Re: Online and Offline admins - Jefff - 06.10.2014

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(...);



AW: Re: Online and Offline admins - lcp9 - 06.10.2014

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);
     }
}



Re: Online and Offline admins - ShoortyFl - 06.10.2014

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


Re: Online and Offline admins - Eth - 06.10.2014

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