-
Notifications
You must be signed in to change notification settings - Fork 0
/
s-main.lua
41 lines (31 loc) · 975 Bytes
/
s-main.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
ESX = nil
TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
ESX.RegisterServerCallback('dk-weaponshop:buyLicense', function(source, cb)
local xPlayer = ESX.GetPlayerFromId(source)
if xPlayer.getMoney() >= Config.LicensePrice then
xPlayer.removeMoney(Config.LicensePrice)
TriggerEvent('esx_license:addLicense', source, 'weapon', function()
cb(true)
end)
else
xPlayer.showNotification(_U('not_enough'))
cb(false)
end
end)
ESX.RegisterServerCallback('dk-weaponshop:buyWeapon', function(source, cb, weaponName,identifier)
local xPlayer = ESX.GetPlayerFromId(source)
local price = Config.Weapons[identifier].price
if xPlayer.hasWeapon(weaponName) then
xPlayer.showNotification(_U('already_owned'))
cb(false)
else
if xPlayer.getMoney() >= price then
xPlayer.removeMoney(price)
xPlayer.addWeapon(weaponName, 42)
cb(true)
else
xPlayer.showNotification(_U('not_enough'))
cb(false)
end
end
end)