mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-09-04 08:13:21 +00:00
Fixed broken script and last_property being empty instead of nil, closes #33
This commit is contained in:
@@ -26,7 +26,7 @@ git clone https://github.com/ESX-Org/esx_property [esx]/esx_property
|
||||
|
||||
## Installation
|
||||
- Import `esx_property.sql` in your database
|
||||
- Import `esx_offices.sql` in your database if you want the offices to added in your server (The Arcadius Business Centre is not included because realstateagentjob)
|
||||
- Import `esx_offices.sql` in your database if you want offices (The Arcadius Business Centre is not included because realstateagentjob)
|
||||
- Add this to your `server.cfg`:
|
||||
|
||||
```
|
||||
|
||||
+5
-1
@@ -33,5 +33,9 @@ client_scripts {
|
||||
|
||||
dependencies {
|
||||
'es_extended',
|
||||
'instance'
|
||||
'instance',
|
||||
'cron',
|
||||
'esx_addonaccount',
|
||||
'esx_addoninventory',
|
||||
'esx_datastore'
|
||||
}
|
||||
|
||||
+30
-17
@@ -31,6 +31,21 @@ Citizen.CreateThread(function()
|
||||
end
|
||||
end)
|
||||
|
||||
RegisterNetEvent('esx:playerLoaded')
|
||||
AddEventHandler('esx:playerLoaded', function(xPlayer)
|
||||
ESX.TriggerServerCallback('esx_property:getProperties', function(properties)
|
||||
Config.Properties = properties
|
||||
CreateBlips()
|
||||
end)
|
||||
|
||||
ESX.TriggerServerCallback('esx_property:getOwnedProperties', function(ownedProperties)
|
||||
for i=1, #ownedProperties, 1 do
|
||||
SetPropertyOwned(ownedProperties[i], true)
|
||||
end
|
||||
end)
|
||||
end)
|
||||
|
||||
-- only used when script is restarting mid-session
|
||||
RegisterNetEvent('esx_property:sendProperties')
|
||||
AddEventHandler('esx_property:sendProperties', function(properties)
|
||||
Config.Properties = properties
|
||||
@@ -854,26 +869,25 @@ AddEventHandler('instance:loaded', function()
|
||||
end)
|
||||
|
||||
AddEventHandler('playerSpawned', function()
|
||||
if FirstSpawn then
|
||||
|
||||
if FirstSpawn then
|
||||
Citizen.CreateThread(function()
|
||||
|
||||
Citizen.CreateThread(function()
|
||||
while not ESX.IsPlayerLoaded() do
|
||||
Citizen.Wait(0)
|
||||
end
|
||||
|
||||
while not ESX.IsPlayerLoaded() do
|
||||
Citizen.Wait(0)
|
||||
end
|
||||
|
||||
ESX.TriggerServerCallback('esx_property:getLastProperty', function(propertyName)
|
||||
if propertyName ~= nil then
|
||||
TriggerEvent('instance:create', 'property', {property = propertyName, owner = ESX.GetPlayerData().identifier})
|
||||
end
|
||||
end)
|
||||
|
||||
end)
|
||||
|
||||
FirstSpawn = false
|
||||
end
|
||||
ESX.TriggerServerCallback('esx_property:getLastProperty', function(propertyName)
|
||||
if propertyName ~= nil then
|
||||
if propertyName ~= '' then
|
||||
TriggerEvent('instance:create', 'property', {property = propertyName, owner = ESX.GetPlayerData().identifier})
|
||||
end
|
||||
end
|
||||
end)
|
||||
end)
|
||||
|
||||
FirstSpawn = false
|
||||
end
|
||||
end)
|
||||
|
||||
AddEventHandler('esx_property:getProperties', function(cb)
|
||||
@@ -904,7 +918,6 @@ end)
|
||||
|
||||
RegisterNetEvent('instance:onEnter')
|
||||
AddEventHandler('instance:onEnter', function(instance)
|
||||
|
||||
if instance.type == 'property' then
|
||||
|
||||
local property = GetProperty(instance.data.property)
|
||||
|
||||
+7
-3
@@ -159,12 +159,16 @@ function LoadSql()
|
||||
roomMenu = roomMenu,
|
||||
price = properties[i].price
|
||||
})
|
||||
end
|
||||
|
||||
TriggerClientEvent('esx_property:broadcastProperties', -1, Config.Properties)
|
||||
end
|
||||
|
||||
TriggerClientEvent('esx_property:sendProperties', -1, Config.Properties)
|
||||
end)
|
||||
end
|
||||
|
||||
ESX.RegisterServerCallback('esx_property:getProperties', function(source, cb)
|
||||
cb(Config.Properties)
|
||||
end)
|
||||
|
||||
AddEventHandler('esx_ownedproperty:getOwnedProperties', function(cb)
|
||||
|
||||
MySQL.Async.fetchAll(
|
||||
|
||||
Reference in New Issue
Block a user