Files
esx_core/server/main.lua
T
2018-07-03 13:05:23 +02:00

52 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 _source = source
local xPlayer = ESX.GetPlayerFromId(_source)
xPlayer.removeMoney(Config.Price)
TriggerClientEvent('esx:showNotification', _source, _U('you_paid', Config.Price))
end)
RegisterServerEvent('esx_clotheshop:saveOutfit')
AddEventHandler('esx_clotheshop:saveOutfit', function(label, skin)
local _source = source
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)
cb(xPlayer.get('money') >= Config.Price)
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)