Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function OpenBuyWeaponsMenu()
- local elements = {}
- local playerPed = PlayerPedId()
- PlayerData = ESX.GetPlayerData()
- for k,v in ipairs(Config.AuthorizedWeapons[PlayerData.job.grade_name]) do
- local weaponNum, weapon = ESX.GetWeapon(v.weapon)
- local components, label = {}
- local hasWeapon = HasPedGotWeapon(playerPed, GetHashKey(v.weapon), false)
- if v.components then
- for i=1, #v.components do
- if v.components[i] then
- local component = weapon.components[i]
- local hasComponent = HasPedGotWeaponComponent(playerPed, GetHashKey(v.weapon), component.hash)
- if hasComponent then
- label = ('%s: <span style="color:green;">%s</span>'):format(component.label, _U('armory_owned'))
- else
- if v.components[i] > 0 then
- label = ('%s: <span style="color:green;">%s</span>'):format(component.label, _U('armory_item', ESX.Math.GroupDigits(v.components[i])))
- else
- label = ('%s: <span style="color:green;">%s</span>'):format(component.label, _U('armory_free'))
- end
- end
- table.insert(components, {
- label = label,
- componentLabel = component.label,
- hash = component.hash,
- name = component.name,
- price = v.components[i],
- hasComponent = hasComponent,
- componentNum = i
- })
- end
- end
- end
- if hasWeapon and v.components then
- label = ('%s: <span style="color:green;">></span>'):format(weapon.label)
- elseif hasWeapon and not v.components then
- label = ('%s: <span style="color:green;">%s</span>'):format(weapon.label, _U('armory_owned'))
- else
- if v.price > 0 then
- label = ('%s: <span style="color:green;">%s</span>'):format(weapon.label, _U('armory_item', ESX.Math.GroupDigits(v.price)))
- else
- label = ('%s: <span style="color:green;">%s</span>'):format(weapon.label, _U('armory_free'))
- end
- end
- table.insert(elements, {
- label = label,
- weaponLabel = weapon.label,
- name = weapon.name,
- components = components,
- price = v.price,
- hasWeapon = hasWeapon
- })
- end
- ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'armory_buy_weapons', {
- title = _U('armory_weapontitle'),
- align = 'bottom-right',
- elements = elements
- }, function(data, menu)
- if data.current.hasWeapon then
- if #data.current.components > 0 then
- OpenWeaponComponentShop(data.current.components, data.current.name, menu)
- end
- else
- ESX.TriggerServerCallback('esx_policejob:buyWeapon', function(bought)
- if bought then
- if data.current.price > 0 then
- ESX.ShowNotification(_U('armory_bought', data.current.weaponLabel, ESX.Math.GroupDigits(data.current.price)))
- end
- menu.close()
- OpenBuyWeaponsMenu()
- else
- ESX.ShowNotification(_U('armory_money'))
- end
- end, data.current.name, 1)
- end
- end, function(data, menu)
- menu.close()
- end)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement