Help please....SSCANF issue - Still not resolved.
#1

Hello, there is an issue i'm facing with this, everytime I type /housestore money...it returns /housestore money amount..

but when I actually type the amount it returns the same message!


pawn Code:
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]D", function, cashamount)) 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;
}
Reply
#2

its if(!sscanf

Otherwise it u must liturally use "d" as parameter

pawn Code:
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]D", function, cashamount)) 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]"); //use !sscanf  
        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;
}
Reply
#3

Still not returning correctly, although it stores the money.
Reply
#4

hmm let me check.. will post the edit when im done

EDIT:
try this:
I re organized it a bit. I can understand if you dont like it but its cleaner for me

pawn Code:
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]D", function, cashamount)) 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))
        {
            if(cashamount > 1 || cashamount < 500000)
            {
                if(cashamount < PlayerMoney[playerid])
                {
                    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);
                    }
                }
                else return SendClientMessage(playerid, COLOUR_GREY, "You do not have this much to store.");
            }
            else return SendClientMessage(playerid, COLOUR_GREY, "The amount must be between $0 and $500,000.");
        }
        else return SendClientMessage(playerid, COLOUR_GREY, "Usage: /housestore money [amount]"); //use !sscanf
    }
    return 1;
}
Reply
#5

hmm let me check.. will post the edit when im done

EDIT:
try this:
I re organized it a bit. I can understand if you dont like it but its cleaner for me

pawn Code:
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]D", function, cashamount)) 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))
        {
            if(cashamount > 1 || cashamount < 500000)
            {
                if(cashamount < PlayerMoney[playerid])
                {
                    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);
                    }
                }
                else return SendClientMessage(playerid, COLOUR_GREY, "You do not have this much to store.");
            }
            else return SendClientMessage(playerid, COLOUR_GREY, "The amount must be between $0 and $500,000.");
        }
        else return SendClientMessage(playerid, COLOUR_GREY, "Usage: /housestore money [amount]"); //use !sscanf
    }
    return 1;
}
I HATE DUBBEL POSTS
Reply
#6

Still not working.
Reply
#7

ok explain, It does store everything right? but it still shows the message?

and what is strcmp funcion money
Reply
#8

Compares the string.
Reply
#9

this maybe?
pawn Code:
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]d", function, cashamount))
    {
        if(!sscanf(function, "d", cashamount))
        {
            if(cashamount > 1 || cashamount < 500000)
            {
                if(cashamount < PlayerMoney[playerid])
                {
                    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);
                    }
                }
                else return SendClientMessage(playerid, COLOUR_GREY, "You do not have this much to store.");
            }
            else return SendClientMessage(playerid, COLOUR_GREY, "The amount must be between $0 and $500,000.");
        }
        else return SendClientMessage(playerid, COLOUR_GREY, "Usage: /housestore money [amount]"); //use !sscanf
    }
    else return SendClientMessage(playerid, COLOUR_GREY, "Usage: /housestore [function] Available functions: weapon(coming soon), money");
}
EDIT: I have no idea what you did.. Your doing it waaay different then me
Reply
#10

Still not working.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)