Help menu, shows same line over and over
#1

Hey guys, so I have got a menu, which will choose each category, like "/help account" or /help vehicle. and so on.

this is the full code:
PHP код:
CMD:help(playeridparams[])
{
    if (!
strcmp(params"general"true))
    {
    
SendClientMessage(playeridCOLOR_NICEYELLOW". : : General commands : : .");
       
SendClientMessage(playeridCOLOR_NICEBLUE"/stats, /report, /helpme, /acc, /me, /do, /(s)hout, /(o)oc, /inventory, /switch.");
    
SendClientMessage(playeridCOLOR_NICELBLUE"/approve, /faq, /sell, /paint, /drink, /bank, /cook, /vest, /ammo, /usekit, /phone.");
    
SendClientMessage(playeridCOLOR_NICEBLUE"/id, /call, /hangup, /text, /drop, /flist, /crates, /fill, /pay, /gps, /open, /usedrug.");
    
SendClientMessage(playeridCOLOR_NICELBLUE"/animcmds, /backpack, /boombox, /channel, /jobcmds, /supporters, /disablecp, /stopanim.");
    
SendClientMessage(playeridCOLOR_NICEBLUE"/shakehand, /showlicense, /frisk, /toghud, /passwep, /setradio, /picklock, /resetvw. /factionhelp.");
    }
    if (!
strcmp(params"account"true))
    {
    
SendClientMessage(playeridCOLOR_NICEYELLOW". : : Account Commands : : .");
    
SendClientMessage(playeridCOLOR_NICEBLUE"/changepass, /lastlogged, /username, /properties.");
    }
    if (!
strcmp(params"vehicle"true))
    {
    
SendClientMessage(playeridCOLOR_NICEYELLOW". : : Vehicle Commands : : .");
    
SendClientMessage(playeridCOLOR_NICEBLUE"/park, /lock, /abandon, /refuel, /unmod, /trunk, /listcars, /engine, /lights, /hood, /tow.");
    }
    if (!
strcmp(params"business"true))
    {
    
SendClientMessage(playeridCOLOR_NICEYELLOW". : : Business Commands : : .");
    
SendClientMessage(playeridCOLOR_NICEBLUE"/buy, /abandon, /lock, /vault, /products, /binfo, /bname, /bmessage, /bshipment.");
    }
    if (!
strcmp(params"house"true))
    {
    
SendClientMessage(playeridCOLOR_NICEYELLOW". : : House Commands : : .");
       
SendClientMessage(playeridCOLOR_NICEBLUE"/buy, /abandon, /lock, /storage, /furniture, /buyrack, /gunrack, /deleterack.");
    
SendClientMessage(playeridCOLOR_NICEBLUE"/doorbell, /switch.");
    }
    if (!
strcmp(params"property"true))
    {
    
SendClientMessage(playeridCOLOR_NICEYELLOW". : : Property Commands : : .");
    
SendClientMessage(playeridCOLOR_NICEBLUE"/buy, /abandon, /lock, /housecmds, /products, /vault, /binfo, /bizcmds.");
    }
    if (!
strcmp(params"Helper"true))
    {
    if (!
PlayerData[playerid][pTester]) { return SendClientMessage(playeridCOLOR_NICEBLUE"SERVER: You cannot use this command");
    }
    
SendClientMessage(playeridCOLOR_NICEYELLOW". : : Helper Commands : : .");
    
SendClientMessage(playeridCOLOR_NICEBLUE"/t, /tduty, /ah, /dh, /kick");
    }
    else if (!
strcmp(params"admin"true))
    {
    if (!
PlayerData[playerid][pAdmin]) { return SendClientMessage(playeridCOLOR_NICEBLUE"SERVER: You cannot use this command");
    }
    
SendClientMessage(playeridCOLOR_NICEYELLOW". : : Administrator Commands : : .");
    if (
PlayerData[playerid][pAdmin] >= 1) {
        
SendClientMessage(playeridCOLOR_NICEBLUE"/a, /reports, /spectate, /ajail, /release, /kick, /mute, /unmute, /freeze, /unfreeze.");
        
SendClientMessage(playeridCOLOR_NICELBLUE"/aduty, /ban, /skin /goto /aremovecall");
    }
    if (
PlayerData[playerid][pAdmin] >= 2) {
        
SendClientMessage(playeridCOLOR_NICEBLUE"/respawn, /warn, /checkstats, /shooter, /goto, /bring, /setinterior, /setvw.");
        
SendClientMessage(playeridCOLOR_NICELBLUE"/sendto, /clearchat, /spawn, /refill, /revive, /aslap, /acceptname, /declinename, /atalk.");
        
SendClientMessage(playeridCOLOR_NICEBLUE"/masked, /listguns, /respawncar, /respawncars, /respawnnear, /heal, /bringcar, /gotocar.");
        
SendClientMessage(playeridCOLOR_NICELBLUE"/x /y /z");
     }
    if (
PlayerData[playerid][pAdmin] >= 3) {
        
SendClientMessage(playeridCOLOR_NICEBLUE"/unban, /blacklist, /getip, /togooc, /health, /armor, /resetweps, /arepair, /listwarns.");
        
SendClientMessage(playeridCOLOR_NICELBLUE"/entercar, /flipcar, /veh, /destroyveh, /near, /healall, /tracenumber, /bleeding.");
        
SendClientMessage(playeridCOLOR_NICEBLUE"/atune, /acolorcar, /apaintjob, /afire, /akillfire, /adestroybox.");
    }
    if (
PlayerData[playerid][pAdmin] >= 4) {
        
SendClientMessage(playeridCOLOR_NICEBLUE"/givewep, /settester, /baninfo, /setname, /asetfaction, /asetrank, /setitem.");
        
SendClientMessage(playeridCOLOR_NICELBLUE"/asellhouse, /asellbiz, /jetpack, /setweather, /setfuel, /setcarhp, /spawnitem.");
        
SendClientMessage(playeridCOLOR_NICEBLUE"/setquantity, /destroyitem, /setplayer, /setleader, /setinventory, /givecar.");
    }
    if (
PlayerData[playerid][pAdmin] >= 5) {
        
SendClientMessage(playeridCOLOR_NICELBLUE"/dynamichelp, /givecash, /clearinventory, /clearwarns, /saveall, /restart.");
    }
    if (
PlayerData[playerid][pAdmin] >= 6) {
        
SendClientMessage(playeridCOLOR_NICEBLUE"/makeadmin, /deleteaccount, /deletechar, /factionmod, /panel.");
    }
    }
    else
    {
        
SendClientMessage(playeridCOLOR_NICEYELLOW". : : Help List : : .");
        
SendClientMessage(playeridCOLOR_NICEBLUE"TIP: /help [name]");
        
SendClientMessage(playeridCOLOR_NICEBLUE"Names: General, Account, Vehicle, Business, House , Property, Helper, Admin");
    }
    return 
1;

But it keeps to repeat the same three last lines -

PHP код:
 SendClientMessage(playeridCOLOR_NICEYELLOW". : : Help List : : .");
        
SendClientMessage(playeridCOLOR_NICEBLUE"TIP: /help [name]");
        
SendClientMessage(playeridCOLOR_NICEBLUE"Names: General, Account, Vehicle, Business, House , 
when I choose an option, it shows these lines again and again.
how do I do only when I type /help or /help without a category name such as /help misc
it will show these there lines above ^
tried few ways, still the same.
Reply
#2

I'd suggest you to use sscanf.

http://pastebin.com/7fBrCa4H

You will need to use sscanf include for that. It has not been tested ^.
Reply
#3

Quote:
Originally Posted by Private200
Посмотреть сообщение
I'd suggest you to use sscanf.

http://pastebin.com/7fBrCa4H

You will need to use sscanf include for that. It has not been tested ^.
Now when I do /help, it writes all the lines plus "Unknown Command" instead of categories.
Reply
#4

pawn Код:
#define isnull(%1) ((!(%1[0])) || (((%1[0]) == '\1') && (!(%1[1]))))

CMD:help(playerid, params[])
{
    if(isnull(params)) return SendClientMessage(playerid, -1, "Usage: /help (category).");

    if(!strcmp(params, "general", true))
    {
        SendClientMessage(playerid, COLOR_NICEYELLOW, ". : : General commands : : .");
        SendClientMessage(playerid, COLOR_NICEBLUE, "/stats, /report, /helpme, /acc, /me, /do, /(s)hout, /(o)oc, /inventory, /switch.");
        SendClientMessage(playerid, COLOR_NICELBLUE, "/approve, /faq, /sell, /paint, /drink, /bank, /cook, /vest, /ammo, /usekit, /phone.");
        SendClientMessage(playerid, COLOR_NICEBLUE, "/id, /call, /hangup, /text, /drop, /flist, /crates, /fill, /pay, /gps, /open, /usedrug.");
        SendClientMessage(playerid, COLOR_NICELBLUE, "/animcmds, /backpack, /boombox, /channel, /jobcmds, /supporters, /disablecp, /stopanim.");
        SendClientMessage(playerid, COLOR_NICEBLUE, "/shakehand, /showlicense, /frisk, /toghud, /passwep, /setradio, /picklock, /resetvw. /factionhelp.");
    }
    else if(!strcmp(params, "account", true))
    {
        SendClientMessage(playerid, COLOR_NICEYELLOW, ". : : Account Commands : : .");
        SendClientMessage(playerid, COLOR_NICEBLUE, "/changepass, /lastlogged, /username, /properties.");
    }
    else if(!strcmp(params, "vehicle", true))
    {
        SendClientMessage(playerid, COLOR_NICEYELLOW, ". : : Vehicle Commands : : .");
        SendClientMessage(playerid, COLOR_NICEBLUE, "/park, /lock, /abandon, /refuel, /unmod, /trunk, /listcars, /engine, /lights, /hood, /tow.");
    }
    else if(!strcmp(params, "business", true))
    {
        SendClientMessage(playerid, COLOR_NICEYELLOW, ". : : Business Commands : : .");
        SendClientMessage(playerid, COLOR_NICEBLUE, "/buy, /abandon, /lock, /vault, /products, /binfo, /bname, /bmessage, /bshipment.");
    }
    else if(!strcmp(params, "house", true))
    {
        SendClientMessage(playerid, COLOR_NICEYELLOW, ". : : House Commands : : .");
        SendClientMessage(playerid, COLOR_NICEBLUE, "/buy, /abandon, /lock, /storage, /furniture, /buyrack, /gunrack, /deleterack.");
        SendClientMessage(playerid, COLOR_NICEBLUE, "/doorbell, /switch.");
    }
    else if(!strcmp(params, "property", true))
    {
        SendClientMessage(playerid, COLOR_NICEYELLOW, ". : : Property Commands : : .");
        SendClientMessage(playerid, COLOR_NICEBLUE, "/buy, /abandon, /lock, /housecmds, /products, /vault, /binfo, /bizcmds.");
    }
    else if(!strcmp(params, "Helper", true))
    {
        if(!PlayerData[playerid][pTester]) return SendClientMessage(playerid, COLOR_NICEBLUE, "SERVER: You cannot use this command");

        SendClientMessage(playerid, COLOR_NICEYELLOW, ". : : Helper Commands : : .");
        SendClientMessage(playerid, COLOR_NICEBLUE, "/t, /tduty, /ah, /dh, /kick");
    }
    else if (!strcmp(params, "admin", true))
    {
        if(!PlayerData[playerid][pAdmin]) return SendClientMessage(playerid, COLOR_NICEBLUE, "SERVER: You cannot use this command");

        SendClientMessage(playerid, COLOR_NICEYELLOW, ". : : Administrator Commands : : .");

        if(PlayerData[playerid][pAdmin] >= 1)
        {
            SendClientMessage(playerid, COLOR_NICEBLUE, "/a, /reports, /spectate, /ajail, /release, /kick, /mute, /unmute, /freeze, /unfreeze.");
            SendClientMessage(playerid, COLOR_NICELBLUE, "/aduty, /ban, /skin /goto /aremovecall");
        }

        if(PlayerData[playerid][pAdmin] >= 2)
        {
            SendClientMessage(playerid, COLOR_NICEBLUE, "/respawn, /warn, /checkstats, /shooter, /goto, /bring, /setinterior, /setvw.");
            SendClientMessage(playerid, COLOR_NICELBLUE, "/sendto, /clearchat, /spawn, /refill, /revive, /aslap, /acceptname, /declinename, /atalk.");
            SendClientMessage(playerid, COLOR_NICEBLUE, "/masked, /listguns, /respawncar, /respawncars, /respawnnear, /heal, /bringcar, /gotocar.");
            SendClientMessage(playerid, COLOR_NICELBLUE, "/x /y /z");
        }

        if(PlayerData[playerid][pAdmin] >= 3)
        {
            SendClientMessage(playerid, COLOR_NICEBLUE, "/unban, /blacklist, /getip, /togooc, /health, /armor, /resetweps, /arepair, /listwarns.");
            SendClientMessage(playerid, COLOR_NICELBLUE, "/entercar, /flipcar, /veh, /destroyveh, /near, /healall, /tracenumber, /bleeding.");
            SendClientMessage(playerid, COLOR_NICEBLUE, "/atune, /acolorcar, /apaintjob, /afire, /akillfire, /adestroybox.");
        }

        if(PlayerData[playerid][pAdmin] >= 4)
        {
            SendClientMessage(playerid, COLOR_NICEBLUE, "/givewep, /settester, /baninfo, /setname, /asetfaction, /asetrank, /setitem.");
            SendClientMessage(playerid, COLOR_NICELBLUE, "/asellhouse, /asellbiz, /jetpack, /setweather, /setfuel, /setcarhp, /spawnitem.");
            SendClientMessage(playerid, COLOR_NICEBLUE, "/setquantity, /destroyitem, /setplayer, /setleader, /setinventory, /givecar.");
        }

        if(PlayerData[playerid][pAdmin] >= 5)
        {
            SendClientMessage(playerid, COLOR_NICELBLUE, "/dynamichelp, /givecash, /clearinventory, /clearwarns, /saveall, /restart.");
        }

        if(PlayerData[playerid][pAdmin] >= 6)
        {
            SendClientMessage(playerid, COLOR_NICEBLUE, "/makeadmin, /deleteaccount, /deletechar, /factionmod, /panel.");
        }
    }
    else
    {
        SendClientMessage(playerid, COLOR_NICEYELLOW, ". : : Help List : : .");
        SendClientMessage(playerid, COLOR_NICEBLUE, "TIP: /help [name]");
        SendClientMessage(playerid, COLOR_NICEBLUE, "Names: General, Account, Vehicle, Business, House , Property, Helper, Admin");
    }
    return 1;
}
Reply
#5

A - You can use else if's you are currently using if's, that means the else part is only for last if (which is admin, so if they type /help admin ) those lines won't be shown
B - You can return 1 ( or return SCM ) in every section to make it stop advancing to those else
C - you can check and see with isnull(params) to only show it when they type /help and nothing else
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)