Files
esx_core/server/main.lua
T
Jérémie N'gadi 6c44faa1ab Add files
2017-08-02 10:58:39 +02:00

63 lines
1.3 KiB
Lua

ESX = nil
TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
RegisterServerEvent('esx_clotheshop:pay')
AddEventHandler('esx_clotheshop:pay', function()
local xPlayer = ESX.GetPlayerFromId(source)
xPlayer.removeMoney(Config.Price)
TriggerClientEvent('esx:showNotification', source, 'Vous avez payé $' .. Config.Price)
end)
RegisterServerEvent('esx_clotheshop:saveOutfit')
AddEventHandler('esx_clotheshop:saveOutfit', function(label, skin)
local xPlayer = ESX.GetPlayerFromId(source)
TriggerEvent('esx_datastore:getDataStore', 'property', xPlayer.identifier, function(store)
local dressing = store.get('dressing')
if dressing == nil then
dressing = {}
end
table.insert(dressing, {
label = label,
skin = skin
})
store.set('dressing', dressing)
end)
end)
ESX.RegisterServerCallback('esx_clotheshop:checkMoney', function(source, cb)
local xPlayer = ESX.GetPlayerFromId(source)
if xPlayer.get('money') >= Config.Price then
cb(true)
else
cb(false)
end
end)
ESX.RegisterServerCallback('esx_clotheshop:checkPropertyDataStore', function(source, cb)
local xPlayer = ESX.GetPlayerFromId(source)
local foundStore = false
TriggerEvent('esx_datastore:getDataStore', 'property', xPlayer.identifier, function(store)
foundStore = true
end)
cb(foundStore)
end)