SA-MP Forums Archive
Admin Commands [Adminlevel] - 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: Admin Commands [Adminlevel] (/showthread.php?tid=574535)



Admin Commands [Adminlevel] - Zmith - 18.05.2015

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


Re: Admin Commands [Adminlevel] - ranme15 - 18.05.2015

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.


Re: Admin Commands [Adminlevel] - Zmith - 18.05.2015

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.




Re: Admin Commands [Adminlevel] - EBook - 18.05.2015

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
}



Re: Admin Commands [Adminlevel] - Threshold - 18.05.2015

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.


Re: Admin Commands [Adminlevel] - Zmith - 18.05.2015

Код:
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


Re: Admin Commands [Adminlevel] - Threshold - 18.05.2015

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?


Re: Admin Commands [Adminlevel] - Zmith - 18.05.2015

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


Re: Admin Commands [Adminlevel] - Threshold - 18.05.2015

So does the code work??


Re: Admin Commands [Adminlevel] - Zmith - 18.05.2015

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
....