SA-MP Forums Archive
Cases on a cmd? - 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: Cases on a cmd? (/showthread.php?tid=484552)



Cases on a cmd? - HK - 31.12.2013

Hello guys, how can I make this cmd to like, cases? like /bandana [1-9] i've an attachedobject system, so I wanna like know to make this?

- Thanks in advanced!

Код HTML:
CMD:bandana(playerid,params[])
{
                SetPlayerAttachedObject(playerid, 0, 18912, 2, 0.078534, 0.041857, -0.001727, 268.970458, 1.533374, 269.223754);
                SendClientMessage(playerid, -1, "Use /removebandana to get it off");
        return 1;
    }



Re: Cases on a cmd? - SilentSoul - 31.12.2013

NVM , not working.


Re: Cases on a cmd? - HK - 31.12.2013

Doesnt give me any errors / warnings, compiles fine, but IG it aren't appearing, it aren't sayin "Unknown Command" just some blank sht, please help e.


Re: Cases on a cmd? - SilentSoul - 31.12.2013

Show me your codes please full codes for that command.


Re: Cases on a cmd? - dominik523 - 31.12.2013

that is a really bad way to get any data from your command. Use a plugin called sscanf.
pawn Код:
CMD:bandana(playerid, params[])
{
    new number;
    if(sscanf(params, "d", number)) return SendClientMessage(playerid, -1, "Usage: /bandana [number]");
    switch(number)
    {
            // code for removing bandana and attaching it...
    }
    return 1;
}



Re: Cases on a cmd? - HK - 31.12.2013

Ok, the command shows up IG now, but it doesnt work at all, when im doing /gsign 1

then its returning me back to /gsign [1-20]

Код HTML:
CMD:gsign(playerid, params[])
{
    if(isnull(params) == 0) return SendClientMessage(playerid,-1,"/gsign [1-20]");
    if(params[0] == 1) ApplyAnimation(playerid, "GHANDS", "gsign1", 4.1, 0, 1, 1, 1, 0, 1);
    if(params[0] == 2) ApplyAnimation(playerid, "GHANDS", "gsign1LH", 4.1, 0, 1, 1, 1, 0, 1);
    if(params[0] == 3) ApplyAnimation(playerid, "GHANDS", "gsign2", 4.1, 0, 1, 1, 1, 0, 1);
    if(params[0] == 4) ApplyAnimation(playerid, "GHANDS", "gsign2LH", 4.1, 0, 1, 1, 1, 0, 1);
    if(params[0] == 5) ApplyAnimation(playerid, "GHANDS", "gsign3", 4.1, 0, 1, 1, 1, 0, 1);
    if(params[0] == 6) ApplyAnimation(playerid, "GHANDS", "gsign3LH", 4.1, 0, 1, 1, 1, 0, 1);
    if(params[0] == 7) ApplyAnimation(playerid, "GHANDS", "gsign4", 4.1, 0, 1, 1, 1, 0, 1);
    if(params[0] == 8) ApplyAnimation(playerid, "GHANDS", "gsign4LH", 4.1, 0, 1, 1, 1, 0, 1);
    if(params[0] == 9) ApplyAnimation(playerid, "GHANDS", "gsign5", 4.1, 0, 1, 1, 1, 0, 1);
    if(params[0] == 10) ApplyAnimation(playerid, "GHANDS", "gsign5LH", 4.1, 0, 1, 1, 1, 0, 1);
    if(params[0] == 11) ApplyAnimation(playerid, "GHANDS", "LHGsign1", 4.1, 0, 1, 1, 1, 0, 1);
    if(params[0] == 12) ApplyAnimation(playerid, "GHANDS", "LHGsign2", 4.1, 0, 1, 1, 1, 0, 1);
    if(params[0] == 13) ApplyAnimation(playerid, "GHANDS", "LHGsign3", 4.1, 0, 1, 1, 1, 0, 1);
    if(params[0] == 14) ApplyAnimation(playerid, "GHANDS", "LHGsign4", 4.1, 0, 1, 1, 1, 0, 1);
    if(params[0] == 15) ApplyAnimation(playerid, "GHANDS", "LHGsign5", 4.1, 0, 1, 1, 1, 0, 1);
    if(params[0] == 16) ApplyAnimation(playerid, "GHANDS", "RHGsign1", 4.1, 0, 1, 1, 1, 0, 1);
    if(params[0] == 17) ApplyAnimation(playerid, "GHANDS", "RHGsign2", 4.1, 0, 1, 1, 1, 0, 1);
    if(params[0] == 18) ApplyAnimation(playerid, "GHANDS", "RHGsign3", 4.1, 0, 1, 1, 1, 0, 1);
    if(params[0] == 19) ApplyAnimation(playerid, "GHANDS", "RHGsign4", 4.1, 0, 1, 1, 1, 1, 1);
    if(params[0] == 20) ApplyAnimation(playerid, "GHANDS", "RHGsign5", 4.1, 0, 1, 1, 1, 1, 1);
return 1;
}



Re: Cases on a cmd? - dominik523 - 31.12.2013

Like I said, use sscanf and switch after it.
You are doing this. You enter 1 as a parameter, and it is written as a character, not a number. You would need to set if(params[0] == "1") for each if branching.


Re: Cases on a cmd? - HK - 31.12.2013

I'm going to test yours now bro, hold on!