MySQL Won't set integer (DEBUGGED ALREADY)
#1

The actual code is below, and Although it removes the money and gives the correct house id. AND i've debugged it, results below 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 amount, string[128],function[16], sum;
    new houseid = GetPlayerHouseID(playerid);
    if(sscanf(params, "s[16]d",function, amount)) return SendClientMessage(playerid, COLOUR_GREY, "Usage: /housestore [function] [amount]- Functions: Money, Weed, Cocaine.");

    if(!strcmp(function, "money", true))
    {
        if(amount < 1 || amount > 500000) return SendClientMessage(playerid, COLOUR_GREY, "The amount must be between $0 and $500,000.");
        if(amount > PlayerMoney[playerid]) return SendClientMessage(playerid, COLOUR_GREY, "You do not have this much to store.");
       
        PlayerSQLID[playerid] = MySQL_GetValue(PlayerSQLID[playerid], "id", "accounts");
        HouseOwned[playerid] = MySQL_GetValue(PlayerSQLID[playerid], "HouseOwned", "accounts");
        if(HouseOwned[playerid] != houseid) return SendClientMessage(playerid, COLOUR_GREY, "You do not own this house.");
            printf("House Owned: %d", HouseOwned[playerid]);
            sum = HouseMoney[houseid] += amount;
            HouseSQLID[houseid] = MySQL_GetValue(HouseSQLID[houseid], "id", "houses");
            new query[256];
            format(query, sizeof(query), "UPDATE `houses` SET `HouseMoney` = %d WHERE id = %d LIMIT 1", sum, HouseSQLID[houseid]);
            mysql_query(query);
            mysql_store_result();
            mysql_free_result();
            printf("House Amount added: %d", sum);
            printf("House ID: %d", houseid);
            GivePlayerMoney(playerid, -amount);
            printf("Cash amount %d", amount);
            format(string, sizeof(string), "You have stored $%d in your house.", amount);
            SendClientMessage(playerid, COLOUR_ORANGE, string);
    }
    return 1;
}
pawn Код:
[13:41:34] Cash amount 500
[13:41:34] House ID: 5
[13:41:34] House Amount added: 20500
[13:41:34] House Owned: 5
[13:41:27] House owner: Grant_McCaw
Reply
#2

I haven't got your problem but at the first glance on the code, I saw that you are using
pawn Код:
mysql_store_result();
mysql_free_result();
which is really unnecessary.
Reply
#3

Check the table for errors first, then check mysql_log.txt.
Reply
#4

I've checked the actual table, they all correspond to what they should be, I'll check the MYSQL_LOG, Thanks.
Reply
#5

pawn Код:
query(UPDATE `houses` SET `HouseMoney` = 20500 WHERE id = -1 LIMIT 1)

Why is it setting as -1? Hm.
Reply
#6

Quote:
Originally Posted by Dokins
Посмотреть сообщение
pawn Код:
query(UPDATE `houses` SET `HouseMoney` = 20500 WHERE id = -1 LIMIT 1)

Why is it setting as -1? Hm.
Because on your function it should return the integer and if it fails, it will return -1.
Reply
#7

Yep, I've managed to resolve it! Thanks!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)