Add exports, Config.Locale and some functions

This commit is contained in:
Jérémie N'gadi
2017-08-10 18:15:32 +02:00
parent 9106a7db2b
commit 5b97605431
7 changed files with 63 additions and 4 deletions
@@ -15,6 +15,7 @@ server_scripts {
client_scripts {
'config.lua',
'client/common.lua',
'client/functions.lua',
'client/main.lua'
}
@@ -41,4 +42,16 @@ files {
'html/img/accounts/bank.png',
'html/img/accounts/black_money.png'
}
exports {
'getSharedObject'
}
server_exports {
'getSharedObject'
}
dependencies {
'essentialmode'
}
@@ -0,0 +1,7 @@
AddEventHandler('esx:getSharedObject', function(cb)
cb(ESX)
end)
function getSharedObject()
return ESX
end
@@ -17,6 +17,10 @@ ESX.UI.Menu.Opened = {}
ESX.Game = {}
ESX.Game.Utils = {}
ESX.GetConfig = function()
return Config
end
ESX.GetRandomString = function(length)
math.randomseed(GetGameTimer())
@@ -123,6 +127,8 @@ end
ESX.UI.Menu.RegisterType = function(type, open, close)
print('ESX.UI.Menu.RegisterType => ' .. type)
ESX.UI.Menu.RegisteredTypes[type] = {
open = open,
close = close,
@@ -749,6 +755,27 @@ ESX.Game.SetVehicleProperties = function(vehicle, props)
end
ESX.Game.TeleportEntity = function(entity, coords, cb)
Citizen.CreateThread(function()
RequestCollisionAtCoord(coords.x, coords.y, coords.z)
while not HasCollisionLoadedAroundEntity(entity) do
RequestCollisionAtCoord(coords.x, coords.y, coords.z)
Citizen.Wait(0)
end
SetEntityCoords(entity, coords.x, coords.y, coords.z)
if cb ~= nil then
cb()
end
end)
end
ESX.Game.Utils.DrawText3D = function(coords, text, size)
local onScreen, x, y = World3dToScreen2d(coords.x, coords.y, coords.z)
@@ -967,10 +994,6 @@ ESX.ShowInventory = function()
end
AddEventHandler('esx:getSharedObject', function(cb)
cb(ESX)
end)
RegisterNetEvent('esx:serverCallback')
AddEventHandler('esx:serverCallback', function(requestId, a, b, c, d, e, f, g ,h ,i ,j ,k, l, m, n, o, p, q, r, s, t, u ,v ,w, x ,y ,z)
ESX.ServerCallbacks[requestId](a, b, c, d, e, f, g ,h ,i ,j ,k, l, m, n, o, p, q, r, s, t, u ,v ,w, x ,y ,z)
@@ -6,6 +6,7 @@ Config.PaycheckInterval = 7 * 60000
Config.ShowDotAbovePlayer = false
Config.DisableWantedLevel = true
Config.RemoveInventoryItemDelay = 5 * 60000
Config.Locale = 'fr_FR'
Config.Weapons = {
@@ -9,6 +9,10 @@ AddEventHandler('esx:getSharedObject', function(cb)
cb(ESX)
end)
function getSharedObject()
return ESX
end
AddEventHandler('onMySQLReady', function ()
MySQL.Async.fetchAll(
@@ -4,6 +4,10 @@ for i = 48, 57 do table.insert(Charset, string.char(i)) end
for i = 65, 90 do table.insert(Charset, string.char(i)) end
for i = 97, 122 do table.insert(Charset, string.char(i)) end
ESX.GetConfig = function()
return Config
end
ESX.GetRandomString = function(length)
math.randomseed(os.time())
@@ -279,6 +279,13 @@ AddEventHandler('esx:updateLoadout', function(loadout)
xPlayer.loadout = loadout
end)
RegisterServerEvent('esx:updateLastPosition')
AddEventHandler('esx:updateLastPosition', function(position)
local xPlayer = ESX.GetPlayerFromId(source)
xPlayer.lastPosition = position
end)
RegisterServerEvent('esx:giveInventoryItem')
AddEventHandler('esx:giveInventoryItem', function(target, type, itemName, itemCount)