Can someone assist me with this?
#1

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

    new function[16], cashamount;
    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.");
        MySQL_SetInteger(HouseSQLID[houseid], "HouseMoney", cashamount, "houses");
                    new string[32];
        format(string, sizeof(string), "You have stored $%d in your house.", cashamount);
        GivePlayerMoney(playerid, -cashamount);
        SendClientMessage(playerid, COLOUR_ORANGE, string);

    }
    return 1;
}
Well, basically, this wont do as I've asked it. I don't get any client message and it won't set the integers.
Reply
#2

pawn Код:
if(strcmp(function, "money", true, 5) == 0)
pawn Код:
if(sscanf(params, "{s[16]}d", cashamount))
Reply
#3

the problem is caused by function[16], wich gets used as string and cashamount. sscanning a string followed by an integer can be tricky, maybe this does the trick:
Код:
CMD:housestore(playerid, params[])
{
    if(LoggedIn[playerid] == 0) return SendClientMessage(playerid, COLOUR_GREY, "You must be logged in to use this command.");

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

    if(strcmp(function, "money", true) == 0)
    {
        if(sscanf(functionrest, "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.");
        MySQL_SetInteger(HouseSQLID[houseid], "HouseMoney", cashamount, "houses");
                    new string[32];
        format(string, sizeof(string), "You have stored $%d in your house.", cashamount);
        GivePlayerMoney(playerid, -cashamount);
        SendClientMessage(playerid, COLOUR_ORANGE, string);

    }
    return 1;
}
since the "money" as function is 1 word, the stringsize of 16 wont disturb the " " space delimeter. if it wont work, maybe the "p< >" delimeter helps..
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)