SA-MP Forums Archive
Issue with sscanf - 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: Issue with sscanf (/showthread.php?tid=312283)



Issue with sscanf - Dokins - 20.01.2012

Basically, It doesn't return "function" correctly. If I type /housestore ot returns the client message, but if I type /housestore money it doesnt.

Please advise me.



pawn Код:
CMD:housestore(playerid, params[])
{
    if(LoggedIn[playerid] == 0) return SendClientMessage(playerid, COLOUR_GREY, "You must be logged in to use this command.");

    new cashamount, string[128],function[16], sum;
    new houseid = GetPlayerHouseID(playerid);
    if(sscanf(params, "s[16]", function)) return SendClientMessage(playerid, COLOUR_GREY, "Usage: /housestore [function] Available functions: weapon(coming soon), money");

    if(strcmp(function, "money", true) == 0)
    {
        if(sscanf(function, "d", cashamount)) return SendClientMessage(playerid, COLOUR_GREY, "Usage: /housestore money [amount]");
        if(cashamount < 1 || cashamount > 500000) return SendClientMessage(playerid, COLOUR_GREY, "The amount must be between $0 and $500,000.");
        if(cashamount > PlayerMoney[playerid]) return SendClientMessage(playerid, COLOUR_GREY, "You do not have this much to store.");
        if(HouseOwned[playerid] == houseid)
        {
            printf("House Owned: %d", HouseOwned[playerid]);
            sum = HouseMoney[houseid] += cashamount;
            HouseSQLID[houseid] = MySQL_GetValue(HouseSQLID[houseid], "id", "houses");
            MySQL_SetInteger(HouseSQLID[houseid], "HouseMoney", sum, "houses");
            GivePlayerMoney(playerid, -cashamount);
            printf("Cash amount %d", cashamount);
            format(string, sizeof(string), "You have stored $%d in your house.", cashamount);
            SendClientMessage(playerid, COLOUR_ORANGE, string);
        }

    }
    return 1;
}



Re: Issue with sscanf - Bogdan1992 - 20.01.2012

, nvm


Re: Issue with sscanf - Laronic - 20.01.2012

Should work. I'll also made a example for next command.
pawn Код:
CMD:housestore(playerid, params[])
{
    if(LoggedIn[playerid] == 0) return SendClientMessage(playerid, COLOUR_GREY, "You must be logged in to use this command.");

    new houseid = GetPlayerHouseID(playerid), string[128];
    if(strcmp(params, "money", true) == 0)
    {
        new cashamount, sum;
        if(sscanf(params, "{s[6]}d", cashamount)) return SendClientMessage(playerid, COLOUR_GREY, "Usage: /housestore money [amount]");
        if(cashamount < 1 || cashamount > 500000) return SendClientMessage(playerid, COLOUR_GREY, "The amount must be between $0 and $500,000.");
        if(cashamount > PlayerMoney[playerid]) return SendClientMessage(playerid, COLOUR_GREY, "You do not have this much to store.");
        if(HouseOwned[playerid] == houseid)
        {
            printf("House Owned: %d", HouseOwned[playerid]);
            sum = HouseMoney[houseid] += cashamount;
            HouseSQLID[houseid] = MySQL_GetValue(HouseSQLID[houseid], "id", "houses");
            MySQL_SetInteger(HouseSQLID[houseid], "HouseMoney", sum, "houses");
            GivePlayerMoney(playerid, -cashamount);
            printf("Cash amount %d", cashamount);
            format(string, sizeof(string), "You have stored $%d in your house.", cashamount);
            SendClientMessage(playerid, COLOUR_ORANGE, string);
        }
        return true;
    }
   
    if(strcmp(params, "NextCommandGoesHere", true) == 0)
    {
        new stuff[128], something;
        if(sscanf(params, "{s[20]}s[128]d", stuff, something)) return SendClientMessage(playerid, COLOUR_GREY, "Usage: /housestore NextCommandGoesHere [stuff | something]");
        {
            //Command stuff
        }
        return true;
    }
    SendClientMessage(playerid, COLOUR_GREY, "Usage: /housestore [function] Available functions: weapon(coming soon), money");
    return true;
}



Re: Issue with sscanf - Dokins - 20.01.2012

Ill try that, have you changed it in anyway?


Re: Issue with sscanf - Dokins - 21.01.2012

Issue is still not fixed, can someone else have a look?