SA-MP Forums Archive
I am having troubles making an /admins command. - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: I am having troubles making an /admins command. (/showthread.php?tid=262991)



I am having troubles making an /admins command. - kin - 20.06.2011

Ok, so i have tried many different methods but none of them worked out as i hoped. So i am wondering if you, the community. Can help me figure this command out. I need serious help on this one, please and thank you.


Re: I am having troubles making an /admins command. - Smurf[SMURF] - 20.06.2011

Код:
if(strcmp(cmd, "/admins", true) == 0) // If the player types /admins...
{
    new playername[32]; // Create a new string where the players name will be stored
    new string[64]; // Creates a new string where the message will be stored
    SendClientMessage(playerid, COLOR_WHITE, "Admins online:"); // Sends the beginning text "Admins online:"
    for(new i = 0; i < MAX_PLAYERS; i++) // Creates a loop which runs for every player on the server
    {
        if(PlayerInfo[i][pAdmin] > 0) // If the players level is above 0.. you must replace this with whatever your definition as an admin
        {
            GetPlayerName(i, playername, sizeof(playername)); // Store the players name under 'playername'
            format(string, sizeof(string), "Admin: %s, Level: %d", playername, PlayerInfo[i][pAdmin]); // Add a new message which contains the players name and level
            SendClientMessage(playerid, COLOR_GREY, string); // Sends the message to the player
        }
    }
}
hopefully this will help you


Re : I am having troubles making an /admins command. - Amine_Mejrhirrou - 20.06.2011

that not a command info but i think that you sould think about that : WHEN A HACK JOIN YOUR SERVER THE FIRST THING HE DO IS /ADMIND TO KNOW IF HE CAN HACK WITHOUT PROBLEM ! SO command that show you the admins online is a very very very bad idea if you want to ban the hackers (if a hacker see that admins are online he will only make undetecteble hacks like more ammo ! or a small Air B for example and the admins will notknow it)


Re: I am having troubles making an /admins command. - PCheriyan007 - 20.06.2011

He has a good point, try making it say with SendClientMessage (or anything else you would use) saying that there are no admins online. It'll save you the trouble of having to go through and look at all the code.


Re: I am having troubles making an /admins command. - skaTim - 20.06.2011

Quote:
Originally Posted by Smurf[SMURF]
Посмотреть сообщение
Код:
if(strcmp(cmd, "/admins", true) == 0) // If the player types /admins...
{
    new playername[32]; // Create a new string where the players name will be stored
    new string[64]; // Creates a new string where the message will be stored
    SendClientMessage(playerid, COLOR_WHITE, "Admins online:"); // Sends the beginning text "Admins online:"
    for(new i = 0; i < MAX_PLAYERS; i++) // Creates a loop which runs for every player on the server
    {
        if(PlayerInfo[i][pAdmin] > 0) // If the players level is above 0.. you must replace this with whatever your definition as an admin
        {
            GetPlayerName(i, playername, sizeof(playername)); // Store the players name under 'playername'
            format(string, sizeof(string), "Admin: %s, Level: %d", playername, PlayerInfo[i][pAdmin]); // Add a new message which contains the players name and level
            SendClientMessage(playerid, COLOR_GREY, string); // Sends the message to the player
        }
    }
}
hopefully this will help you
Wrong!

Код:
if(strcmp(cmd,"/admins",true)==0){
  new admname[MAX_STRING];
  SendClientMessage(playerid, COLOR_GREEN, "..:: Admin List ::..");
     for(new i=0;i<MAX_PLAYERS;i++){
	 if((PlayerInfo[i][power]>0 && IsPlayerConnected(i)){ // power=pAdmin
	    if(PlayerTemp[i][OnDuty]){ 
	       format(admname,sizeof(admname),"Admin %s [Level: %d] [On Duty]",PlayerName(i),PlayerInfo[i][power]);
	       SendClientMessage(playerid, COLOR_GREEN, admname);
	    }
	    else{
		format(admname,sizeof(admname),"Admin %s [Level: %d] [Off Duty]",PlayerName(i),PlayerInfo[i][power]);
		SendClientMessage(playerid, COLOR_RED, admname);
	    }
            return 1;
	}
    }
    return 1;
}
You can add 'OnDuty' to PlayerInfo if youre not really sure what it is..


Re: I am having troubles making an /admins command. - kin - 20.06.2011

We have an amazing punkbuster.


Re: I am having troubles making an /admins command. - Smurf[SMURF] - 21.06.2011

Quote:
Originally Posted by skaTim
Посмотреть сообщение
Wrong!

Код:
if(strcmp(cmd,"/admins",true)==0){
  new admname[MAX_STRING];
  SendClientMessage(playerid, COLOR_GREEN, "..:: Admin List ::..");
     for(new i=0;i<MAX_PLAYERS;i++){
	 if((PlayerInfo[i][power]>0 && IsPlayerConnected(i)){ // power=pAdmin
	    if(PlayerTemp[i][OnDuty]){ 
	       format(admname,sizeof(admname),"Admin %s [Level: %d] [On Duty]",PlayerName(i),PlayerInfo[i][power]);
	       SendClientMessage(playerid, COLOR_GREEN, admname);
	    }
	    else{
		format(admname,sizeof(admname),"Admin %s [Level: %d] [Off Duty]",PlayerName(i),PlayerInfo[i][power]);
		SendClientMessage(playerid, COLOR_RED, admname);
	    }
            return 1;
	}
    }
    return 1;
}
You can add 'OnDuty' to PlayerInfo if youre not really sure what it is..
your code is messy :P


Re: I am having troubles making an /admins command. - skaTim - 21.06.2011

didn't tested