Admin Commands [Adminlevel]
#1

Hi. I want to make commands display based on their admin level. First code is my current script, second code is my previous script.
I've tried copying the second code into the first but it caused errors at some other areas of the gamemode.
Код:
CMD:ahelp(playerid, params[])
{
    if(pInfo[playerid][Adminlevel] < 1)return SendClientMessage(playerid, COLOR_RED, "{ff6347}Error: You are not allowed to use this command!");
    SendClientMessage(playerid, COLOR_SERVER, "Age of Revolution {EAEAEA}- Admin Commands");
	SendClientMessage(playerid, COLOR_SERVER, "Trial Admin: {EAEAEA}/sp(ecoff), /cp, /(un)freeze, /slap, /warn, /kick, /tpto, /tptome, /(un)mute");
	SendClientMessage(playerid, COLOR_SERVER, "Basic Admin: {EAEAEA}/cchat, /burn, /mute, /ban, /ann, /setskin");
	SendClientMessage(playerid, COLOR_SERVER, "Senior Admin: {EAEAEA}/bomb, /hna, /settime, /givewep, /setweather, /sethealth, /disarm, /heal, /armour");
	SendClientMessage(playerid, COLOR_SERVER, "Head Admin: {EAEAEA}/akill, /resetscore, /resetmoney, /givemoney, /setscore, /makecmd");
	SendClientMessage(playerid, COLOR_SERVER, "Owner: {EAEAEA}/setadmin, /plantbomb");
	SendClientMessage(playerid, COLOR_RED,"Warning: {E5E5E5}Abuse these commands for unfair advantage you will be removed without question!");
	return 1;
}
Код:
   if(strcmp(cmd, "/acommands", true) == 0 || strcmp(cmd, "/ahelp", true) == 0)
	{
	    if(IsPlayerConnected(playerid))
	    {
 			if (PlayerInfo[playerid][pAdmin] >= 2)
            SendClientMessage(playerid,COLOR_GREY, "  ");
			SendClientMessage(playerid, COLOR_ADMIN,"> ADMIN {E5E5E5}COMMANDS");
			SendClientMessage(playerid,COLOR_GREY, "``````````````````````````````````````````````````````````````````");
			if (PlayerInfo[playerid][pAdmin] >= 2)
			{
				SendClientMessage(playerid, COLOR_WHITE," /ufa - /fa - /ann - /unfreeze - /freeze - /cp - /duty - /cc - /home");
			}
			if (PlayerInfo[playerid][pAdmin] >= 2)
			{
				SendClientMessage(playerid, COLOR_WHITE," /goto - /kick - /ban - /fix - /respawn - /tp - /getip - /cg");
			}
			if (PlayerInfo[playerid][pAdmin] >= 4)
			{
				SendClientMessage(playerid, COLOR_WHITE," /veh - /sethealth - /setarmour - /setskin - /disarm - /tpall - /jetpack");
			}
			if (PlayerInfo[playerid][pAdmin] >= 5)
			{
				SendClientMessage(playerid, COLOR_WHITE," /givecash - /setweather - /gmx - /setadmin - /servername");
			}
			if (PlayerInfo[playerid][pAdmin] >= 2)
			{
				SendClientMessage(playerid, COLOR_RED,"Warning: {E5E5E5}Abuse these commands for unfair advantage you will be removed without question!");

				}
		}
		return 1;
Attempt: http://puu.sh/hRpPf/2fc4c66044.png - http://pastebin.com/KHBFZQ2L
Reply
#2

You don't have to create a {} after every if. Use this:
http://pastebin.com/pSCPzsrb

If it still gives errors, show me your pInfo variable.
Reply
#3

It doesn't give errors, I actually tried that first before having to open my previous script.
I'm obviously admin-lvl 5 but when typing /ahelp it only gives me trial admin lvl commands.

Reply
#4

Quote:
Originally Posted by Zmith
Посмотреть сообщение
It doesn't give errors, I actually tried that first before having to open my previous script.
I'm obviously admin-lvl 5 but when typing /ahelp it only gives me trial admin lvl commands.

Try using "==" paramater instead of ">="

Example:
pawn Код:
if(playerinfo[playerid][pAdmin] == 5)
{
    // Do something here
}
edit:
whoops, my mistake , Forget the codes above

Try using ">" parameters only instead of ">="
Example:
pawn Код:
if(playerinfo[playerid][pAdmin] > 5)
{
    // Do something here
}
Reply
#5

pawn Код:
CMD:ahelp(playerid, params[])
{
    new var = pInfo[playerid][Adminlevel]; // I just don't wanna keep typing this out :P
    if(!var) return SendClientMessage(playerid, COLOR_RED, "{ff6347}Error: You are not allowed to use this command!");
    SendClientMessage(playerid, COLOR_SERVER, "Age of Revolution {EAEAEA}- Admin Commands");
    if(var >= 1) SendClientMessage(playerid, COLOR_SERVER, "Trial Admin: {EAEAEA}/sp(ecoff), /cp, /(un)freeze, /slap, /warn, /kick, /tpto, /tptome, /(un)mute");
    if(var >= 2) SendClientMessage(playerid, COLOR_SERVER, "Basic Admin: {EAEAEA}/cchat, /burn, /mute, /ban, /ann, /setskin");
    if(var >= 3) SendClientMessage(playerid, COLOR_SERVER, "Senior Admin: {EAEAEA}/bomb, /hna, /settime, /givewep, /setweather, /sethealth, /disarm, /heal, /armour");
    if(var >= 4) SendClientMessage(playerid, COLOR_SERVER, "Head Admin: {EAEAEA}/akill, /resetscore, /resetmoney, /givemoney, /setscore, /makecmd");
    if(var >= 5) SendClientMessage(playerid, COLOR_SERVER, "Owner: {EAEAEA}/setadmin, /plantbomb");
    SendClientMessage(playerid, COLOR_RED, "Warning: {E5E5E5}If you abuse these commands for unfair advantage, you will be removed without question!");
    return 1;
}

CMD:acommands(playerid, params[]) return cmd_ahelp(playerid, params);
You should not be using two different methods to process commands.
Reply
#6

Код:
CMD:ahelp(playerid, params[])
{
    if(pInfo[playerid][Adminlevel] < 1)return SendClientMessage(playerid, COLOR_RED, "{ff6347}Error: You are not allowed to use this command!");
    SendClientMessage(playerid, COLOR_SERVER, "Age of Revolution {EAEAEA}- Admin Commands");
	SendClientMessage(playerid, COLOR_SERVER, "Trial Admin: {EAEAEA}/sp(off), /cp, /(un)freeze, /slap, /warn, /kick, /tpto, /tptome, /(un)mute");
	if(pInfo[playerid][Adminlevel] == 2)
	SendClientMessage(playerid, COLOR_SERVER, "Basic Admin: {EAEAEA}/cchat, /burn, /mute, /ban, /ann, /setskin");
    if(pInfo[playerid][Adminlevel] == 3)
	SendClientMessage(playerid, COLOR_SERVER, "Senior Admin: {EAEAEA}/bomb, /hna, /settime, /givewep, /setweather, /sethealth, /disarm, /heal, /armour");
	if(pInfo[playerid][Adminlevel] == 4)
	SendClientMessage(playerid, COLOR_SERVER, "Head Admin: {EAEAEA}/akill, /resetscore, /resetmoney, /givemoney, /setscore, /makecmd");
	if(pInfo[playerid][Adminlevel] == 5)
	SendClientMessage(playerid, COLOR_SERVER, "Owner: {EAEAEA}/setadmin, /plantbomb");
	if(pInfo[playerid][Adminlevel] == 1)
	SendClientMessage(playerid, COLOR_RED,"Warning: {E5E5E5}Abuse these commands for unfair advantage you will be removed without question!");
	return 1;
}
I've just tried this and now it's showing them individually by their admin lvl. (see "Currently:" below for example)
I want it to be such as;

- Adminlevel 1 (can see) = Adminlevel 1 commands
- Adminlevel 2 (can see) = Adminlevel 1&2 commands
- Adminlevel 3 (can see) = Adminlevel 1&2&3 commands
- Adminlevel 4 (can see) = Adminlevel 1&2&3&4 commands
- Adminlevel 5 (can see) = Adminlevel 1&2&3&4&5 commands

Currently:
- Adminlevel 1 (can see) = Adminlevel 1 commands
- Adminlevel 2 (can see) = Adminlevel 2 commands
- Adminlevel 3 (can see) = Adminlevel 3 commands
- Adminlevel 4 (can see) = Adminlevel 4 commands
- Adminlevel 5 (can see) = Adminlevel 5 commands

Previously:
- Adminlevel 1 (can see) = Adminlevel 1&2&3&4&5 commands
- Adminlevel 2 (can see) = Adminlevel 1&2&3&4&5 commands
- Adminlevel 3 (can see) = Adminlevel 1&2&3&4&5 commands
- Adminlevel 4 (can see) = Adminlevel 1&2&3&4&5 commands
- Adminlevel 5 (can see) = Adminlevel 1&2&3&4&5 commands
Reply
#7

Quote:
Originally Posted by Threshold
Посмотреть сообщение
pawn Код:
CMD:ahelp(playerid, params[])
{
    new var = pInfo[playerid][Adminlevel]; // I just don't wanna keep typing this out :P
    if(!var) return SendClientMessage(playerid, COLOR_RED, "{ff6347}Error: You are not allowed to use this command!");
    SendClientMessage(playerid, COLOR_SERVER, "Age of Revolution {EAEAEA}- Admin Commands");
    if(var >= 1) SendClientMessage(playerid, COLOR_SERVER, "Trial Admin: {EAEAEA}/sp(ecoff), /cp, /(un)freeze, /slap, /warn, /kick, /tpto, /tptome, /(un)mute");
    if(var >= 2) SendClientMessage(playerid, COLOR_SERVER, "Basic Admin: {EAEAEA}/cchat, /burn, /mute, /ban, /ann, /setskin");
    if(var >= 3) SendClientMessage(playerid, COLOR_SERVER, "Senior Admin: {EAEAEA}/bomb, /hna, /settime, /givewep, /setweather, /sethealth, /disarm, /heal, /armour");
    if(var >= 4) SendClientMessage(playerid, COLOR_SERVER, "Head Admin: {EAEAEA}/akill, /resetscore, /resetmoney, /givemoney, /setscore, /makecmd");
    if(var >= 5) SendClientMessage(playerid, COLOR_SERVER, "Owner: {EAEAEA}/setadmin, /plantbomb");
    SendClientMessage(playerid, COLOR_RED, "Warning: {E5E5E5}If you abuse these commands for unfair advantage, you will be removed without question!");
    return 1;
}

CMD:acommands(playerid, params[]) return cmd_ahelp(playerid, params);
You should not be using two different methods to process commands.
Did you completely ignore my post?
Reply
#8

It's two different gamemodes. They're not in the same script.
Reply
#9

So does the code work??
Reply
#10

Quote:
Originally Posted by Zmith
Посмотреть сообщение
Код:
CMD:ahelp(playerid, params[])
{
    if(pInfo[playerid][Adminlevel] < 1)return SendClientMessage(playerid, COLOR_RED, "{ff6347}Error: You are not allowed to use this command!");
    SendClientMessage(playerid, COLOR_SERVER, "Age of Revolution {EAEAEA}- Admin Commands");
	SendClientMessage(playerid, COLOR_SERVER, "Trial Admin: {EAEAEA}/sp(off), /cp, /(un)freeze, /slap, /warn, /kick, /tpto, /tptome, /(un)mute");
	if(pInfo[playerid][Adminlevel] == 2)
	SendClientMessage(playerid, COLOR_SERVER, "Basic Admin: {EAEAEA}/cchat, /burn, /mute, /ban, /ann, /setskin");
    if(pInfo[playerid][Adminlevel] == 3)
	SendClientMessage(playerid, COLOR_SERVER, "Senior Admin: {EAEAEA}/bomb, /hna, /settime, /givewep, /setweather, /sethealth, /disarm, /heal, /armour");
	if(pInfo[playerid][Adminlevel] == 4)
	SendClientMessage(playerid, COLOR_SERVER, "Head Admin: {EAEAEA}/akill, /resetscore, /resetmoney, /givemoney, /setscore, /makecmd");
	if(pInfo[playerid][Adminlevel] == 5)
	SendClientMessage(playerid, COLOR_SERVER, "Owner: {EAEAEA}/setadmin, /plantbomb");
	if(pInfo[playerid][Adminlevel] == 1)
	SendClientMessage(playerid, COLOR_RED,"Warning: {E5E5E5}Abuse these commands for unfair advantage you will be removed without question!");
	return 1;
}
I've just tried this and now it's showing them individually by their admin lvl. (see "Currently:" below for example)
I want it to be such as;

- Adminlevel 1 (can see) = Adminlevel 1 commands
- Adminlevel 2 (can see) = Adminlevel 1&2 commands
- Adminlevel 3 (can see) = Adminlevel 1&2&3 commands
- Adminlevel 4 (can see) = Adminlevel 1&2&3&4 commands
- Adminlevel 5 (can see) = Adminlevel 1&2&3&4&5 commands

Currently:
- Adminlevel 1 (can see) = Adminlevel 1 commands
- Adminlevel 2 (can see) = Adminlevel 2 commands
- Adminlevel 3 (can see) = Adminlevel 3 commands
- Adminlevel 4 (can see) = Adminlevel 4 commands
- Adminlevel 5 (can see) = Adminlevel 5 commands

Previously:
- Adminlevel 1 (can see) = Adminlevel 1&2&3&4&5 commands
- Adminlevel 2 (can see) = Adminlevel 1&2&3&4&5 commands
- Adminlevel 3 (can see) = Adminlevel 1&2&3&4&5 commands
- Adminlevel 4 (can see) = Adminlevel 1&2&3&4&5 commands
- Adminlevel 5 (can see) = Adminlevel 1&2&3&4&5 commands
....
Reply


Forum Jump:


Users browsing this thread: 5 Guest(s)