13.04.2019, 13:19
Whats wrong with my script,Can buy house but money not reduced, help me please
Code:
CMD:buyhouse(playerid, params[]) { new name[MAX_PLAYER_NAME], labelstring[144], string[144], file[50]; GetPlayerName(playerid, name, sizeof(name)); for(new i = 0; i < MAX_HOUSES; i++) { if(IsPlayerInRangeOfPoint(playerid, 5.0, HouseInfo[i][hX], HouseInfo[i][hY], HouseInfo[i][hZ])) { if(HouseInfo[i][hOwned] == 1) return SendClientMessage(playerid, -1, "{FF0000}ERROR: {FFFFFF}This house have an Owner."); if(GetPlayerMoney(playerid) < HouseInfo[i][hPrice]) return SendClientMessage(playerid, -1, "{FF0000}ERROR: {FFFFFF}You don't have enough money."); GivePlayerMoney(playerid, -HouseInfo[i][hPrice]); DestroyPickup(HouseInfo[i][hPick]); format(labelstring, sizeof(labelstring), "{15FF00}House ID: {FFFFFF}%d\n{15FF00}Owner: {FFFFFF}%s\n{15FF00}Price: {FFFFFF}%d", i, name, HouseInfo[i][hPrice]); HouseInfo[i][hPick] = CreatePickup(1272, 1, HouseInfo[i][hX], HouseInfo[i][hY], HouseInfo[i][hZ]); Update3DTextLabelText(HouseInfo[i][hLabel], 0xFFFFFFFF, labelstring); format(string, sizeof(string), "{FF0000}[HOUSE]: {FFFFFF}You bought house ID: {FF0000}%d {FFFFFF}for {FF0000}$ %d.", i, HouseInfo[i][hPrice]); SendClientMessage(playerid, -1, string); HouseInfo[i][hOwned] = 1; HouseInfo[i][hOwner] = name; format(file, sizeof(file), "Houses/%d.ini", i); if(fexist(file)) { dini_IntSet(file, "Owned", 1); dini_Set(file, "Owner", name); } } } return 1; }