I’m trying to modify the esx_property script so that a player can only rent one property at a time. To do this I’m trying to trigger an event that removes all properties from a player before assigning a new one.
This is my latest attempt. I also tried an ‘if’ ‘then’ ‘else’ statement using the database query event found towards the end of the esx_property script with no luck.
RegisterServerEvent('esx_property:rentProperty')
AddEventHandler('esx_property:rentProperty', function(propertyName)
local xPlayer = ESX.GetPlayerFromId(source)
local property = GetProperty(propertyName)
local rent = ESX.Math.Round(property.price / 600)
TriggerEvent('esx_property:removeOwnedProperty', function(propertyName)
local xPlayer = ESX.GetPlayerFromId(source)
RemoveOwnedProperty(propertyName, xPlayer.identifier)
end)
SetPropertyOwned(propertyName, rent, true, xPlayer.identifier)
end)
Its on the list of things to do but I’m still learning to code and working on easier scripts first. Hopefully someone will be generous and release their modded script as its a highly requested feature.