You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
`ESX.RegisterServerCallback("esx_property:buyProperty", function(source, cb, PropertyId)
local xPlayer = ESX.GetPlayerFromId(source)
local Price = Properties[PropertyId].Price
if xPlayer.getAccount("bank").money >= Price then
xPlayer.removeAccountMoney("bank", Price, "Bought Property")
Properties[PropertyId].Owner = xPlayer.identifier
Properties[PropertyId].OwnerName = xPlayer.getName()
Properties[PropertyId].Owned = true
Log("Property Bought", 65280, {{name = "Property Name", value = Properties[PropertyId].Name, inline = true},
{name = "Price", value = ESX.Math.GroupDigits(Price), inline = true},
{name = "Player", value = xPlayer.getName(), inline = true}}, 1)
TriggerClientEvent("esx_property:syncProperties", -1, Properties)
if Config.OxInventory then
exports.ox_inventory:RegisterStash("property-" .. PropertyId, Properties[PropertyId].Name, 15, 100000, xPlayer.identifier)
end
end
cb(xPlayer.getAccount("bank").money >= Price)
end)`
if player has enough money to buy property. example price : 100k
and what he got left after buying is under the property value, the cb() function returns to client false which will prompt user with a "cant afford" msg but he bought the house. gotta leave menu and interact again to see the owner's menu.
i have changed to this and worked :
ESX.RegisterServerCallback("esx_property:buyProperty", function(source, cb, PropertyId) local xPlayer = ESX.GetPlayerFromId(source) local Price = Properties[PropertyId].Price local isBought = false if xPlayer.getAccount("bank").money >= Price then xPlayer.removeAccountMoney("bank", Price, "Bought Property") Properties[PropertyId].Owner = xPlayer.identifier Properties[PropertyId].OwnerName = xPlayer.getName() Properties[PropertyId].Owned = true Log("Property Bought", 65280, {{name = "**Property Name**", value = Properties[PropertyId].Name, inline = true}, {name = "**Price**", value = ESX.Math.GroupDigits(Price), inline = true}, {name = "**Player**", value = xPlayer.getName(), inline = true}}, 1) TriggerClientEvent("esx_property:syncProperties", -1, Properties) if Config.OxInventory then exports.ox_inventory:RegisterStash("property-" .. PropertyId, Properties[PropertyId].Name, 15, 100000, xPlayer.identifier) end isBought = true end cb(isBought) end)
The text was updated successfully, but these errors were encountered:
`ESX.RegisterServerCallback("esx_property:buyProperty", function(source, cb, PropertyId)
local xPlayer = ESX.GetPlayerFromId(source)
local Price = Properties[PropertyId].Price
if xPlayer.getAccount("bank").money >= Price then
xPlayer.removeAccountMoney("bank", Price, "Bought Property")
Properties[PropertyId].Owner = xPlayer.identifier
Properties[PropertyId].OwnerName = xPlayer.getName()
Properties[PropertyId].Owned = true
Log("Property Bought", 65280, {{name = "Property Name", value = Properties[PropertyId].Name, inline = true},
{name = "Price", value = ESX.Math.GroupDigits(Price), inline = true},
{name = "Player", value = xPlayer.getName(), inline = true}}, 1)
TriggerClientEvent("esx_property:syncProperties", -1, Properties)
if Config.OxInventory then
exports.ox_inventory:RegisterStash("property-" .. PropertyId, Properties[PropertyId].Name, 15, 100000, xPlayer.identifier)
end
end
cb(xPlayer.getAccount("bank").money >= Price)
end)`
if player has enough money to buy property. example price : 100k
and what he got left after buying is under the property value, the cb() function returns to client false which will prompt user with a "cant afford" msg but he bought the house. gotta leave menu and interact again to see the owner's menu.
i have changed to this and worked :
ESX.RegisterServerCallback("esx_property:buyProperty", function(source, cb, PropertyId) local xPlayer = ESX.GetPlayerFromId(source) local Price = Properties[PropertyId].Price local isBought = false if xPlayer.getAccount("bank").money >= Price then xPlayer.removeAccountMoney("bank", Price, "Bought Property") Properties[PropertyId].Owner = xPlayer.identifier Properties[PropertyId].OwnerName = xPlayer.getName() Properties[PropertyId].Owned = true Log("Property Bought", 65280, {{name = "**Property Name**", value = Properties[PropertyId].Name, inline = true}, {name = "**Price**", value = ESX.Math.GroupDigits(Price), inline = true}, {name = "**Player**", value = xPlayer.getName(), inline = true}}, 1) TriggerClientEvent("esx_property:syncProperties", -1, Properties) if Config.OxInventory then exports.ox_inventory:RegisterStash("property-" .. PropertyId, Properties[PropertyId].Name, 15, 100000, xPlayer.identifier) end isBought = true end cb(isBought) end)
The text was updated successfully, but these errors were encountered: