This commit is contained in:
2026-07-07 21:08:52 +02:00
commit 4c20cfc716
2613 changed files with 318021 additions and 0 deletions

View File

@@ -0,0 +1,64 @@
ESX.RegisterServerCallback('esx_weaponshop:buyLicense', function(source, cb)
local xPlayer = ESX.Player(source)
if xPlayer.getMoney() >= Config.LicensePrice then
xPlayer.removeMoney(Config.LicensePrice, "Weapon License")
TriggerEvent('esx_license:addLicense', source, 'weapon', function()
cb(true)
end)
else
xPlayer.showNotification(TranslateCap('not_enough'))
cb(false)
end
end)
ESX.RegisterServerCallback('esx_weaponshop:buyWeapon', function(source, cb, weaponName, zone)
local xPlayer = ESX.Player(source)
local price = GetPrice(weaponName, zone)
if price <= 0 then
print(('[^3WARNING^7] Player ^5%s^7 attempted to buy Invalid weapon - %s!'):format(source, weaponName))
cb(false)
else
if xPlayer.hasWeapon(weaponName) then
xPlayer.showNotification(TranslateCap('already_owned'))
cb(false)
else
if zone == 'BlackWeashop' then
if xPlayer.getAccount('black_money').money >= price then
xPlayer.removeAccountMoney('black_money', price, "Black Weapons Deal")
xPlayer.addWeapon(weaponName, 42)
cb(true)
else
xPlayer.showNotification(TranslateCap('not_enough_black'))
cb(false)
end
else
if xPlayer.getMoney() >= price then
xPlayer.removeMoney(price, "Weapons Deal")
xPlayer.addWeapon(weaponName, 42)
cb(true)
else
xPlayer.showNotification(TranslateCap('not_enough'))
cb(false)
end
end
end
end
end)
function GetPrice(weaponName, zone)
for i=1, #(Config.Zones[zone].Items) do
if Config.Zones[zone].Items[i].name == weaponName then
local weapon = Config.Zones[zone].Items[i]
return weapon.price
end
end
return -1
end