AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [SOLVED] custom /admins "online" ? (https://forums.alliedmods.net/showthread.php?t=209275)

Blizzard_87 02-23-2013 17:19

[SOLVED] custom /admins "online" ?
 
im using this method to assign ranks to clients...

PHP Code:

/* Rank Names */
enum
{
    
OWNER,
    
HADMIN,
    
ADMIN,
    
PLAYER,
    
    
AUTHORIZED
};

new const 
AccessType[AUTHORIZED][]=
{
    
"Manager",
    
"Head Admin",
    
"Admin",
    
"Player"
};
/* Rank Names End */ 

and how they get assigned to clients

PHP Code:

public client_connect(id)
{
    
    
rank1 get_user_flags(id) & ADMIN_LEVEL_B;
    
rank2 get_user_flags(id) & ADMIN_LEVEL_C;
    
rank3 get_user_flags(id) & ADMIN_LEVEL_D;
    
rank4 get_user_flags(id) & ADMIN_ALL;
    
    if(
rank1 rank2 rank3)
    {
        
RankName[id] = OWNER;
    }
    
    else if(
rank2 && rank3)
    {
        
RankName[id] = HADMIN;
    }
    
    else if(
rank3)
    {
        
RankName[id] = ADMIN;
    }        
        
    else if(
rank4)
    {
        
RankName[id] = PLAYER;
    } 

now my question is how to script this into a client_print ?

i know i havent tried yet... just need a shove in right direction ?

thanks,

Doc-Holiday 02-23-2013 17:39

Re: custom /admins "online" ?
 
hook the command that you want to use.. then loop through the players on the server... get_players method works well..

If you want to display something like this
Code:

[AMXX] Name: SavSin    Rank: Manager
PHP Code:

public cmdAdminsOnline(id)
{
    new 
iPlayers[32], iPlayersNum;
    
get_players(iPlayersiPlayersNum); //iPlayers is an array which holds the player id's of the only line players. iPlayersNum is number of players playing.
                                                        //if iPlayersNum was 5 then iPlayers would hold the id's for those players in cell's 0-4
    
new szName[32];
    
    for(new 
i=0iPlayersNumi++)
    {
        
get_user_name(iPlayers[i], szNamecharsmax(szName));
        
client_print(idprint_chat"[AMXX] Name: %s Rank: %s"szNameAccessType[RankName[iPlayers[i]]]);
    }



Blizzard_87 02-23-2013 17:55

Re: custom /admins "online" ?
 
Quote:

Originally Posted by Doc-Holiday (Post 1900423)
hook the command that you want to use.. then loop through the players on the server... get_players method works well..

If you want to display something like this
Code:

[AMXX] Name: SavSin    Rank: Manager
PHP Code:

public cmdAdminsOnline(id)
{
    new 
iPlayers[32], iPlayersNum;
    
get_players(iPlayersiPlayersNum); //iPlayers is an array which holds the player id's of the only line players. iPlayersNum is number of players playing.
                                                        //if iPlayersNum was 5 then iPlayers would hold the id's for those players in cell's 0-4
    
new szName[32];
    
    for(new 
i=0iPlayersNumi++)
    {
        
get_user_name(iPlayers[i], szNamecharsmax(szName));
        
client_print(idprint_chat"[AMXX] Name: %s Rank: %s"szNameAccessType[RankName[iPlayers[i]]]);
    }



PHP Code:

public cmdAdminsOnline(id)
{
    new 
iPlayers[32], iPlayersNum;
    
get_players(iPlayersiPlayersNum);
    new 
szName[32];
    
    
get_pcvar_string(TAGPREFIXcharsmax(PREFIX));
    
    for(new 
i=0iPlayersNumi++)
    {
        
get_user_name(iPlayers[i], szNamecharsmax(szName));
        
client_printc(id"!g[%s]!n %s(!g%s!n) "PREFIXszNameAccessType[RankName[iPlayers[i]]]);
    }


works... but was hoping to display like this..

[PREFIX] Admins Online: Name1 (Rank), Name2 (Rank), Name3 (Rank), etc etc

and if g_HideRank is true then to only show admins who have NOT chosen to hide rank...

this explanation make sense?

Blizzard_87 02-23-2013 18:03

Re: custom /admins "online" ?
 
SOLVED:

PHP Code:

public onlineadmins(id) {
    new 
players[32],pnumplayer;
    
get_players(players,pnum);
    
    
get_pcvar_string(TAGPREFIXcharsmax(PREFIX));
        
    new 
temp[216],name[32], count
    
    
for( new ii<pnumi++ ) {
        if(!
g_HideRank[players[i]]) {
            
player players[i]
            
count++
            
get_user_name(player,name,31)
            
formatex(temp,215,"%s %s !n(!g%s!n),!t "tempnameAccessType[RankName[players[i]]])
        }
    }
    if(
count)
        
client_printc(id"!g[%s]!n Admins Online:!t %s!n"PREFIXtemp)
    else
        
client_printc(id"!g[%s]!n No admins online."PREFIX)
        
    return 
PLUGIN_HANDLED;



Doc-Holiday 02-23-2013 19:12

Re: Re: custom /admins "online" ?
 
Quote:

Originally Posted by Blizzard_87 (Post 1900435)
SOLVED:

PHP Code:

public onlineadmins(id) {
new 
players[32],pnumplayer;
get_players(players,pnum);

get_pcvar_string(TAGPREFIXcharsmax(PREFIX));

new 
temp[216],name[32], count

for( new ii<pnumi++ ) {
if(!
g_HideRank[players[i]]) {
player players[i]
count++
get_user_name(player,name,31)
formatex(temp,215,"%s %s !n(!g%s!n),!t "tempnameAccessType[RankName[players[i]]])
}
}
if(
count)
client_printc(id"!g[%s]!n Admins Online:!t %s!n"PREFIXtemp)
else
client_printc(id"!g[%s]!n No admins online."PREFIX)

return 
PLUGIN_HANDLED;



Then formatex is what you want like you did

WeeZick 02-25-2013 15:26

Re: custom /admins "online" ?
 
Quote:

Originally Posted by Blizzard_87 (Post 1900435)
SOLVED:

PHP Code:

public onlineadmins(id) {
    new 
players[32],pnumplayer;
    
get_players(players,pnum);
    
    
get_pcvar_string(TAGPREFIXcharsmax(PREFIX));
        
    new 
temp[216],name[32], count
    
    
for( new ii<pnumi++ ) {
        if(!
g_HideRank[players[i]]) {
            
player players[i]
            
count++
            
get_user_name(player,name,31)
            
formatex(temp,215,"%s %s !n(!g%s!n),!t "tempnameAccessType[RankName[players[i]]])
        }
    }
    if(
count)
        
client_printc(id"!g[%s]!n Admins Online:!t %s!n"PREFIXtemp)
    else
        
client_printc(id"!g[%s]!n No admins online."PREFIX)
        
    return 
PLUGIN_HANDLED;



Where have you defined g_HideRank?
My friend is interested in this too.
Send full code please

Blizzard_87 02-25-2013 15:58

Re: custom /admins "online" ?
 
Quote:

Originally Posted by WeeZick (Post 1901841)
Where have you defined g_HideRank?
My friend is interested in this too.
Send full code please

defined above plugin_init ( )

new bool:g_HideRank [33];

ironskillz1 02-25-2013 16:02

Re: custom /admins "online" ?
 
Quote:

Originally Posted by Blizzard_87 (Post 1901857)
defined above plugin_init ( )

new bool:g_HideRank [33];

A plugin like this already exist
Hiderank
Admin menu
Change tag

WeeZick 02-25-2013 16:26

Re: custom /admins "online" ?
 
Quote:

Originally Posted by Blizzard_87 (Post 1901857)
defined above plugin_init ( )

new bool:g_HideRank [33];

But you need to use g_HideRank somewhere, in a function?
or else it will be error g_HideRank have no effect

WeeZick 02-25-2013 16:42

Re: custom /admins "online" ?
 
Quote:

Originally Posted by ironskillz1 (Post 1901858)
A plugin like this already exist
Hiderank
Admin menu
Change tag

I know but i dont have it. It is Execute-Gaming menu


All times are GMT -4. The time now is 21:47.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.