Admin ranks
#1

hey guys i got problem with the admin ranks i got the /makeadmin system.

Код:
    new cmd[256], idx;
	cmd = strtok(cmdtext, idx);
	if(strcmp(cmd, "/makeadmin", true) == 0)
	{
       new string[128];
       new tmp[256];
       new player[MAX_PLAYER_NAME], giveplayer[MAX_PLAYER_NAME];
       new giveplayerid;
       if (IsPlayerAdmin(playerid))
       {
               tmp = strtok(cmdtext, idx);
               if(!strlen(tmp))
               {
                       SendClientMessage(playerid, COLOUR_AQUA, "USAGE: /makeadmin [playerid] [level]");
                       SendClientMessage(playerid, COLOUR_AQUA, "FUNCTION: Player will be an admin.");
                       return 1;
               }
               giveplayerid = ReturnUser(tmp);
               tmp = strtok(cmdtext, idx);
               new level = strval(tmp);
               if(giveplayerid != INVALID_PLAYER_ID)
               {
                       GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
                       GetPlayerName(playerid, player, sizeof(player));
                       PlayerInfo[giveplayerid][pAdminLevel] = level;
                       printf("Admin %s made %s a level %d admin.", player, giveplayer, level);
                       format(string, sizeof(string), "You are now an administrator level %d thanks to %s.", level,  player);
                       SendClientMessage(giveplayerid, 0x00C2ECFF, string);
                       format(string, sizeof(string), "You have given %s level %d admin.",  giveplayer,PlayerInfo[giveplayerid][pAdminLevel]);
                       SendClientMessage(playerid, 0x00C2ECFF, string);
               }
               else if(giveplayerid == INVALID_PLAYER_ID)
               {
                       format(string, sizeof(string), "%i is not an active player.", giveplayerid);
                       SendClientMessage(playerid, 0xE60000FF, string);
               }
       }
       else
       {
           SendClientMessage(playerid, 0xE60000FF, "You are not a lead admin!");
			}
	return 1;
	}
but how i can make it like this that if you talk infront of your name will be Admin Rank name and if i set myself like level 6 admin then it sets you that admin level. if you know what i mean so basically you cna use the commands what are meant for that level admin and also you can use lower level admin commands.
Reply
#2

anywhere:
pawn Код:
enum PlayerData
{
    Level,
    // etc
}
new PlayerInfo[MAX_PLAYERS][PlayerData]; //making a varbi to set and get player info which inside enum.
to use cmds like what you told:
just do to check what his lvl in cmd by using:
pawn Код:
if(PlayerInfo[playerid][Level] <= 6)
         {
                // here your code
         }
         else // if not lvl 6 and lower:
         {
              SendClientMessage(playerid, red, "not high enough level");
         }
         return 1;
<= is equals and lower

See: http://en.wikipedia.org/wiki/Operators_in_C_and_C++
Reply
#3

may i ask how i can do like this if im admin then if i talk in chat it will show before my name the Owner or somethin
?
Reply
#4

use this cmd /asay it show admin rank with chat try
Код:
CMD:asay ( playerid, params[] )
{
new string[128], text[128], pName[MAX_PLAYER_NAME]; // Two new variables for storing 'message' and     'text' (/asay <Text>)..
GetPlayerName( playerid, pName, sizeof(pName) );
if ( Player[ playerid ][ pAdmin ] < 2 ) return SendClientMessage( playerid, -1, "[ERROR]: You don't have the required admin level!" ); // Checking player's admin level and sending error message accordingly..
if ( sscanf ( params, "s[128]", text ) ) return SendClientMessage( playerid,-1, "[USAGE]: /asay <Text>" );
format( string , sizeof(string), "[%s] %s : %s",staffrank(playerid), pName, text );
SendClientMessageToAll( -1, string ); // -1 = White Color..
return 1;
}
}
stock staffrank(playerid) {
	new szString[256];
	switch(Player[playerid][pAdmin]) {
	    case 0: szString = "Not a Staff Member";
	    case 1: szString = "Trial Admin";
	    case 2: szString = "Senior Moderator";
 	    case 3: szString = "Lead Admin";
 	    case 4: szString = "Head Admin";
 	    case 5: szString = "Server Owner";

	}
	return szString;
}
Reply
#5

i mean like i dont want a command for that i want that if you set player as admin then it automatically sets your name Ex: "[Owner] Shark: Hello" example like this
Reply
#6

pawn Код:
public OnPlayerText(playerid, text[])
{
    new name[MAX_PLAYER_NAME]; GetPlayerName(playerid, name, sizeof(name));
    new string[128];
    if(PlayerInfo[playerid][Level] == 6) // if level is 6
    {
          format(string, sizeof(string), "Owner %s: %s", name, text[0]) // name is player name, text[0] [0] is the        first text you type.
          SendClientMessageToAll(COLOR, string); // sends the message
          return 0; // return 0; is to mind the old text from sending, so will be only 1 text to be sent.
    }
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)