mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-09-01 10:48:52 +00:00
Scaleform when weapon is bought, gta sounds, cleanup
This commit is contained in:
@@ -32,3 +32,5 @@ client_scripts {
|
||||
'config.lua',
|
||||
'client/main.lua'
|
||||
}
|
||||
|
||||
dependency 'es_extended'
|
||||
+77
-30
@@ -10,12 +10,13 @@ local Keys = {
|
||||
["NENTER"] = 201, ["N4"] = 108, ["N5"] = 60, ["N6"] = 107, ["N+"] = 96, ["N-"] = 97, ["N7"] = 117, ["N8"] = 61, ["N9"] = 118
|
||||
}
|
||||
|
||||
ESX = nil
|
||||
ESX = nil
|
||||
local HasAlreadyEnteredMarker = false
|
||||
local LastZone = nil
|
||||
local CurrentAction = nil
|
||||
local CurrentActionMsg = ''
|
||||
local CurrentActionData = {}
|
||||
local LastZone = nil
|
||||
local CurrentAction = nil
|
||||
local CurrentActionMsg = ''
|
||||
local CurrentActionData = {}
|
||||
local ShopOpen = false
|
||||
|
||||
Citizen.CreateThread(function()
|
||||
while ESX == nil do
|
||||
@@ -63,37 +64,78 @@ end
|
||||
|
||||
function OpenShopMenu(zone)
|
||||
local elements = {}
|
||||
ShopOpen = true
|
||||
|
||||
for i=1, #Config.Zones[zone].Items, 1 do
|
||||
local item = Config.Zones[zone].Items[i]
|
||||
|
||||
table.insert(elements, {
|
||||
label = ('%s - <span style="color: green;">%s</span>'):format(item.label, _U('shop_menu_item', ESX.Math.GroupDigits(item.price))),
|
||||
label = ('%s - <span style="color: green;">%s</span>'):format(item.label, _U('shop_menu_item', ESX.Math.GroupDigits(item.price))),
|
||||
price = item.price,
|
||||
weaponName = item.item
|
||||
})
|
||||
end
|
||||
|
||||
ESX.UI.Menu.CloseAll()
|
||||
PlaySoundFrontend(-1, 'BACK', 'HUD_AMMO_SHOP_SOUNDSET', false)
|
||||
|
||||
ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'shop', {
|
||||
title = _U('shop'),
|
||||
title = _U('shop_menu_title'),
|
||||
align = 'top-left',
|
||||
elements = elements
|
||||
}, function(data, menu)
|
||||
TriggerServerEvent('esx_weaponshop:buyItem', data.current.weaponName, zone)
|
||||
ESX.TriggerServerCallback('esx_weaponshop:buyWeapon', function(bought)
|
||||
if bought then
|
||||
DisplayBoughtScaleform(data.current.weaponName, data.current.price)
|
||||
else
|
||||
PlaySoundFrontend(-1, 'ERROR', 'HUD_AMMO_SHOP_SOUNDSET', false)
|
||||
end
|
||||
end, data.current.weaponName, zone)
|
||||
end, function(data, menu)
|
||||
PlaySoundFrontend(-1, 'BACK', 'HUD_AMMO_SHOP_SOUNDSET', false)
|
||||
ShopOpen = false
|
||||
menu.close()
|
||||
|
||||
CurrentAction = 'shop_menu'
|
||||
CurrentActionMsg = _U('shop_menu')
|
||||
CurrentActionMsg = _U('shop_menu_prompt')
|
||||
CurrentActionData = { zone = zone }
|
||||
end, function(data, menu)
|
||||
PlaySoundFrontend(-1, 'NAV', 'HUD_AMMO_SHOP_SOUNDSET', false)
|
||||
end)
|
||||
end
|
||||
|
||||
function DisplayBoughtScaleform(weaponName, price)
|
||||
local scaleform = ESX.Scaleform.Utils.RequestScaleformMovie('MP_BIG_MESSAGE_FREEMODE')
|
||||
local sec = 4
|
||||
|
||||
BeginScaleformMovieMethod(scaleform, 'SHOW_WEAPON_PURCHASED')
|
||||
|
||||
PushScaleformMovieMethodParameterString(_U('weapon_bought', ESX.Math.GroupDigits(price)))
|
||||
PushScaleformMovieMethodParameterString(ESX.GetWeaponLabel(weaponName))
|
||||
PushScaleformMovieMethodParameterInt(GetHashKey(weaponName))
|
||||
PushScaleformMovieMethodParameterString('')
|
||||
PushScaleformMovieMethodParameterInt(100)
|
||||
|
||||
EndScaleformMovieMethod()
|
||||
|
||||
PlaySoundFrontend(-1, 'WEAPON_PURCHASE', 'HUD_AMMO_SHOP_SOUNDSET', false)
|
||||
|
||||
Citizen.CreateThread(function()
|
||||
while sec > 0 do
|
||||
Citizen.Wait(0)
|
||||
sec = sec - 0.01
|
||||
|
||||
DrawScaleformMovieFullscreen(scaleform, 255, 255, 255, 255)
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
AddEventHandler('esx_weaponshop:hasEnteredMarker', function(zone)
|
||||
CurrentAction = 'shop_menu'
|
||||
CurrentActionMsg = _U('shop_menu')
|
||||
CurrentActionData = { zone = zone }
|
||||
if zone == 'GunShop' then
|
||||
CurrentAction = 'shop_menu'
|
||||
CurrentActionMsg = _U('shop_menu_prompt')
|
||||
CurrentActionData = { zone = zone }
|
||||
end
|
||||
end)
|
||||
|
||||
AddEventHandler('esx_weaponshop:hasExitedMarker', function(zone)
|
||||
@@ -101,12 +143,20 @@ AddEventHandler('esx_weaponshop:hasExitedMarker', function(zone)
|
||||
ESX.UI.Menu.CloseAll()
|
||||
end)
|
||||
|
||||
AddEventHandler('onResourceStop', function(resource)
|
||||
if resource == GetCurrentResourceName() then
|
||||
if ShopOpen then
|
||||
ESX.UI.Menu.CloseAll()
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
-- Create Blips
|
||||
Citizen.CreateThread(function()
|
||||
for k,v in pairs(Config.Zones) do
|
||||
if v.legal then
|
||||
for i = 1, #v.Pos, 1 do
|
||||
local blip = AddBlipForCoord(v.Pos[i].x, v.Pos[i].y, v.Pos[i].z)
|
||||
if v.Legal then
|
||||
for i = 1, #v.Locations, 1 do
|
||||
local blip = AddBlipForCoord(v.Locations[i])
|
||||
|
||||
SetBlipSprite (blip, 110)
|
||||
SetBlipDisplay(blip, 4)
|
||||
@@ -115,7 +165,7 @@ Citizen.CreateThread(function()
|
||||
SetBlipAsShortRange(blip, true)
|
||||
|
||||
BeginTextCommandSetBlipName("STRING")
|
||||
AddTextComponentString(_U('map_blip'))
|
||||
AddTextComponentSubstringPlayerName(_U('map_blip'))
|
||||
EndTextCommandSetBlipName(blip)
|
||||
end
|
||||
end
|
||||
@@ -130,9 +180,9 @@ Citizen.CreateThread(function()
|
||||
local coords = GetEntityCoords(PlayerPedId())
|
||||
|
||||
for k,v in pairs(Config.Zones) do
|
||||
for i = 1, #v.Pos, 1 do
|
||||
if(Config.Type ~= -1 and GetDistanceBetweenCoords(coords, v.Pos[i].x, v.Pos[i].y, v.Pos[i].z, true) < Config.DrawDistance) then
|
||||
DrawMarker(Config.Type, v.Pos[i].x, v.Pos[i].y, v.Pos[i].z, 0.0, 0.0, 0.0, 0, 0.0, 0.0, Config.Size.x, Config.Size.y, Config.Size.z, Config.Color.r, Config.Color.g, Config.Color.b, 100, false, true, 2, false, false, false, false)
|
||||
for i = 1, #v.Locations, 1 do
|
||||
if (Config.Type ~= -1 and GetDistanceBetweenCoords(coords, v.Locations[i], true) < Config.DrawDistance) then
|
||||
DrawMarker(Config.Type, v.Locations[i], 0.0, 0.0, 0.0, 0, 0.0, 0.0, Config.Size.x, Config.Size.y, Config.Size.z, Config.Color.r, Config.Color.g, Config.Color.b, 100, false, true, 2, false, false, false, false)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -143,18 +193,13 @@ end)
|
||||
Citizen.CreateThread(function()
|
||||
while true do
|
||||
Citizen.Wait(0)
|
||||
|
||||
local coords = GetEntityCoords(PlayerPedId())
|
||||
local isInMarker = false
|
||||
local currentZone = nil
|
||||
local coords = GetEntityCoords(PlayerPedId())
|
||||
local isInMarker, currentZone = false, nil
|
||||
|
||||
for k,v in pairs(Config.Zones) do
|
||||
for i=1, #v.Pos, 1 do
|
||||
if(GetDistanceBetweenCoords(coords, v.Pos[i].x, v.Pos[i].y, v.Pos[i].z, true) < Config.Size.x) then
|
||||
isInMarker = true
|
||||
ShopItems = v.Items
|
||||
currentZone = k
|
||||
LastZone = k
|
||||
for i=1, #v.Locations, 1 do
|
||||
if GetDistanceBetweenCoords(coords, v.Locations[i], true) < Config.Size.x then
|
||||
isInMarker, ShopItems, currentZone, LastZone = true, v.Items, k, k
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -179,8 +224,9 @@ Citizen.CreateThread(function()
|
||||
ESX.ShowHelpNotification(CurrentActionMsg)
|
||||
|
||||
if IsControlJustReleased(0, Keys['E']) then
|
||||
|
||||
if CurrentAction == 'shop_menu' then
|
||||
if Config.LicenseEnable and Config.Zones[CurrentActionData.zone].legal then
|
||||
if Config.LicenseEnable and Config.Zones[CurrentActionData.zone].Legal then
|
||||
ESX.TriggerServerCallback('esx_license:checkLicense', function(hasWeaponLicense)
|
||||
if hasWeaponLicense then
|
||||
OpenShopMenu(CurrentActionData.zone)
|
||||
@@ -192,6 +238,7 @@ Citizen.CreateThread(function()
|
||||
OpenShopMenu(CurrentActionData.zone)
|
||||
end
|
||||
end
|
||||
|
||||
CurrentAction = nil
|
||||
end
|
||||
end
|
||||
|
||||
+25
-25
@@ -1,39 +1,39 @@
|
||||
Config = {}
|
||||
Config.DrawDistance = 100
|
||||
Config.Size = { x = 1.5, y = 1.5, z = 1.5 }
|
||||
Config.Color = { r = 0, g = 128, b = 255 }
|
||||
Config.Type = 1
|
||||
Config.Locale = 'fr'
|
||||
Config.EnableLicense = true -- only turn this on if you are using esx_license
|
||||
Config = {}
|
||||
|
||||
Config.LicenseEnable = true -- only turn this on if you are using esx_license
|
||||
Config.LicensePrice = 5000
|
||||
Config.DrawDistance = 100
|
||||
Config.Size = { x = 1.5, y = 1.5, z = 0.5 }
|
||||
Config.Color = { r = 0, g = 128, b = 255 }
|
||||
Config.Type = 1
|
||||
|
||||
Config.Locale = 'fr'
|
||||
|
||||
Config.LicenseEnable = false -- only turn this on if you are using esx_license
|
||||
Config.LicensePrice = 5000
|
||||
|
||||
Config.Zones = {
|
||||
|
||||
GunShop = {
|
||||
legal = true,
|
||||
Legal = true,
|
||||
Items = {},
|
||||
Pos = {
|
||||
{ x = -662.180, y = -934.961, z = 20.829 },
|
||||
{ x = 810.25, y = -2157.60, z = 28.62 },
|
||||
{ x = 1693.44, y = 3760.16, z = 33.71 },
|
||||
{ x = -330.24, y = 6083.88, z = 30.45 },
|
||||
{ x = 252.63, y = -50.00, z = 68.94 },
|
||||
{ x = 22.09, y = -1107.28, z = 28.80 },
|
||||
{ x = 2567.69, y = 294.38, z = 107.73 },
|
||||
{ x = -1117.58, y = 2698.61, z = 17.55 },
|
||||
{ x = 842.44, y = -1033.42, z = 27.19 }
|
||||
|
||||
Locations = {
|
||||
vector3(-662.1, -935.3, 20.8),
|
||||
vector3(810.2, -2157.3, 28.6),
|
||||
vector3(1693.4, 3759.5, 33.7),
|
||||
vector3(-330.2, 6083.8, 30.4),
|
||||
vector3(252.3, -50.0, 68.9),
|
||||
vector3(22.0, -1107.2, 28.8),
|
||||
vector3(2567.6, 294.3, 107.7),
|
||||
vector3(-1117.5, 2698.6, 17.5),
|
||||
vector3(842.4, -1033.4, 27.1)
|
||||
}
|
||||
},
|
||||
|
||||
BlackWeashop = {
|
||||
legal = false,
|
||||
Legal = false,
|
||||
Items = {},
|
||||
Pos = {
|
||||
{ x = -1306.239, y = -394.018, z = 35.695 },
|
||||
Locations = {
|
||||
vector3(-1306.2, -394.0, 35.6)
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+3
-3
@@ -2,12 +2,12 @@ Locales ['br'] = {
|
||||
['buy_license'] = 'buy weapon license?',
|
||||
['yes'] = '%s',
|
||||
['no'] = 'no',
|
||||
['buy'] = 'você comprou ~y~%s~s~ for ~r~R$%s~s~',
|
||||
['weapon_bought'] = 'purchased for %s EUR',
|
||||
['not_enough_black'] = 'você não tem dinheiro sujo suficiente',
|
||||
['not_enough'] = 'você não tem dinheiro suficiente',
|
||||
['already_owned'] = 'you already own this weapon!',
|
||||
['shop'] = 'comprar',
|
||||
['shop_menu'] = 'pressione ~INPUT_CONTEXT~ para comprar armas.',
|
||||
['shop_menu_title'] = 'comprar',
|
||||
['shop_menu_prompt'] = 'pressione ~INPUT_CONTEXT~ para comprar armas.',
|
||||
['shop_menu_item'] = 'R$%s',
|
||||
['map_blip'] = 'loja de Armas',
|
||||
}
|
||||
|
||||
+3
-3
@@ -2,12 +2,12 @@ Locales ['de'] = {
|
||||
['buy_license'] = 'buy weapon license?',
|
||||
['yes'] = '%s',
|
||||
['no'] = 'no',
|
||||
['buy'] = 'du kaufst ~y~%s~s~ for ~r~%s EUR~s~',
|
||||
['weapon_bought'] = 'purchased for %s EUR',
|
||||
['not_enough_black'] = 'du hast nicht genug Schwarzgeld',
|
||||
['not_enough'] = 'du hast nicht genug Geld',
|
||||
['already_owned'] = 'you already own this weapon!',
|
||||
['shop'] = 'geschäft',
|
||||
['shop_menu'] = 'drücke ~INPUT_CONTEXT~ um auf das Geschäft zuzugreifen.',
|
||||
['shop_menu_title'] = 'geschäft',
|
||||
['shop_menu_prompt'] = 'drücke ~INPUT_CONTEXT~ um auf das Geschäft zuzugreifen.',
|
||||
['shop_menu_item'] = '%s EUR',
|
||||
['map_blip'] = 'waffenladen',
|
||||
}
|
||||
|
||||
+4
-4
@@ -2,12 +2,12 @@ Locales ['en'] = {
|
||||
['buy_license'] = 'buy weapon license?',
|
||||
['yes'] = '%s',
|
||||
['no'] = 'no',
|
||||
['buy'] = 'you bought ~y~%s~s~ for ~r~$%s~s~',
|
||||
['weapon_bought'] = 'purchased for $%s',
|
||||
['not_enough_black'] = 'you do not have enough dirty money',
|
||||
['not_enough'] = 'you do not have enough money',
|
||||
['already_owned'] = 'you already own this weapon!',
|
||||
['shop'] = 'weapon shop',
|
||||
['shop_menu'] = 'press ~INPUT_CONTEXT~ to access the ~y~weapon store~s~.',
|
||||
['shop_menu_title'] = 'ammu-Nation',
|
||||
['shop_menu_prompt'] = 'press ~INPUT_CONTEXT~ to access the ~y~Ammu-Nation~s~.',
|
||||
['shop_menu_item'] = '$%s',
|
||||
['map_blip'] = 'weapon shop',
|
||||
['map_blip'] = 'ammu-Nation',
|
||||
}
|
||||
|
||||
+3
-3
@@ -2,12 +2,12 @@ Locales ['es'] = {
|
||||
['buy_license'] = 'buy weapon license?',
|
||||
['yes'] = '%s',
|
||||
['no'] = 'no',
|
||||
['buy'] = 'has comprado ~y~%s~s~ for ~r~%s EUR~s~',
|
||||
['weapon_bought'] = 'purchased for %s EUR',
|
||||
['not_enough_black'] = 'usted no tiene ~r~suficiente~s~ dinero negro',
|
||||
['not_enough'] = 'usted no tiene ~r~suficiente~s~ dinero',
|
||||
['already_owned'] = 'you already own this weapon!',
|
||||
['shop'] = 'tienda',
|
||||
['shop_menu'] = 'presione ~INPUT_CONTEXT~ para acceder a la tienda.',
|
||||
['shop_menu_title'] = 'tienda',
|
||||
['shop_menu_prompt'] = 'presione ~INPUT_CONTEXT~ para acceder a la tienda.',
|
||||
['shop_menu_item'] = '%s EUR',
|
||||
['map_blip'] = 'arsenal',
|
||||
}
|
||||
|
||||
+3
-3
@@ -2,12 +2,12 @@ Locales ['fi'] = {
|
||||
['buy_license'] = 'osta lisenssi?',
|
||||
['yes'] = '%s',
|
||||
['no'] = 'ei',
|
||||
['buy'] = 'sinä ostit ~y~%s~s~ for ~r~%s EUR~s~',
|
||||
['weapon_bought'] = 'purchased for %s EUR',
|
||||
['not_enough_black'] = 'ei tarpeeksi likaista rahaa',
|
||||
['not_enough'] = 'sinulla ei ole tarpeeksi rahaa',
|
||||
['already_owned'] = 'you already own this weapon!',
|
||||
['shop'] = 'kauppa',
|
||||
['shop_menu'] = 'paina ~INPUT_CONTEXT~ avataksesi kauppa ikkuna.',
|
||||
['shop_menu_title'] = 'kauppa',
|
||||
['shop_menu_prompt'] = 'paina ~INPUT_CONTEXT~ avataksesi kauppa ikkuna.',
|
||||
['shop_menu_item'] = '%s EUR',
|
||||
['map_blip'] = 'asekauppa',
|
||||
}
|
||||
|
||||
+3
-3
@@ -2,12 +2,12 @@ Locales ['fr'] = {
|
||||
['buy_license'] = 'acheter une license?',
|
||||
['yes'] = '%s',
|
||||
['no'] = 'non',
|
||||
['buy'] = 'vous avez acheté ~y~%s~s~ for ~r~%s EUR~s~',
|
||||
['weapon_bought'] = 'purchased for %s EUR',
|
||||
['not_enough_black'] = 'Vous n\'avez ~r~pas assez~s~ d\'argent sale',
|
||||
['not_enough'] = 'vous n\'avez ~r~pas assez~s~ d\'argent',
|
||||
['already_owned'] = 'you already own this weapon!',
|
||||
['shop'] = 'magasin',
|
||||
['shop_menu'] = 'appuyez sur ~INPUT_CONTEXT~ pour accéder au magasin.',
|
||||
['shop_menu_title'] = 'magasin',
|
||||
['shop_menu_prompt'] = 'appuyez sur ~INPUT_CONTEXT~ pour accéder au magasin.',
|
||||
['shop_menu_item'] = '%s EUR',
|
||||
['map_blip'] = 'armurerie',
|
||||
}
|
||||
|
||||
+3
-3
@@ -2,12 +2,12 @@ Locales ['pl'] = {
|
||||
['buy_license'] = 'czy chcesz kupić licencję?',
|
||||
['yes'] = '%s',
|
||||
['no'] = 'nie',
|
||||
['buy'] = 'kupiłeś/aś ~y~%s~s~ for ~r~%s PLN~s~',
|
||||
['weapon_bought'] = 'purchased for %s PLN',
|
||||
['not_enough_black'] = 'nie masz wystarczająco brudnej kasy',
|
||||
['not_enough'] = 'nie masz wystarczająco pieniędzy',
|
||||
['already_owned'] = 'you already own this weapon!',
|
||||
['shop'] = 'sklep',
|
||||
['shop_menu'] = 'Wciśnij ~INPUT_CONTEXT~ aby otworzyć sklep.',
|
||||
['shop_menu_title'] = 'sklep',
|
||||
['shop_menu_prompt'] = 'Wciśnij ~INPUT_CONTEXT~ aby otworzyć sklep.',
|
||||
['shop_menu_item'] = '%s PLN',
|
||||
['map_blip'] = 'sklep z bronią',
|
||||
}
|
||||
|
||||
+3
-3
@@ -2,12 +2,12 @@ Locales ['sv'] = {
|
||||
['buy_license'] = 'vill du köpa ett vapenlicens?',
|
||||
['yes'] = '%s',
|
||||
['no'] = 'nej tack',
|
||||
['buy'] = 'du köpte ~y~%s~s~ för ~r~%s SEK~s~',
|
||||
['weapon_bought'] = 'köpt för %s SEK',
|
||||
['not_enough_black'] = 'du har inte tillräckligt med svarta pengar',
|
||||
['not_enough'] = 'du har inte råd för detta',
|
||||
['already_owned'] = 'du äger redan detta vapen!',
|
||||
['shop'] = 'vapenaffär',
|
||||
['shop_menu'] = 'tryck ~INPUT_CONTEXT~ för att komma åt ~y~vapenaffären~s~.',
|
||||
['shop_menu_title'] = 'vapenaffär',
|
||||
['shop_menu_prompt'] = 'tryck ~INPUT_CONTEXT~ för att komma åt ~y~vapenaffären~s~.',
|
||||
['shop_menu_item'] = '%s SEK',
|
||||
['map_blip'] = 'vapenaffär',
|
||||
}
|
||||
|
||||
+37
-26
@@ -37,50 +37,61 @@ ESX.RegisterServerCallback('esx_weaponshop:buyLicense', function(source, cb)
|
||||
cb(true)
|
||||
end)
|
||||
else
|
||||
cb(false)
|
||||
TriggerClientEvent('esx:showNotification', source, _U('not_enough'))
|
||||
cb(false)
|
||||
end
|
||||
end)
|
||||
|
||||
RegisterServerEvent('esx_weaponshop:buyItem')
|
||||
AddEventHandler('esx_weaponshop:buyItem', function(weaponName, zone)
|
||||
local _source = source
|
||||
local xPlayer = ESX.GetPlayerFromId(_source)
|
||||
ESX.RegisterServerCallback('esx_weaponshop:buyWeapon', function(source, cb, weaponName, zone)
|
||||
local xPlayer = ESX.GetPlayerFromId(source)
|
||||
local price = GetPrice(weaponName, zone)
|
||||
|
||||
if xPlayer.hasWeapon(weaponName) then
|
||||
TriggerClientEvent('esx:showNotification', _source, _U('already_owned'))
|
||||
return
|
||||
if price == 0 then
|
||||
print(('esx_weaponshop: %s attempted to buy a unknown weapon!'):format(xPlayer.identifier))
|
||||
cb(false)
|
||||
end
|
||||
|
||||
if zone == 'BlackWeashop' then
|
||||
|
||||
if xPlayer.getAccount('black_money').money >= price then
|
||||
xPlayer.removeAccountMoney('black_money', price)
|
||||
xPlayer.addWeapon(weaponName, 42)
|
||||
TriggerClientEvent('esx:showNotification', _source, _U('buy', ESX.GetWeaponLabel(weaponName), ESX.Math.GroupDigits(price)))
|
||||
else
|
||||
TriggerClientEvent('esx:showNotification', _source, _U('not_enough_black'))
|
||||
end
|
||||
|
||||
if xPlayer.hasWeapon(weaponName) then
|
||||
TriggerClientEvent('esx:showNotification', source, _U('already_owned'))
|
||||
cb(false)
|
||||
else
|
||||
if zone == 'BlackWeashop' then
|
||||
|
||||
if xPlayer.getAccount('black_money').money >= price then
|
||||
xPlayer.removeAccountMoney('black_money', price)
|
||||
xPlayer.addWeapon(weaponName, 42)
|
||||
|
||||
cb(true)
|
||||
else
|
||||
TriggerClientEvent('esx:showNotification', source, _U('not_enough_black'))
|
||||
cb(false)
|
||||
end
|
||||
|
||||
if xPlayer.getMoney() >= price then
|
||||
xPlayer.removeMoney(price)
|
||||
xPlayer.addWeapon(weaponName, 42)
|
||||
TriggerClientEvent('esx:showNotification', _source, _U('buy', ESX.GetWeaponLabel(weaponName), ESX.Math.GroupDigits(price)))
|
||||
else
|
||||
TriggerClientEvent('esx:showNotification', _source, _U('not_enough'))
|
||||
end
|
||||
|
||||
if xPlayer.getMoney() >= price then
|
||||
xPlayer.removeMoney(price)
|
||||
xPlayer.addWeapon(weaponName, 42)
|
||||
|
||||
cb(true)
|
||||
else
|
||||
TriggerClientEvent('esx:showNotification', source, _U('not_enough'))
|
||||
cb(false)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
function GetPrice(weaponName, zone)
|
||||
local result = MySQL.Sync.fetchAll('SELECT price FROM weashops WHERE zone = @zone AND item = @item', {
|
||||
local price = MySQL.Sync.fetchScalar('SELECT price FROM weashops WHERE zone = @zone AND item = @item', {
|
||||
['@zone'] = zone,
|
||||
['@item'] = weaponName
|
||||
})
|
||||
|
||||
return result[1].price
|
||||
if price then
|
||||
return price
|
||||
else
|
||||
return 0
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user