How to short this?
#1

I have this long code but how do I make it shorter -_-

Код:
CMD:ah(playerid, params[]) return cmd_ahelp(playerid, params);
CMD:ahelp(playerid, params[])
{
	if(PlayerInfo[playerid][pAdminLevel] == 1)
	{
	    SendClientMessage(playerid, COLOR_YELLOW, "==============================");
	    SendClientMessage(playerid, COLOR_WHITE, "Level 1: /slap, /gethere");
	    SendClientMessage(playerid, COLOR_WHITE, "Level 1: /slay");
	    SendClientMessage(playerid, COLOR_WHITE, "Level 1: /spec, /specoff");
	    SendClientMessage(playerid, COLOR_WHITE, "Level 1: /gotoplace, /goto");
	    SendClientMessage(playerid, COLOR_WHITE, "Level 1: /killcar");
	    SendClientMessage(playerid, COLOR_YELLOW, "==============================");
	}
	if(PlayerInfo[playerid][pAdminLevel] == 2)
	{
	    SendClientMessage(playerid, COLOR_YELLOW, "==============================");
	    SendClientMessage(playerid, COLOR_WHITE, "Level 1: /slap, /gethere");
	    SendClientMessage(playerid, COLOR_WHITE, "Level 1: /slay");
	    SendClientMessage(playerid, COLOR_WHITE, "Level 1: /spec, /specoff");
	    SendClientMessage(playerid, COLOR_WHITE, "Level 1: /gotoplace, /goto");
	    SendClientMessage(playerid, COLOR_WHITE, "Level 2: /announce, /warn, /kick");
	    SendClientMessage(playerid, COLOR_YELLOW, "==============================");
	    
	}
	if(PlayerInfo[playerid][pAdminLevel] == 3)
	{
	    SendClientMessage(playerid, COLOR_YELLOW, "==============================");
	    SendClientMessage(playerid, COLOR_WHITE, "Level 1: /slap, /gethere");
	    SendClientMessage(playerid, COLOR_WHITE, "Level 1: /slay");
	    SendClientMessage(playerid, COLOR_WHITE, "Level 1: /spec, /specoff");
	    SendClientMessage(playerid, COLOR_WHITE, "Level 1: /gotoplace, /goto");
	    SendClientMessage(playerid, COLOR_WHITE, "Level 2: /announce, /warn, /kick");
	    SendClientMessage(playerid, COLOR_WHITE, "Level 3: /ban");
	    SendClientMessage(playerid, COLOR_YELLOW, "==============================");
	    return 1;
	}
	if(PlayerInfo[playerid][pAdminLevel] == 4)
	{
	    SendClientMessage(playerid, COLOR_YELLOW, "==============================");
	    SendClientMessage(playerid, COLOR_WHITE, "Level 1: /slap, /gethere");
	    SendClientMessage(playerid, COLOR_WHITE, "Level 1: /slay");
	    SendClientMessage(playerid, COLOR_WHITE, "Level 1: /spec, /specoff");
	    SendClientMessage(playerid, COLOR_WHITE, "Level 1: /gotoplace, /goto");
	    SendClientMessage(playerid, COLOR_WHITE, "Level 2: /announce, /warn, /kick");
	    SendClientMessage(playerid, COLOR_WHITE, "Level 3: /ban");
	    SendClientMessage(playerid, COLOR_WHITE, "Level 4: /givemoney, /givegun ");
	    SendClientMessage(playerid, COLOR_WHITE, "Level 4: /sethp, /setarmour");
	    SendClientMessage(playerid, COLOR_WHITE, "Level 4: /setscore, /v");
	    SendClientMessage(playerid, COLOR_WHITE, "Level 4: /respawncars");
	    SendClientMessage(playerid, COLOR_YELLOW, "==============================");
	    return 1;
	}
	if(PlayerInfo[playerid][pAdminLevel] == 5)
	{
	    SendClientMessage(playerid, COLOR_YELLOW, "==============================");
	    SendClientMessage(playerid, COLOR_WHITE, "Level 1: /slap, /gethere");
	    SendClientMessage(playerid, COLOR_WHITE, "Level 1: /slay");
	    SendClientMessage(playerid, COLOR_WHITE, "Level 1: /spec, /specoff");
	    SendClientMessage(playerid, COLOR_WHITE, "Level 1: /gotoplace, /goto");
	    SendClientMessage(playerid, COLOR_WHITE, "Level 2: /announce, /warn, /kick");
	    SendClientMessage(playerid, COLOR_WHITE, "Level 3: /ban");
	    SendClientMessage(playerid, COLOR_WHITE, "Level 4: /givemoney, /givegun ");
	    SendClientMessage(playerid, COLOR_WHITE, "Level 4: /sethp, /setarmour");
	    SendClientMessage(playerid, COLOR_WHITE, "Level 4: /setscore, /v");
	    SendClientMessage(playerid, COLOR_WHITE, "Level 5: /restartserver, /setadmin");
	    SendClientMessage(playerid, COLOR_YELLOW, "==============================");
	    return 1;
	}
	if(PlayerInfo[playerid][pAdminLevel] == 6)
	{
	    SendClientMessage(playerid, COLOR_YELLOW, "==============================");
	    SendClientMessage(playerid, COLOR_WHITE, "Level 1: /slap, /gethere");
	    SendClientMessage(playerid, COLOR_WHITE, "Level 1: /slay");
	    SendClientMessage(playerid, COLOR_WHITE, "Level 1: /spec, /specoff");
	    SendClientMessage(playerid, COLOR_WHITE, "Level 1: /gotoplace, /goto");
	    SendClientMessage(playerid, COLOR_WHITE, "Level 2: /announce, /warn, /kick");
	    SendClientMessage(playerid, COLOR_WHITE, "Level 3: /ban");
	    SendClientMessage(playerid, COLOR_WHITE, "Level 4: /givemoney, /givegun ");
	    SendClientMessage(playerid, COLOR_WHITE, "Level 4: /sethp, /setarmour");
	    SendClientMessage(playerid, COLOR_WHITE, "Level 4: /setscore, /v");
	    SendClientMessage(playerid, COLOR_WHITE, "Level 5: /restartserver, /setadmin");
	    SendClientMessage(playerid, COLOR_YELLOW, "==============================");
	}
	if(PlayerInfo[playerid][pAdminLevel] == 7)
	{
	    SendClientMessage(playerid, COLOR_YELLOW, "==============================");
	    SendClientMessage(playerid, COLOR_WHITE, "Level 1: /slap, /gethere");
	    SendClientMessage(playerid, COLOR_WHITE, "Level 1: /slay");
	    SendClientMessage(playerid, COLOR_WHITE, "Level 1: /spec, /specoff");
	    SendClientMessage(playerid, COLOR_WHITE, "Level 1: /gotoplace, /goto");
	    SendClientMessage(playerid, COLOR_WHITE, "Level 2: /announce, /warn, /kick");
	    SendClientMessage(playerid, COLOR_WHITE, "Level 3: /ban");
	    SendClientMessage(playerid, COLOR_WHITE, "Level 4: /givemoney, /givegun ");
	    SendClientMessage(playerid, COLOR_WHITE, "Level 4: /sethp, /setarmour");
	    SendClientMessage(playerid, COLOR_WHITE, "Level 4: /setscore, /v");
	    SendClientMessage(playerid, COLOR_WHITE, "Level 5: /restartserver, /setadmin");
	    SendClientMessage(playerid, COLOR_WHITE, "Level 7: /banofflineplayer");
	    SendClientMessage(playerid, COLOR_YELLOW, "==============================");
	}
	return 1;
}
Reply
#2

This has not been tested, but it should work:

pawn Код:
CMD:ah(playerid, params[]) return cmd_ahelp(playerid, params);
CMD:ahelp(playerid, params[])
{
    if(PlayerInfo[playerid][pAdminLevel] <= 0) return 0;
    SendClientMessage(playerid, COLOR_YELLOW, "==============================");
    if(PlayerInfo[playerid][pAdminLevel] >= 1)
    {
        SendClientMessage(playerid, COLOR_WHITE, "Level 1: /slap, /gethere");
        SendClientMessage(playerid, COLOR_WHITE, "Level 1: /slay");
        SendClientMessage(playerid, COLOR_WHITE, "Level 1: /spec, /specoff");
        SendClientMessage(playerid, COLOR_WHITE, "Level 1: /gotoplace, /goto");
        SendClientMessage(playerid, COLOR_WHITE, "Level 1: /killcar");
    }
    if(PlayerInfo[playerid][pAdminLevel] >= 2)
    {
        SendClientMessage(playerid, COLOR_WHITE, "Level 2: /announce, /warn, /kick");
    }
    if(PlayerInfo[playerid][pAdminLevel] >= 3)
    {
        SendClientMessage(playerid, COLOR_WHITE, "Level 3: /ban");
    }
    if(PlayerInfo[playerid][pAdminLevel] >= 4)
    {
        SendClientMessage(playerid, COLOR_WHITE, "Level 4: /givemoney, /givegun ");
        SendClientMessage(playerid, COLOR_WHITE, "Level 4: /sethp, /setarmour");
        SendClientMessage(playerid, COLOR_WHITE, "Level 4: /setscore, /v");
        SendClientMessage(playerid, COLOR_WHITE, "Level 4: /respawncars");
    }
    if(PlayerInfo[playerid][pAdminLevel] >= 5)
    {
        SendClientMessage(playerid, COLOR_WHITE, "Level 5: /restartserver, /setadmin");
    }
    if(PlayerInfo[playerid][pAdminLevel] >= 6)
    {
        // Level 6 doesn't have any priority commands?
    }
    if(PlayerInfo[playerid][pAdminLevel] >= 7)
    {
        SendClientMessage(playerid, COLOR_WHITE, "Level 7: /banofflineplayer");
    }
    SendClientMessage(playerid, COLOR_YELLOW, "==============================");
    return 1;
}
Reply
#3

Maybe write more then 1 or 2 commands per SCM.
Reply
#4

Thank ya'll!
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)