31.01.2012, 11:41
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