mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-08-31 10:18:54 +00:00
Minor fixes, fixed restarting script
This commit is contained in:
+3
-2
@@ -2,10 +2,11 @@ resource_manifest_version '44febabe-d386-4d18-afbe-5e627f4af937'
|
||||
|
||||
description 'ESX Property'
|
||||
|
||||
version '1.0.3'
|
||||
version '1.0.4'
|
||||
|
||||
server_scripts {
|
||||
'@es_extended/locale.lua',
|
||||
'@mysql-async/lib/MySQL.lua',
|
||||
'locales/de.lua',
|
||||
'locales/br.lua',
|
||||
'locales/en.lua',
|
||||
@@ -13,7 +14,6 @@ server_scripts {
|
||||
'locales/fr.lua',
|
||||
'locales/es.lua',
|
||||
'locales/sv.lua',
|
||||
'@mysql-async/lib/MySQL.lua',
|
||||
'config.lua',
|
||||
'server/main.lua'
|
||||
}
|
||||
@@ -32,5 +32,6 @@ client_scripts {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
'es_extended',
|
||||
'instance'
|
||||
}
|
||||
|
||||
+11
-19
@@ -11,8 +11,6 @@ local Keys = {
|
||||
}
|
||||
|
||||
ESX = nil
|
||||
local GUI = {}
|
||||
GUI.Time = 0
|
||||
local OwnedProperties = {}
|
||||
local Blips = {}
|
||||
local CurrentProperty = nil
|
||||
@@ -861,7 +859,13 @@ end)
|
||||
|
||||
RegisterNetEvent('esx:playerLoaded')
|
||||
AddEventHandler('esx:playerLoaded', function(xPlayer)
|
||||
PlayerLoaded = true
|
||||
PlayerLoaded = true
|
||||
|
||||
ESX.TriggerServerCallback('esx_property:getOwnedProperties', function(ownedProperties)
|
||||
for i=1, #ownedProperties, 1 do
|
||||
SetPropertyOwned(ownedProperties[i], true)
|
||||
end
|
||||
end)
|
||||
end)
|
||||
|
||||
AddEventHandler('esx_property:getProperties', function(cb)
|
||||
@@ -881,17 +885,6 @@ AddEventHandler('esx_property:setPropertyOwned', function(name, owned)
|
||||
SetPropertyOwned(name, owned)
|
||||
end)
|
||||
|
||||
RegisterNetEvent('esx:playerLoaded')
|
||||
AddEventHandler('esx:playerLoaded', function(xPlayer)
|
||||
|
||||
ESX.TriggerServerCallback('esx_property:getOwnedProperties', function(ownedProperties)
|
||||
for i=1, #ownedProperties, 1 do
|
||||
SetPropertyOwned(ownedProperties[i], true)
|
||||
end
|
||||
end)
|
||||
|
||||
end)
|
||||
|
||||
RegisterNetEvent('instance:onCreate')
|
||||
AddEventHandler('instance:onCreate', function(instance)
|
||||
|
||||
@@ -987,7 +980,7 @@ end)
|
||||
Citizen.CreateThread(function()
|
||||
while true do
|
||||
|
||||
Wait(0)
|
||||
Citizen.Wait(1)
|
||||
|
||||
local coords = GetEntityCoords(GetPlayerPed(-1))
|
||||
|
||||
@@ -1017,7 +1010,7 @@ end)
|
||||
Citizen.CreateThread(function()
|
||||
while true do
|
||||
|
||||
Wait(0)
|
||||
Citizen.Wait(1)
|
||||
|
||||
local coords = GetEntityCoords(GetPlayerPed(-1))
|
||||
local isInMarker = false
|
||||
@@ -1083,7 +1076,7 @@ end)
|
||||
Citizen.CreateThread(function()
|
||||
while true do
|
||||
|
||||
Citizen.Wait(0)
|
||||
Citizen.Wait(10)
|
||||
|
||||
if CurrentAction ~= nil then
|
||||
|
||||
@@ -1091,7 +1084,7 @@ Citizen.CreateThread(function()
|
||||
AddTextComponentString(CurrentActionMsg)
|
||||
DisplayHelpTextFromStringLabel(0, 0, 1, -1)
|
||||
|
||||
if IsControlPressed(0, Keys['E']) and (GetGameTimer() - GUI.Time) > 300 then
|
||||
if IsControlJustReleased(0, Keys['E']) then
|
||||
|
||||
if CurrentAction == 'property_menu' then
|
||||
OpenPropertyMenu(CurrentActionData.property)
|
||||
@@ -1116,7 +1109,6 @@ Citizen.CreateThread(function()
|
||||
end
|
||||
|
||||
CurrentAction = nil
|
||||
GUI.Time = GetGameTimer()
|
||||
|
||||
end
|
||||
|
||||
|
||||
+85
-74
@@ -1,4 +1,5 @@
|
||||
ESX = nil
|
||||
local hasSqlRun = false
|
||||
|
||||
TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
|
||||
|
||||
@@ -77,81 +78,91 @@ function RemoveOwnedProperty(name, owner)
|
||||
|
||||
end
|
||||
|
||||
AddEventHandler('onMySQLReady', function ()
|
||||
|
||||
MySQL.Async.fetchAll('SELECT * FROM properties', {}, function(properties)
|
||||
|
||||
for i=1, #properties, 1 do
|
||||
|
||||
local entering = nil
|
||||
local exit = nil
|
||||
local inside = nil
|
||||
local outside = nil
|
||||
local isSingle = nil
|
||||
local isRoom = nil
|
||||
local isGateway = nil
|
||||
local roomMenu = nil
|
||||
|
||||
if properties[i].entering ~= nil then
|
||||
entering = json.decode(properties[i].entering)
|
||||
end
|
||||
|
||||
if properties[i].exit ~= nil then
|
||||
exit = json.decode(properties[i].exit)
|
||||
end
|
||||
|
||||
if properties[i].inside ~= nil then
|
||||
inside = json.decode(properties[i].inside)
|
||||
end
|
||||
|
||||
if properties[i].outside ~= nil then
|
||||
outside = json.decode(properties[i].outside)
|
||||
end
|
||||
|
||||
if properties[i].is_single == 0 then
|
||||
isSingle = false
|
||||
else
|
||||
isSingle = true
|
||||
end
|
||||
|
||||
if properties[i].is_room == 0 then
|
||||
isRoom = false
|
||||
else
|
||||
isRoom = true
|
||||
end
|
||||
|
||||
if properties[i].is_gateway == 0 then
|
||||
isGateway = false
|
||||
else
|
||||
isGateway = true
|
||||
end
|
||||
|
||||
if properties[i].room_menu ~= nil then
|
||||
roomMenu = json.decode(properties[i].room_menu)
|
||||
end
|
||||
|
||||
table.insert(Config.Properties, {
|
||||
name = properties[i].name,
|
||||
label = properties[i].label,
|
||||
entering = entering,
|
||||
exit = exit,
|
||||
inside = inside,
|
||||
outside = outside,
|
||||
ipls = json.decode(properties[i].ipls),
|
||||
gateway = properties[i].gateway,
|
||||
isSingle = isSingle,
|
||||
isRoom = isRoom,
|
||||
isGateway = isGateway,
|
||||
roomMenu = roomMenu,
|
||||
price = properties[i].price
|
||||
})
|
||||
|
||||
end
|
||||
|
||||
end)
|
||||
|
||||
AddEventHandler('onMySQLReady', function()
|
||||
hasSqlRun = true
|
||||
LoadSql()
|
||||
end)
|
||||
|
||||
-- extremely useful when restarting script mid-game
|
||||
Citizen.CreateThread(function()
|
||||
Citizen.Wait(20000) -- hopefully enough for connection to the SQL server
|
||||
|
||||
if not hasSqlRun then
|
||||
LoadSql()
|
||||
hasSqlRun = true
|
||||
end
|
||||
end)
|
||||
|
||||
function LoadSql()
|
||||
MySQL.Async.fetchAll('SELECT * FROM properties', {}, function(properties)
|
||||
for i=1, #properties, 1 do
|
||||
|
||||
local entering = nil
|
||||
local exit = nil
|
||||
local inside = nil
|
||||
local outside = nil
|
||||
local isSingle = nil
|
||||
local isRoom = nil
|
||||
local isGateway = nil
|
||||
local roomMenu = nil
|
||||
|
||||
if properties[i].entering ~= nil then
|
||||
entering = json.decode(properties[i].entering)
|
||||
end
|
||||
|
||||
if properties[i].exit ~= nil then
|
||||
exit = json.decode(properties[i].exit)
|
||||
end
|
||||
|
||||
if properties[i].inside ~= nil then
|
||||
inside = json.decode(properties[i].inside)
|
||||
end
|
||||
|
||||
if properties[i].outside ~= nil then
|
||||
outside = json.decode(properties[i].outside)
|
||||
end
|
||||
|
||||
if properties[i].is_single == 0 then
|
||||
isSingle = false
|
||||
else
|
||||
isSingle = true
|
||||
end
|
||||
|
||||
if properties[i].is_room == 0 then
|
||||
isRoom = false
|
||||
else
|
||||
isRoom = true
|
||||
end
|
||||
|
||||
if properties[i].is_gateway == 0 then
|
||||
isGateway = false
|
||||
else
|
||||
isGateway = true
|
||||
end
|
||||
|
||||
if properties[i].room_menu ~= nil then
|
||||
roomMenu = json.decode(properties[i].room_menu)
|
||||
end
|
||||
|
||||
table.insert(Config.Properties, {
|
||||
name = properties[i].name,
|
||||
label = properties[i].label,
|
||||
entering = entering,
|
||||
exit = exit,
|
||||
inside = inside,
|
||||
outside = outside,
|
||||
ipls = json.decode(properties[i].ipls),
|
||||
gateway = properties[i].gateway,
|
||||
isSingle = isSingle,
|
||||
isRoom = isRoom,
|
||||
isGateway = isGateway,
|
||||
roomMenu = roomMenu,
|
||||
price = properties[i].price
|
||||
})
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
AddEventHandler('esx_ownedproperty:getOwnedProperties', function(cb)
|
||||
|
||||
MySQL.Async.fetchAll(
|
||||
@@ -556,7 +567,7 @@ function PayRent(d, h, m)
|
||||
|
||||
-- message player if connected
|
||||
if xPlayer ~= nil then
|
||||
xPlayer.removeBank(result[i].price)
|
||||
xPlayer.removeAccountMoney('bank', result[i].price)
|
||||
TriggerClientEvent('esx:showNotification', xPlayer.source, _U('paid_rent', result[i].price))
|
||||
else -- pay rent either way
|
||||
MySQL.Sync.execute(
|
||||
|
||||
Reference in New Issue
Block a user