Help with command
#1

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]
Reply
#2

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.
Reply
#3

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
Reply
#4

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.
Reply
#5

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.
Reply
#6

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?
Reply
#7

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.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)