SA-MP Forums Archive
Help with command - 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: Help with command (/showthread.php?tid=663565)



Help with command - akib - 05.02.2019

How I can make a command like this

Available Action: deposit, withdraw
Usage /fsafe [Action]

and if action == deposit then

Available Action: weapon, cash
Usage /fsafe deposit [Action]

and if action == cash then

Usage /fsafe deposit cash [Amount]


Re: Help with command - Proxus - 05.02.2019

You could use zcmd and then strcmp for the parameters. However, you'll need somewhere to store the amount a player has in the safe. I can post a sample script later unless someone does that before me.


Re: Help with command - akib - 05.02.2019

Quote:
Originally Posted by Proxus
View Post
You could use zcmd and then strcmp for the parameters. However, you'll need somewhere to store the amount a player has in the safe. I can post a sample script later unless someone does that before me.
I tried with zcmd, strcmp... but i am failed, please show me your example


Re: Help with command - TheToretto - 05.02.2019

Quote:
Originally Posted by akib
View Post
I tried with zcmd, strcmp... but i am failed, please show me your example
Show your code so we can help you, not do it for you so you can understand your mistake.


Re: Help with command - Kane - 05.02.2019

pawn Code:
CMD:fsafe(playerid, cmdtext[]){

    new szCmdInfo[30], szActionInfo[30], amount;

    if(sscanf(cmdtext, "s[30]S()[30]", szCmdInfo, szActionInfo))
    {
        SendClientMessage(playerid, -1, "USAGE: /fsafe [Action]");
        SendClientMessage(playerid, -1, "Available Actions: deposit, withdraw");
        return 1;
    }

    if(!strcmp(szCmdInfo, "deposit", true)){

        // Deposit here:

        if(sscanf(szActionInfo, "i", amount))
        {
            SendClientMessage(playerid, -1, "/fsafe deposit [amount]");
            return 1;
        }

    }


    return 1;
}
That should give you an idea of how to start.


Re: Help with command - akib - 05.02.2019

Quote:
Originally Posted by Kane_
View Post
pawn Code:
CMD:fsafe(playerid, cmdtext[]){

    new szCmdInfo[30], szActionInfo[30], amount;

    if(sscanf(cmdtext, "s[30]S()[30]", szCmdInfo, szActionInfo))
    {
        SendClientMessage(playerid, -1, "USAGE: /fsafe [Action]");
        SendClientMessage(playerid, -1, "Available Actions: deposit, withdraw");
        return 1;
    }

    if(!strcmp(szCmdInfo, "deposit", true)){

        // Deposit here:

        if(sscanf(szActionInfo, "i", amount))
        {
            SendClientMessage(playerid, -1, "/fsafe deposit [amount]");
            return 1;
        }

    }


    return 1;
}
That should give you an idea of how to start.
Can you explain me this line
PHP Code:
if(sscanf(cmdtext"s[30]S()[30]"szCmdInfoszActionInfo)) 
s[30]S()[30]

first s[30] is for szCMDInfo
but S() for? and why brackets?


Re: Help with command - TheToretto - 05.02.2019

S() means the specifier is a string, and optional. So it can reach your options down, else it would always return the SendClientMessage usage thingie. And brackets are there to specify a reason, we obviously don't need that so they're left blank.