PDA

View Full Version : Admin level Owner


025Tadija
08/07/2015, 10:41 PM
I need help to make Admin Rank: Owner, so currently I have admin levels: 1,2,3,4,1337,1338, but I want one more that is called "Owner" so I want to have 1,2,3,4,1337,1338 and Owner.. I dont' know how to create admin level with words, not numbers.

kyriakos587
08/07/2015, 10:44 PM
make it like this

if(AdminLeve... >= 1400){
SendClientMessage(playerid,-1,"Owner");
}

That code mean, if someone have 1400 admin level it will show Owner and no 1400 ;)

Srr for bad english

025Tadija
08/07/2015, 10:56 PM
yeah but I want like this

Usage: /makeadmin [playerid] [admin level]

/makeadmin 3 Owner
/make 3 1338
/make 3 2

kyriakos587
08/07/2015, 11:29 PM
ohhh that you mean lel..

copy & paste that:

if(strcmp(params,"Owner",false)){ // Here change the params to the variable that you have to type the Level
//MSG...
AccInfo[id][AdminLevel] = 1400; //Here change it to your variable that you have to make it admin
//If you have PlayerInfo change it, to [AdminLevel] change it and make it that you have, i mean if you have it Admin just change it to admin
}

srr for bad english

025Tadija
09/07/2015, 01:36 PM
anyone?

liquor
09/07/2015, 02:13 PM
Show your makeadmin command so that we know how to make it for your script, as it differs depending on what includes and plugins you might have.

025Tadija
09/07/2015, 02:26 PM
CMD:makeadmin(playerid, params[])
{
new
ID, alevel, string[120];

if(!IsPlayerAdmin(playerid))
return SendClientMessage(playerid, COLOR_RED,"No permission for command");

if(sscanf(params,"ui", ID, alevel))
return SendClientMessage(playerid, -1, "Usage: /makeadmin [playerid] [admin level]");

if(ID == INVALID_PLAYER_ID)
return SendClientMessage(playerid, COLOR_RED, "Player is not connected.");

if(!IsValidAdminLevel(alevel))
return SendClientMessage(playerid, COLOR_RED, "Only 1,2,3,4,1337,1338 and 2015");

if(pInfo[ID][pAdmin] >= 1)
return SendClientMessage(playerid, COLOR_RED, "Player is already admin.");

SCM(ID, -1, "You are an admin now");


pInfo[ID][pAdmin] = alevel;

return 1;
}


stock IsValidAdminLevel(level) // stock za proveravanje admin levela, 1,2,3,4, 1337, 1338
{
static
adminlevels[] = {1, 2, 3, 4, 1337, 1338, 2015};

for(new i= 0; i < 7; i++)
{
if(level == adminlevels[i])
{
return 1;
}
}

return 0;
}

Bomber07
09/07/2015, 02:34 PM
Admin level

//===================================Admins Colors=========================================//
#define Color_Server_Owner 0xF60000FF //Level 6
#define Color_Global_Admin 0xF66E00FF //Level 5
#define Color_Lead_Admin 0x0000F6FF //Level 4
#define Color_Senior_Admin 0xF6F600FF //Level 3
#define Color_Server_Admin 0xF600ABFF //Level 2
#define Color_Trial_Admin 0x00F6F6FF //Level 1
#define Color_Helper 0xB5A5F6FF //Operator
#define Color_RCON_Administrator 0xF60000FF //Rcon Admin
//================================================== ===========================================//

enum PlayerData
{
Level,
};

CMD:setlevel(playerid,params[]) {
if(PlayerInfo[playerid][Level] >= 5 || IsPlayerAdmin(playerid)) {
new tmp[256], tmp2[256], Index; tmp = strtok(params,Index), tmp2 = strtok(params,Index);
if(isnull(params)) return SendClientMessage(playerid, red, "USAGE: /setlevel [playerid] [level]");
new player1, level, playername[MAX_PLAYER_NAME], adminname[MAX_PLAYER_NAME], string[128];
player1 = strval(tmp);
if(isnull(tmp2)) return SendClientMessage(playerid, red, "USAGE: /setlevel [playerid] [level]");
level = strval(tmp2);

if(IsPlayerConnected(player1) && player1 != INVALID_PLAYER_ID) {
if(PlayerInfo[player1][LoggedIn] == 1) {
if(level > 7 ) return SendClientMessage(playerid,red,"ERROR: Incorrect Level");
if(level == PlayerInfo[player1][Level]) return SendClientMessage(playerid,red,"ERROR: Player is already this level");
CMDMessageToAdmins(playerid,"SETLEVEL");
GetPlayerName(player1, playername, sizeof(playername)); GetPlayerName(playerid, adminname, sizeof(adminname));
new year,month,day; getdate(year, month, day); new hour,minute,second; gettime(hour,minute,second);

if(level > 0) format(string,sizeof(string),"Administrator %s has set you to Administrator Status [level %d]",adminname, level);
else format(string,sizeof(string),"Administrator %s has set you to Player Status [level %d]",adminname, level);
SendClientMessage(player1,blue,string);

if(level > PlayerInfo[player1][Level]) GameTextForPlayer(player1,"~g~Promoted", 2000, 3);
else GameTextForPlayer(player1,"~r~Demoted", 2000, 3);

format(string,sizeof(string),"You have made %s Level %d on %d/%d/%d at %d:%d:%d", playername, level, day, month, year, hour, minute, second); SendClientMessage(playerid,blue,string);
format(string,sizeof(string),"Administrator %s has made %s Level %d on %d/%d/%d at %d:%d:%d",adminname, playername, level, day, month, year, hour, minute, second);
SaveToFile("AdminLog",string);
dUserSetINT(PlayerName2(player1)).("level",(level));
PlayerInfo[player1][Level] = level;
return PlayerPlaySound(player1,1057,0.0,0.0,0.0);
} else return SendClientMessage(playerid,red,"ERROR: Player must be registered and logged in to be admin");
} else return SendClientMessage(playerid, red, "Player is not connected");
} else return SendClientMessage(playerid,red,"ERROR: You are not a high enough level to use this command");
}

return 1;

025Tadija
09/07/2015, 02:36 PM
Dude, I don't need that, I need to make level called "Owner", I already have 1,2,3,4,1337, 1338 admin levels but i want one more calld "Owner" with words, not numbers.

liquor
09/07/2015, 02:36 PM
CMD:makeadmin(playerid, params[])
{
new
ID, alevel[10], string[120];

if(!IsPlayerAdmin(playerid))
return SendClientMessage(playerid, COLOR_RED,"No permission for command");

if(sscanf(params,"us[10]", ID, alevel))
return SendClientMessage(playerid, -1, "Usage: /makeadmin [playerid] [admin level]");

if(ID == INVALID_PLAYER_ID)
return SendClientMessage(playerid, COLOR_RED, "Player is not connected.");

// This must be before IsValidAdminLevel check below
if(!strcmp(alevel,"Owner") || !strcmp(alevel,"owner"))
{
SCM(ID, -1, "You are an admin now");
return pInfo[ID][pAdmin] = 9999; // return so it doesn't execute the rest of the code below.
}

if(!IsValidAdminLevel(strval(alevel)))
return SendClientMessage(playerid, COLOR_RED, "Only 1,2,3,4,1337,1338,2015 and 'Owner'");

if(pInfo[ID][pAdmin] >= 1)
return SendClientMessage(playerid, COLOR_RED, "Player is already admin.");

SCM(ID, -1, "You are an admin now");


pInfo[ID][pAdmin] = strval(alevel);

return 1;
}

liquor
09/07/2015, 02:39 PM
The level will be 9999 as an example, and will work if you do /makeadmin <id> Owner.
If you don't want to rewrite alot of your code you'll need to have a numeric adminlevel within the script, but you can certainly make it work like you mentioned, so that an admin just types "owner" ingame.

Stev
09/07/2015, 02:39 PM
Assigning levels is easier to manage, then text ranks.

SecretBoss
09/07/2015, 02:43 PM
so your problem solved or you still need help?

025Tadija
09/07/2015, 02:44 PM
That is fine liquor but when I type /admins it shows "Admin level: 9999"; not Admin level: Owner

notime
09/07/2015, 02:45 PM
so your problem solved or you still need help?

I think he needs someone to explain him that the admin level stays numeric, but for other players it will become "owner" if the level is 9999(if he scripts it that way). I dont think he quite understands that his integer cannot become "owner".

Stev
09/07/2015, 02:45 PM
stock AdminRanks(playerid)
{
new rank[40];
if(PlayerInfo[playerid][pAdmin] == 9999) rank= "Owner";
return rank;
}


You would add this in the string on your (/admins) command

format(string, sizeof(string),"%d - %s",PlayerInfo[i][pAdmin], AdminRanks(i));

SecretBoss
09/07/2015, 02:46 PM
I think he needs someone to explain him that the admin level stays numeric, but for other players it will become "owner" if the level is 9999(if he scripts it that way). I dont think he quite understands that his integer cannot become "owner".

Yea but he can use some defines or switch to make it on server showing like Owner text, about interger you are absolutely right :)

liquor
09/07/2015, 02:49 PM
Yeah, i know. But you'll need to change the /admins command as well, with an 'if' statement, so that it will change the level to 'Owner' if level is 9999...

025Tadija
09/07/2015, 02:49 PM
CMD:admins(playerid, params[])
{
SendClientMessage(playerid, COLOR_GREY, "Admins online:");
foreach(Player, i)
{
if(IsPlayerConnected(i))
{
if(pInfo[i][pAdmin] >= 1)
{
if(pInfo[i][pDuty] == true) // if player is onduty
{
if(pInfo[i][pNameAdmin] == true) // if player has his forumname on
{
SendClientMessageEx(playerid, COLOR_ORANGE,"(ID: %d) %s (%s) (Admin level: %d)", i, PlayerName(i),pInfo[i][pAdminName], pInfo[i][pAdmin]);
}

else
{
SendClientMessageEx(playerid, COLOR_ORANGE,"(ID: %d) %s (Admin level: %d)", i, PlayerName(i), pInfo[i][pAdmin]);
}

}

else
{

if(pInfo[i][pNameAdmin] == true)
{
SendClientMessageEx(playerid, COLOR_GREY,"(ID: %d) %s (%s) (Admin level: %d)", i, PlayerName(i),pInfo[i][pAdminName], pInfo[i][pAdmin]);
}

else
{
SendClientMessageEx(playerid, COLOR_GREY,"(ID: %d) %s (Admin level: %d)", i, PlayerName(i), pInfo[i][pAdmin]);
}

}
}
}
}
return 1;
}


that is my admins command

SecretBoss
09/07/2015, 02:50 PM
Yeah, i know. But you'll need to change the /admins command as well, with an 'if' statement, so that it will change the level to 'Owner' if level is 9999...

thats what I am using

switch(PlayerData[i][pAdmin])
{
case 1: LevelName = "Moderator";
case 2: LevelName = "Administrator";
case 3: LevelName = "General Admin";
case 4: LevelName = "Head Admin";
case 5: LevelName = "Owner";

}

Crystallize
09/07/2015, 02:55 PM
lol you have to add it in stock not in the CMD lmfao >_<

liquor
09/07/2015, 02:57 PM
thats what I am using

switch(PlayerData[i][pAdmin])
{
case 1: LevelName = "Moderator";
case 2: LevelName = "Administrator";
case 3: LevelName = "General Admin";
case 4: LevelName = "Head Admin";
case 5: LevelName = "Owner";

}

Change 'case' to the according adminlevel.
Example; case 9999: LevelName = "Owner";

025Tadija
09/07/2015, 03:01 PM
I still don't get it guys -.-

Stev
09/07/2015, 03:07 PM
You made that command so hard for your self.

025Tadija
09/07/2015, 03:08 PM
I know haha, but I still trying to make it works.

notime
09/07/2015, 03:09 PM
I still don't get it guys -.-

Okay, look, so you admin level, its a number, right? We call it an integer.
Integers can only be a a full number, like -1, 0, 1 going into infinity.

"owner" is a word, so its a string.
You CANNOT store a string onto a variable that can only hold an integer.
So pInfo[ID][pAdmin] can only hold an integer.

Now to "trick" the system we just say, 9999 is for owners. So when pInfo[ID][pAdmin] is 9999 then it has to be an owner, right?

Now, when doing /admins, you have to make a check like:
If pInfo[ID][pAdmin] == 9999
Then you have to write away "owner" instead of the normal admin level.

You still follow?

Stev
09/07/2015, 03:11 PM
I got this,

CMD:admins(playerid, params[])
{
SendClientMessage(playerid, COLOR_GREY, "Admins online:");
foreach(Player, i)
{
if(IsPlayerConnected(i))
{
if(pInfo[i][pAdmin] >= 1)
{
if(pInfo[i][pDuty] == true) // if player is onduty
{
if(pInfo[i][pNameAdmin] == true) // if player has his forumname on
{
SendClientMessageEx(playerid, COLOR_ORANGE,"(ID: %d) %s (%s) (Admin level: %d)", i, PlayerName(i),AdminRank(i), pInfo[i][pAdmin]);
}
else
{
SendClientMessageEx(playerid, COLOR_GREY,"(ID: %d) %s (Admin level: %d)", i, PlayerName(i), pInfo[i][pAdmin]);
}
}
}
}
}
return 1;
}

stock AdminRank(playerid)
{
new rank[30];
if(pInfo[playerid][Admin] == 1) rank = "Level 1 admin";
// Add what your levels are and when at the and "rank = 'RANK_HERE'"
return rank;
}

liquor
09/07/2015, 03:13 PM
CMD:admins(playerid,params[])
{
new Rank[16],str[64],pname[MAX_PLAYER_NAME];
SendClientMessage(playerid,-1,"Avaliable admins:");
foreach(Player,i)
{
if(pInfo[i][pAdmin] >= 1)
{
switch(pInfo[i][pAdmin])
{
case 1: Rank = "Moderator";
case 2: Rank = "Administrator";
case 3: Rank = "General Admin";
case 4: Rank = "Head Admin";
case 1337: Rank = "Leet";
case 1338: Rank = "Leet+1";
case 2015: Rank = "Thisyear";
case 9999: Rank = "Owner";
}
GetPlayerName(i,pname,sizeof(pname));
format(str,sizeof(str),"%s - %s",pname,Rank);
SendClientMessage(playerid,-1,str);
}
}
return 1;
}


This should work.

025Tadija
09/07/2015, 03:14 PM
Okay, look, so you admin level, its a number, right? We call it an integer.
Integers can only be a a full number, like -1, 0, 1 going into infinity.

"owner" is a word, so its a string.
You CANNOT store a string onto a variable that can only hold an integer.
So pInfo[ID][pAdmin] can only hold an integer.

Now to "trick" the system we just say, 9999 is for owners. So when pInfo[ID][pAdmin] is 9999 then it has to be an owner, right?

Now, when doing /admins, you have to make a check like:
If pInfo[ID][pAdmin] == 9999
Then you have to write away "owner" instead of the normal admin level.

You still follow?

Yeah, I got that, but I tried with that way and It always shows 9999
because I have this
if(pInfo[i][pAdmin] >= 1)
{
// here is the code for normal levels to like 1338
}

then I made like
else if(pInfo[i][pAdmin] == 9999)
{
.....


}

but It will always shows 9999 because I guess i need to create new enum like pInfo[i][pAdminOwner] ?

liquor
09/07/2015, 03:16 PM
Check my last reply :)

025Tadija
09/07/2015, 03:17 PM
I got this,

CMD:admins(playerid, params[])
{
SendClientMessage(playerid, COLOR_GREY, "Admins online:");
foreach(Player, i)
{
if(IsPlayerConnected(i))
{
if(pInfo[i][pAdmin] >= 1)
{
if(pInfo[i][pDuty] == true) // if player is onduty
{
if(pInfo[i][pNameAdmin] == true) // if player has his forumname on
{
SendClientMessageEx(playerid, COLOR_ORANGE,"(ID: %d) %s (%s) (Admin level: %d)", i, PlayerName(i),AdminRank(i), pInfo[i][pAdmin]);
}
else
{
SendClientMessageEx(playerid, COLOR_GREY,"(ID: %d) %s (Admin level: %d)", i, PlayerName(i), pInfo[i][pAdmin]);
}
}
}
}
}
return 1;
}

stock AdminRank(playerid)
{
new rank[30];
if(pInfo[playerid][Admin] == 1) rank = "Level 1 admin";
// Add what your levels are and when at the and "rank = 'RANK_HERE'"
return rank;
}


you just gave me half of my /admins command, because you removed something really important, check again my /admins command and read it carefully.

notime
09/07/2015, 03:17 PM
Yeah, I got that, but I tried with that way and It always shows 9999
because I have this
if(pInfo[i][pAdmin] >= 1)
{
// here is the code for normal levels to like 1338
}

then I made like
else if(pInfo[i][pAdmin] == 9999)
{
.....


}

but It will always shows 9999 because I guess i need to create new enum like pInfo[i][pAdminOwner] ?
Show me what you got at:
if(pInfo[i][pAdmin] >= 1)
{
// here is the code for normal levels to like 1338
}

Stev
09/07/2015, 03:18 PM
Youre not really explaining my to "what you really want" as notime said: Numbers = Int, words = string, If you dont want the level to show just the rank just remove the level from the command. and just show the rank "Owner"

025Tadija
09/07/2015, 03:24 PM
CMD:admins(playerid, params[])
{
SendClientMessage(playerid, COLOR_GREY, "Admins online:");
foreach(Player, i)
{
if(IsPlayerConnected(i))
{
if(pInfo[i][pAdmin] >= 1)
{
if(pInfo[i][pDuty] == true)
{
if(pInfo[i][pNameAdmin] == true)
{
SendClientMessageEx(playerid, COLOR_ORANGE,"(ID: %d) %s (%s) (Admin level: %d)", i, PlayerName(i),pInfo[i][pAdminName], pInfo[i][pAdmin]);
}

else
{
SendClientMessageEx(playerid, COLOR_ORANGE,"(ID: %d) %s (Admin level: %d)", i, PlayerName(i), pInfo[i][pAdmin]);
}

}

else
{

if(pInfo[i][pNameAdmin] == true)
{
SendClientMessageEx(playerid, COLOR_GREY,"(ID: %d) %s (%s) (Admin level: %d)", i, PlayerName(i),pInfo[i][pAdminName], pInfo[i][pAdmin]);
}

else
{
SendClientMessageEx(playerid, COLOR_GREY,"(ID: %d) %s (Admin level: %d)", i, PlayerName(i), pInfo[i][pAdmin]);
}

}
}
else if(pInfo[i][pAdminOwner] == 9999)
{
if(pInfo[i][pDuty] == true)
{
if(pInfo[i][pNameAdmin] == true)
{
SendClientMessageEx(playerid, COLOR_ORANGE,"(ID: %d) %s (%s) (Admin level: Owner)", i, PlayerName(i),pInfo[i][pAdminName]);
}

else
{
SendClientMessageEx(playerid, COLOR_ORANGE,"(ID: %d) %s (Admin level: Owner)", i, PlayerName(i));
}

}

else
{

if(pInfo[i][pNameAdmin] == true)
{
SendClientMessageEx(playerid, COLOR_GREY,"(ID: %d) %s (%s) (Admin level: Owner)", i, PlayerName(i),pInfo[i][pAdminName]);
}

else
{
SendClientMessageEx(playerid, COLOR_GREY,"(ID: %d) %s (Admin level: Owner)", i, PlayerName(i));
}

}
}
}
}
return 1;
}


this is how my new /admins command looks like and it works. It shows Owner in /admins