SA-MP Forums Archive
"CMD:admins" Help - 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: "CMD:admins" Help (/showthread.php?tid=607984)



"CMD:admins" Help - Filbert - 26.05.2016

Hello...
I'm newbie owner...
So, I need help...

I don't want /admins command like this >

___________|- Online Admins -|___________
Level 3 : blablabla1 (id 0) Guard, Level 2 : blablabla2 (id 1) Moderator
______________________________________

But I want like this >

___________|- Online Admins -|___________
Level 3 : blablabla1 (id 0) Guard
Level 2 : blablabla2 (id 1) Moderator
______________________________________

I know I must use SendClientMessage and string
But I don't want like the first instance
I want like the second instance

Sorry About My Bad English...
Please reply me who know about my problem...
Thanks...
God Bless You All...


Re: "CMD:admins" Help - Luicy. - 26.05.2016

Show us the /admins


Re: "CMD:admins" Help - Nin9r - 26.05.2016

HTML Code:
CMD:admins(playerid, params[])
{
		new string[128],sendername[25];
    	SendClientMessage(playerid, COLOR_REDFT, "[Admins Online]");
		foreach(Player,i)
		{
			if(PlayerData[i][pAdminLevel] >= 1)
	        {
	            new param2[32];
                    switch(PlayerData[i][pAdminDuty])
					{
						case 0: param2 = "Off Duty";
						case 1: param2 = "On Duty";
						default: param2 = "Off Duty";
					}
				GetPlayerName(i, sendername, sizeof(sendername));
	
    			if(PlayerData[i][pAdminLevel] == 3)
    			{
    				format(string, 256, "(%d) Admin 3 %s - %s",i,sendername, param2);
    			}
    			else if(PlayerData[i][pAdminLevel] == 2)
    			{
    				format(string, 256, "(%d) Admin 2 %s - %s",i,sendername, param2);
    			}
    			else if(PlayerData[i][pAdminLevel] == 1)
    			{
    				format(string, 256, "(%d) Admin 1 %s - %s",i,sendername, param2);
    			}
    			SendClientMessage(playerid, COLOR_WHITE, string);
			}
		}
		return 1;
}
Change pAdminLevel with your variable.


If you want this command without AOD showing try it :
HTML Code:
CMD:admins(playerid, params[])
{
		new string[128],sendername[25];
    	SendClientMessage(playerid, COLOR_REDFT, "[Admins Online]");
		foreach(Player,i)
		{
			if(PlayerData[i][pAdminLevel] >= 1)
	        {
				GetPlayerName(i, sendername, sizeof(sendername));
	
    			if(PlayerData[i][pAdminLevel] == 3)
    			{
    				format(string, 256, "(%d) Admin 3 %s - %s",i,sendername);
    			}
    			else if(PlayerData[i][pAdminLevel] == 2)
    			{
    				format(string, 256, "(%d) Admin 2 %s - %s",i,sendername);
    			}
    			else if(PlayerData[i][pAdminLevel] == 1)
    			{
    				format(string, 256, "(%d) Admin 1 %s - %s",i,sendername);
    			}
    			SendClientMessage(playerid, COLOR_WHITE, string);
			}
		}
		return 1;
}



Re: "CMD:admins" Help - Dayrion - 26.05.2016

You need to use SendClientMessage every time a player is an admin.
Check this :
PHP Code:
CMD:admins(playerid,params[])
{
    
SendClientMessage(playeridvert"___________|- Online Admins -|___________");
    new 
a;
    foreach(new 
Player// for(new i=0; i<MAX_PLAYERS; i++)
    
{
        if(
PlayerInfo[i][pAdminlvl] == 5)
        {
            
a+1;
             new 
name[MAX_PLAYER_NAME], str[MAX_PLAYER_NAME+120];
            
GetPlayerName(inamesizeof(name));
            
format(strsizeof(str), "[Fondateur] » "blancU"%s"name);
            
SendClientMessage(playeridred1str);
        }
        else if(
PlayerInfo[i][pAdminlvl] == 4)
        {
            
a+1;
             new 
name[MAX_PLAYER_NAME], str[MAX_PLAYER_NAME+120];
            
GetPlayerName(inamesizeof(name));
            
format(strsizeof(str), mappeur"[Mappeur] » "blancU"%s"name);
            
SendClientMessage(playeridX11_STEEL_BLUE_2str);
        }
         else if(
PlayerInfo[i][pAdminlvl] == 3)
        {
            new 
name[MAX_PLAYER_NAME], str[MAX_PLAYER_NAME+120];
            
GetPlayerName(inamesizeof(name));
            
format(strsizeof(str), "[Admin] » "blancU"%s"name);
            
SendClientMessage(playeridredstr);
            
a+1;
        }
         else if(
PlayerInfo[i][pAdminlvl] > 0)
        {
            new 
name[MAX_PLAYER_NAME], str[MAX_PLAYER_NAME+120];
            
GetPlayerName(inamesizeof(name));
            
format(strsizeof(str), modooPs"[Modo] » "blancU"%s"name);
            
SendClientMessage(playerid, -1str);
            
a+1;
        }
    }
    new 
str9[120];
    
format(str9sizeof(str9), "There is actually %i connected admins."a);
    
SendClientMessage(playeridX11_LIGHT_YELLOW_3str9);
    
SendClientMessage(playeridvert"|_____________________________________________________|");
    return 
1;

If you don't understand, show us your /admins!

EDIT : There is optimized version :
PHP Code:
CMD:admins(playerid,params[])
{
    
SendClientMessage(playeridvert"___________|- Online Admins -|___________");
    new 
astr[MAX_PLAYER_NAME+90];
    foreach(new 
Player// for(new i=0; i<MAX_PLAYERS; i++)
    
{
        switch(
PlayerInfo[i][pAdminlvl])
        {
            case 
5:
            {
                
a++;
                
format(strsizeof(str), "[Fondateur] » "blancU"%s"GetName(i));
                
SendClientMessage(playeridred1str);
            }
            case 
4:
            {
                
a++;
                
format(strsizeof(str), mappeur"[Mappeur] » "blancU"%s"GetName(i));
                
SendClientMessage(playeridX11_STEEL_BLUE_2str);
            }
             case 
3:
            {
                
format(strsizeof(str), "[Admin] » "blancU"%s"GetName(i));
                
SendClientMessage(playeridredstr);
                
a++;
            }
             case 
1,2:
            {
                
format(strsizeof(str), modooPs"[Modo] » "blancU"%s"GetName(i));
                
SendClientMessage(playerid, -1str);
                
a++;
            }
        }
    }
    if(
a==0) return SendClientMessage(playeridred1"There is no admin online");
    
format(strsizeof(str), "There is actually %i connected admins."a);
    
SendClientMessage(playeridX11_LIGHT_YELLOW_3str);
    
SendClientMessage(playeridvert"|_____________________________________________________|");
    return 
1;




Re: "CMD:admins" Help - Filbert - 26.05.2016

CMD:admins(playerid,params[]){
#pragma unused params
new Count = 0;
new n[MAX_PLAYER_NAME];
new string[1000];
// SendClientMessage(playerid, 0x00FF00FF, "__________|Admins|__________");
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(!IsPlayerConnected(i)) continue;
if(PlayerInfo[i][Level] < 1) continue;
GetPlayerName(i,n,sizeof(n));
format(string, 1000, "%sLevel %d: {FF9900}%s {FFFF00}(ID: %d) - %s\n", string, PlayerInfo[i][Level], n, i, GetRankFromLevel(i));
Count++;
}
if(Count == 0)
{
SendClientMessage(playerid, green, "___________|- Online Admins -|___________");
SendClientMessage(playerid, red, "No admin online in the list");
SendClientMessage(playerid, green, "_________________________________________");
return 1;
}
SendClientMessage(playerid, green, "___________|- Online Admins -|___________");
SendClientMessage(playerid, red, string);
SendClientMessage(playerid, green, "_________________________________________");
return 1;
}


Re: "CMD:admins" Help - Zorono - 26.05.2016

Code:
CMD:admins(playerid,params[])
{
	#pragma unused params
    new count = 0;
    new string[128];
    new AdmRank[128];
	new AdmDuty[128];
    new ChangeColor;
	SendClientMessage(playerid, green, " ");
    SendClientMessage(playerid, green, "___________ |- Online Admins -| ___________");
	SendClientMessage(playerid, green, " ");
	for(new i = 0; i < MAX_PLAYERS; i++)
	{
 		if (IsPlayerConnected(i))
		{
			if(PlayerInfo[i][Level] >= 1 && PlayerInfo[i][Hide] == 0)
			{
				if(IsPlayerAdmin(i))
			  	{
			  		AdmRank = "RCON Administrator";
			  		ChangeColor = Color_RCON_Administrator;
			  	}
			    else
			    {
			 		switch(PlayerInfo[i][Level])
					{
						case 1: {
							AdmRank = "tueyitu";
						}
						case 2: {
							AdmRank = "yuiuuo";
						}
						case 3: {
							AdmRank = "truiuk";
						}
						case 4: {
							AdmRank = "jfhk";
						}
						case 5: {
							AdmRank = "htytjyuj";
						}
						case 6: {
							AdmRank = "yj7ju";
						}
     					case 7: {
							AdmRank = "trjuyk";
						}
     					case 8: {
							AdmRank = "yt";

						}
     					case 9: {
							AdmRank = "trtyrt";
						}
					}
				}
	 			switch(PlayerInfo[i][OnDuty])
				{
					case 0: AdmDuty = "Off Duty!";
					case 1: AdmDuty = "On Duty!";
				}
				format(string, 128, "Level: %d - %s (Id:%i) | %s | %s",PlayerInfo[i][Level], PlayerName2(i),i,AdmRank,AdmDuty);
				SendClientMessage(playerid, ChangeColor, string);
				count++;
			}
		}
	}
	if (count == 0)
	SendClientMessage(playerid,red,"No admin online in the list");
	SendClientMessage(playerid, green, " _______________________________________");
	return 1;
}
try out my code


Re: "CMD:admins" Help - IceBilizard - 26.05.2016

Try this

PHP Code:
CMD:admins(playerid,params[])
{
    
#pragma unused params
    
new Count 0;
    new 
n[MAX_PLAYER_NAME];
    new 
string[1000];
    
// SendClientMessage(playerid, 0x00FF00FF, "__________|Admins|__________");
    
for(new 0MAX_PLAYERSi++)
    {
        if(!
IsPlayerConnected(i)) continue;
        if(
PlayerInfo[i][Level] < 1) continue;
        
Count++;
    }
    
SendClientMessage(playeridgreen"___________|- Online Admins -|___________");
    if(
Count != 0)
    {
            for (new 
0MAX_PLAYERSi++)
            {
                if (
IsPlayerConnected(i))
                {
                      if (
PlayerInfo[i][Level] >= 1)
                    {
                        
GetPlayerName(i,n,sizeof(n));
                        
format(string1000"%sLevel %d: {FF9900}%s {FFFF00}(ID: %d) - %s\n"stringPlayerInfo[i][Level], niGetRankFromLevel(i));
                        
SendClientMessage(playeridredstring);
                    }
                }
            }
    }
    else 
SendClientMessage(playeridred"No admin online in the list");
    
SendClientMessage(playeridgreen"_________________________________________");
    return 
1;




Re: "CMD:admins" Help - oMa37 - 26.05.2016

This should work:
PHP Code:
CMD:admins(playeridparams[])
{
    new 
count 0,
        
string[128],
        
Name[MAX_PLAYER_NAME];
    
SendClientMessage(playeridgreen"___________ |- Online Admins -| ___________");
    for(new 
0MAX_PLAYERSi++)
    {
         if(
IsPlayerConnected(i))
         {
            switch(
PlayerInfo[i][Level])
            {
                case 
1
                {
                    
Rank "Level 1";
                }
                case 
2
                {
                    
Rank "Level 2";
                }
                case 
3
                {
                    
Rank "Level 3";
                }
                case 
4
                {
                    
Rank "Level 4";
                }
                case 
5
                {
                    
Rank "Level 5";
                }
            }
        }
        
GetPlayerName(iNamesizeof(Name));
        
format(string128"Level %d: {FF9900}%s {FFFF00}(ID: %d) - %s",PlayerInfo[i][Level], NameiRank);
        
SendClientMessage(playeridredstring);
        
Count++;
    }
    if(
Count == 0)
    {
        
SendClientMessage(playeridgreen"___________|- Online Admins -|___________");
        
SendClientMessage(playeridred"No admin online in the list");
        
SendClientMessage(playeridgreen"_________________________________________");
    }
    return 
1;




Respuesta: "CMD:admins" Help - maverick91 - 28.05.2016

My command

Quote:

CMD:admins(playerid, params[])
{
SendClientMessage(playerid, -1, "| Staff |");
for(new i = 0; i < MAX_PLAYERS; i++){
if(IsPlayerConnected(i)){
if(PlayerInfo[i][pAdmin] >= 1 && PlayerInfo[i][pAdmin] <= 10){
new string[128],admtext[24];
switch(PlayerInfo[i][pAdmin]){
case 1: admtext = "Helper";
case 3: admtext = "Moderator";
case 5: admtext = "Administration";
case 6: admtext = "Manager";
case 7: admtext = "Boss";
case 10: admtext = "Owner";
}
format(string, sizeof(string)," %s - %s", admtext, GetPlayerNameEx(i));
SendClientMessage(playerid, 0xC0C0C0FF, string);
}
}
}
return 1;
}