SA-MP Forums Archive
Command doesn't work as intended - 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: Command doesn't work as intended (/showthread.php?tid=460295)



Command doesn't work as intended - Luke_James - 27.08.2013

The command, when processed, sets the house price to something stupid - for example, if I did /sethouseprice 100000 it would set the price to $51...

pawn Код:
YCMD:sethouseprice(playerid, params[], help) {
    if(help) {
        SendClientMessage(playerid, X11_WHITE, "Updates a houses description");
        return 1;
    }
    new house = getStandingHouse(playerid);
    if(house == -1) {
        SendClientMessage(playerid, X11_TOMATO_2, "You must be standing near a house");
        return 1;
    }
    new price[64],price_esc[(sizeof(price)*2)+1];
    if(!sscanf(params,"s[64]", price)) {
        query[0] = 0;
        mysql_real_escape_string(price, price_esc);
        format(Houses[house][EHouseValue],64,"%s",price);
        format(query, sizeof(query), "UPDATE `houses` SET `price` = \"%s\" WHERE `id` = %d", price_esc, Houses[house][EHouseSQLID]);
        mysql_function_query(g_mysql_handle, query, true, "EmptyCallback", "");    
        new labeltext[128];
        getHouseTextLabel(house, labeltext, sizeof(labeltext));
        UpdateDynamic3DTextLabelText(Houses[house][EHouseTextLabel],0x00FF00FF, labeltext);
    } else {
        SendClientMessage(playerid, X11_WHITE, "USAGE: /sethouseprice [price]");
        SendClientMessage(playerid, X11_WHITE, "You must be standing at the house pickup to do this.");
    }
    return 1;
}



Re: Command doesn't work as intended - Konstantinos - 27.08.2013

I'm not really sure why it does not work. Although, have you ever heard of integers? Price can be used/saved as integer.


Re: Command doesn't work as intended - Luke_James - 29.08.2013

Anyone?


Re: Command doesn't work as intended - Misiur - 29.08.2013

51 is character '3' in ascii table. Seriously, change your database to hold price as a number, not a string