Command like /help 1 /help 2 /help 3?
#1

Hello,

I want to know how to make a command for example:

/help 1 --> will give me smth
/help 2 --> will give me other things

without doing a command like /help1 and /help2 .. So if I type

/help it says

Choose /help 1/2/3 etc..

as I remember it's about making cases?
Reply
#2

zcmd + sscanf.
Reply
#3

Yes, but give me a way?
Reply
#4

An example using level/1/2/3/4/5
Using dcmd

pawn Код:
dcmd_level(playerid,params[])
{
    if(AccInfo[playerid][Level] >= 2)//You can change it to 0. Everybody will be able to type this cmd!
    {
        if(!strlen(params))
        {
        SendClientMessage(playerid, aqua, "Usage: /help [1/2/3/4/5]");
        return SendClientMessage(playerid, white, "Function: Will see commands of specified level");
        }
        //======================================================================
        // Level 1
        //======================================================================
        if(strcmp(params,"1",true) == 0)
        {
        if(AccInfo[playerid][Level] >= 2)//here too
        {
        SendClientMessage(playerid, white, "Trial Admin");
        SendClientMessage(playerid,0x53D212FF,"Player: getinfo, weaps, ping, ip, ");
        SendClientMessage(playerid,0x33F666FF,"Vehicle: fix, repair, addnos, tcar");
        SendClientMessage(playerid,0x53D212FF,"Tele: saveplacae, gotoplace");
        SendClientMessage(playerid,0x33F666FF,"Adm: onduty, saveskin, useskin, dontuseskin, setmytime, adminarea");
        SendClientMessage(playerid,0x53D212FF,"Other: lconfig, viplist, morning, reports, richlist, miniguns");
        }
            else return ErrorMessages(playerid, 8);
        }
        //======================================================================
        // Level 2
        //======================================================================
        else if(strcmp(params,"2",true) == 0)
        {
        if(AccInfo[playerid][Level] >= 2)//here too
        {
        SendClientMessage(playerid, white, "___________ |- LuxAdmin - Moderator (Level 2) -| ___________");
        SendClientMessage(playerid, orange, "+ Level 1 commands.");
        SendClientMessage(playerid,0x53D212FF,"Player: giveweapon, setcolour, burn, spawn, disarm, highlight, jetpack, flip, fu");
        SendClientMessage(playerid,0x33F666FF,"Player: warn, slap, (un)mute, laston, lspec, lspecoff");
        SendClientMessage(playerid,0x53D212FF,"Vehicle: acar, abike, aheli, aboat, aplane, lspecvehicle");
        SendClientMessage(playerid,0x33F666FF,"Tele: goto, vgoto, lgoto");
        SendClientMessage(playerid,0x53D212FF,"Adm: lmenu, clearchat, write, announce, announce2, screen, (un)lockcar");
        SendClientMessage(playerid,0x33F666FF,"Other: wanted, jailed, frozen, muted, fstyles");
        }
            else return ErrorMessages(playerid, 7);
        }
        //======================================================================
        // Level 3
        //======================================================================
        else if(strcmp(params,"3",true) == 0)
        {
        if(AccInfo[playerid][Level] >= 3)//here too
        {
        SendClientMessage(playerid, white, "___________ |- LuxAdmin - Master Moderator (Level 3) -| ___________");
        SendClientMessage(playerid, orange, "+ Level 1 and 2 commands.");
        SendClientMessage(playerid,0x53D212FF,"Set: set(health/armour/cash/score/skin/wanted/name/weather/time/world/interior/ping/gravity)");
        SendClientMessage(playerid,0x33F666FF,"All: setallskin, armourall, setallskin, setallwanted, setallweather, setalltime, setallworld");
        SendClientMessage(playerid,0x53D212FF,"All: setallscore, setallcash, giveallcash, giveallweapon, clearallchat, healall, disablechat");
        SendClientMessage(playerid,0x33F666FF,"Player: ubound, duel, akill, aka, caps,(un)freeze, kick, explode,(un)jail, force, eject, (s)removecash");
        SendClientMessage(playerid,0x53D212FF,"Vehicle: car, carhealth, carcolour, destroycar, vget, givecar");
        SendClientMessage(playerid,0x33F666FF,"Tele: teleplayer, gethere, get, move, moveplayer");
        SendClientMessage(playerid,0x53D212FF,"Other: gps, lcam, setpass, lammo, countdown, aweaps, invisible, visible");
        }
            else return ErrorMessages(playerid, 6);
        }
        //======================================================================
        // Level 4
        //======================================================================
        else if(strcmp(params,"4",true) == 0)
        {
        if(AccInfo[playerid][Level] >= 4)//here too
        {
        SendClientMessage(playerid, white, "___________ |- LuxAdmin - Administrator (Level 4) -| ___________");
        SendClientMessage(playerid, orange, "+ Level 1,2 and 3 commands.");
        SendClientMessage(playerid,0x53D212FF,"All: spawnall, muteall, unmuteall, getall, killall, freezeall, unfreezeall");
        SendClientMessage(playerid,0x33F666FF,"All: kickall, slapalll, explodeall, disarmall, ejectall");
        SendClientMessage(playerid,0x53D212FF,"Player: cage, ban, rban, tempban, settemplevel, crash");
        SendClientMessage(playerid,0x33F666FF,"Adm: ctele, lockserver, enable, disable, spam, god, godcar, botcheck, forbidname, forbidword, fakedeath");
        SendClientMessage(playerid,0x53D212FF,"Other: uconfig, die, hide, unhide");
        }
            else return ErrorMessages(playerid, 5);
        }
        //======================================================================
        // Level 5
        //======================================================================
        else if(strcmp(params,"5",true) == 0)
        {
        if(AccInfo[playerid][Level] >= 5)//here too
        {
        SendClientMessage(playerid, white, "___________ |- LuxAdmin - Master Administrator (Level 5) -| ___________");
        SendClientMessage(playerid, orange, "+ Level 1,2,3 and 4 commands.");
        SendClientMessage(playerid, orange, "+ Level 5 is Immune for all commands");
        SendClientMessage(playerid,0x53D212FF,"Player: setlevel, fakechat, fakedeath, fakecmd");
        SendClientMessage(playerid,0x33F666FF,"Adm: god, sgod, console");
        SendClientMessage(playerid,0x53D212FF,"Other: pickup, object, respawncars");
        SendClientMessage(playerid,0x53D212FF,"Rcon: lrcon (Only Rcon Admins) (Use: /rcon lrcon)");
        }
            else return ErrorMessages(playerid, 9);
        }
        //======================================================================
        else
        {
        SendClientMessage(playerid, red, "ERROR: Invalid Level! (1-5)");
        }
        return 1;
    }
    else return ErrorMessages(playerid, 1);
}
//BELOW

dcmd(level,5,cmdtext);
I found it on LuxAdmin!
Reply
#5

Код:
CMD:help(playerid, params[])
{
		SendClientMessageEx(playerid, COLOR_WHITE, "TEXT");
		SendClientMessageEx(playerid, COLOR_GREY,  "TEXT");
		return 1;
	}
	if(strcmp(params, "1", true) == 0) 
	{
                SendClientMessageEx(playerid,COLOR_WHITE, "TEXT");
               }
	}
	else if(strcmp(params, "2", true) == 0)
	{
               
                 SendClientMessageEx(playerid,COLOR_RED,"TEXT");
		}
	}
	return 1;
}
Something like this?
Reply
#6

No need for cases; use options.

DCMD Example:

PHP код:
dcmd_help(playeridparams[])
{
    new 
option[50];
    if(
sscanf(params,"s"option))
    {
       
SendClientMessage(playerid,c_white,"Account help - /help one");
       
SendClientMessage(playerid,c_white,"Account help - /help two");
       return 
1;
    }
    if(
strcmp(option,"one",true) == 0)
    {
       
SendClientMessage(playerid,c_green,"|________Account Help________|");
       
SendClientMessage(playerid,c_white,"your text");
    }
    if(
strcmp(option,"two",true) == 0)
    {
     
SendClientMessage ... etc 
Reply
#7

pawn Код:
CMD:help(playerid, params[]) // command /help
{
    new part;
    if(!sscanf(params, "i", part))
    {
        switch(part)
        {
            case 1: // for page 1
            {
                SendClientMessage(playerid, 0xFFFFFFFF, "Page 1");
            }
            case 2: // for page 2
            {
                SendClientMessage(playerid, 0xFFFFFFFF, "Page 2");
            }
            default: // if the page is not valid
            {
                SendClientMessage(playerid, 0xFFFFFFFF, "Invalid Page Number! Valid Ones: 1 , 2");
            }
        }
    }
    else // if player didnt enter any number
    {
        SendClientMessage(playerid, 0xFFFFFFFF, "Usage: /help [page]");
    }
    return 1;
}
Reply
#8

Here goes mine, just saw now you asked for a example.

pawn Код:
CMD:help(playerid, params[])
{
    new number;
    if(sscanf(params, "i", number)) return SendClientMessage(playerid,-1,"/help 0-3");
    if(0 > number > 3) return SendClientMessage(playerid,-1,"0 - 3");
    if(number == 0)
    {
    // functions
    }
    else if(number == 1)
    {
    // functions
    }
    else if(number == 2)
    {
    // functions
    }
    else if(number == 3)
    {
    // functions
    }
    return 1;
}
Reply
#9

Oh, thanks a lot guys, I'll be testing all these epic ones
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)