From 77ff73d6991aa303da98e38d72cb6cd38a060612 Mon Sep 17 00:00:00 2001 From: ElPumpo Date: Tue, 1 Jan 2019 15:50:19 +0100 Subject: [PATCH] Re wrote police armory. Components supported too! --- client/main.lua | 458 +++++++++++++++++++++++------------------------- config.lua | 61 +++++-- locales/br.lua | 20 +-- locales/de.lua | 20 +-- locales/en.lua | 26 +-- locales/es.lua | 20 +-- locales/fi.lua | 20 +-- locales/fr.lua | 20 +-- locales/pl.lua | 20 +-- locales/sv.lua | 24 +-- server/main.lua | 57 ++++-- 11 files changed, 392 insertions(+), 354 deletions(-) diff --git a/client/main.lua b/client/main.lua index 6aeac42a..c636ed4a 100644 --- a/client/main.lua +++ b/client/main.lua @@ -10,24 +10,21 @@ local Keys = { ["NENTER"] = 201, ["N4"] = 108, ["N5"] = 60, ["N6"] = 107, ["N+"] = 96, ["N-"] = 97, ["N7"] = 117, ["N8"] = 61, ["N9"] = 118 } -local PlayerData = {} +local PlayerData = {} local HasAlreadyEnteredMarker = false -local LastStation = nil -local LastPart = nil -local LastPartNum = nil -local LastEntity = nil -local CurrentAction = nil -local CurrentActionMsg = '' -local CurrentActionData = {} -local IsHandcuffed = false -local HandcuffTimer = {} -local DragStatus = {} -DragStatus.IsDragged = false -local hasAlreadyJoined = false -local blipsCops = {} -local isDead = false -local CurrentTask = {} -local playerInService = false +local LastStation, LastPart, LastPartNum, LastEntity +local CurrentAction = nil +local CurrentActionMsg = '' +local CurrentActionData = {} +local IsHandcuffed = false +local HandcuffTimer = {} +local DragStatus = {} +DragStatus.IsDragged = false +local hasAlreadyJoined = false +local blipsCops = {} +local isDead = false +local CurrentTask = {} +local playerInService = false ESX = nil @@ -255,8 +252,6 @@ function OpenCloakroomMenu() end - - end, function(data, menu) menu.close() @@ -267,82 +262,45 @@ function OpenCloakroomMenu() end function OpenArmoryMenu(station) + local elements = { + {label = _U('buy_weapons'), value = 'buy_weapons'} + } if Config.EnableArmoryManagement then - - local elements = { - {label = _U('get_weapon'), value = 'get_weapon'}, - {label = _U('put_weapon'), value = 'put_weapon'}, - {label = _U('remove_object'), value = 'get_stock'}, - {label = _U('deposit_object'), value = 'put_stock'} - } - - if PlayerData.job.grade_name == 'boss' then - table.insert(elements, {label = _U('buy_weapons'), value = 'buy_weapons'}) - end - - ESX.UI.Menu.CloseAll() - - ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'armory', - { - title = _U('armory'), - align = 'top-left', - elements = elements - }, function(data, menu) - - if data.current.value == 'get_weapon' then - OpenGetWeaponMenu() - elseif data.current.value == 'put_weapon' then - OpenPutWeaponMenu() - elseif data.current.value == 'buy_weapons' then - OpenBuyWeaponsMenu(station) - elseif data.current.value == 'put_stock' then - OpenPutStocksMenu() - elseif data.current.value == 'get_stock' then - OpenGetStocksMenu() - end - - end, function(data, menu) - menu.close() - - CurrentAction = 'menu_armory' - CurrentActionMsg = _U('open_armory') - CurrentActionData = {station = station} - end) - - else - - local elements = {} - - for i=1, #Config.PoliceStations[station].AuthorizedWeapons, 1 do - local weapon = Config.PoliceStations[station].AuthorizedWeapons[i] - - table.insert(elements, { - label = ESX.GetWeaponLabel(weapon.name), - value = weapon.name - }) - end - - ESX.UI.Menu.CloseAll() - - ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'armory', - { - title = _U('armory'), - align = 'top-left', - elements = elements - }, function(data, menu) - local weapon = data.current.value - TriggerServerEvent('esx_policejob:giveWeapon', weapon, 1000) - end, function(data, menu) - menu.close() - - CurrentAction = 'menu_armory' - CurrentActionMsg = _U('open_armory') - CurrentActionData = {station = station} - end) - + table.insert(elements, {label = _U('get_weapon'), value = 'get_weapon'}) + table.insert(elements, {label = _U('put_weapon'), value = 'put_weapon'}) + table.insert(elements, {label = _U('remove_object'), value = 'get_stock'}) + table.insert(elements, {label = _U('deposit_object'), value = 'put_stock'}) end + ESX.UI.Menu.CloseAll() + + ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'armory', + { + title = _U('armory'), + align = 'top-left', + elements = elements + }, function(data, menu) + + if data.current.value == 'get_weapon' then + OpenGetWeaponMenu() + elseif data.current.value == 'put_weapon' then + OpenPutWeaponMenu() + elseif data.current.value == 'buy_weapons' then + OpenBuyWeaponsMenu() + elseif data.current.value == 'put_stock' then + OpenPutStocksMenu() + elseif data.current.value == 'get_stock' then + OpenGetStocksMenu() + end + + end, function(data, menu) + menu.close() + + CurrentAction = 'menu_armory' + CurrentActionMsg = _U('open_armory') + CurrentActionData = {station = station} + end) end function OpenVehicleSpawnerMenu(station, partNum) @@ -1073,55 +1031,132 @@ function OpenPutWeaponMenu() end) end -function OpenBuyWeaponsMenu(station) +function OpenBuyWeaponsMenu() - ESX.TriggerServerCallback('esx_policejob:getArmoryWeapons', function(weapons) + local elements = {} + local playerPed = PlayerPedId() - local elements = {} + for k,v in ipairs(Config.AuthorizedWeapons[PlayerData.job.grade_name]) do + local weaponNum, weapon = ESX.GetWeapon(v.weapon) + local components, label = {} - for i=1, #Config.PoliceStations[station].AuthorizedWeapons, 1 do - local weapon = Config.PoliceStations[station].AuthorizedWeapons[i] - local count = 0 + local hasWeapon = HasPedGotWeapon(playerPed, GetHashKey(v.weapon), false) - for i=1, #weapons, 1 do - if weapons[i].name == weapon.name then - count = weapons[i].count - break + 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: %s'):format(component.label, _U('armory_owned')) + else + if v.components[i] > 0 then + label = ('%s: %s'):format(component.label, _U('armory_item', ESX.Math.GroupDigits(v.components[i]))) + else + label = ('%s: %s'):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 - - table.insert(elements, { - label = 'x' .. count .. ' ' .. ESX.GetWeaponLabel(weapon.name) .. ' $' .. ESX.Math.GroupDigits(weapon.price), - value = weapon.name, - price = weapon.price - }) end - ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'armory_buy_weapons', - { - title = _U('buy_weapon_menu'), - align = 'top-left', - elements = elements, - }, function(data, menu) + if hasWeapon and v.components then + label = ('%s: >'):format(weapon.label) + elseif hasWeapon and not v.components then + label = ('%s: %s'):format(weapon.label, _U('armory_owned')) + else + if v.price > 0 then + label = ('%s: %s'):format(weapon.label, _U('armory_item', ESX.Math.GroupDigits(v.price))) + else + label = ('%s: %s'):format(weapon.label, _U('armory_free')) + end + end - ESX.TriggerServerCallback('esx_policejob:buy', function(hasEnoughMoney) - if hasEnoughMoney then - ESX.TriggerServerCallback('esx_policejob:addArmoryWeapon', function() - OpenBuyWeaponsMenu(station) - end, data.current.value, false) + 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 = 'top-left', + 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('not_enough_money')) + ESX.ShowNotification(_U('armory_money')) end - end, data.current.price) - - end, function(data, menu) - menu.close() - end) + end, data.current.name, 1) + end + end, function(data, menu) + menu.close() end) end +function OpenWeaponComponentShop(components, weaponName, parentShop) + ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'armory_buy_weapons_components', { + title = _U('armory_componenttitle'), + align = 'top-left', + elements = components + }, function(data, menu) + + if data.current.hasComponent then + ESX.ShowNotification(_U('armory_hascomponent')) + else + ESX.TriggerServerCallback('esx_policejob:buyWeapon', function(bought) + if bought then + if data.current.price > 0 then + ESX.ShowNotification(_U('armory_bought', data.current.componentLabel, ESX.Math.GroupDigits(data.current.price))) + end + + menu.close() + parentShop.close() + + OpenBuyWeaponsMenu() + else + ESX.ShowNotification(_U('armory_money')) + end + end, weaponName, 2, data.current.componentNum) + end + + end, function(data, menu) + menu.close() + end) +end + function OpenGetStocksMenu() ESX.TriggerServerCallback('esx_policejob:getStockItems', function(items) @@ -1588,155 +1623,110 @@ end) Citizen.CreateThread(function() while true do - Citizen.Wait(1) + Citizen.Wait(0) if PlayerData.job ~= nil and PlayerData.job.name == 'police' then local playerPed = PlayerPedId() local coords = GetEntityCoords(playerPed) + local isInMarker, hasExited = false, false + local currentStation, currentPart, currentPartNum for k,v in pairs(Config.PoliceStations) do for i=1, #v.Cloakrooms, 1 do - if GetDistanceBetweenCoords(coords, v.Cloakrooms[i].x, v.Cloakrooms[i].y, v.Cloakrooms[i].z, true) < Config.DrawDistance then - DrawMarker(Config.MarkerType, v.Cloakrooms[i].x, v.Cloakrooms[i].y, v.Cloakrooms[i].z, 0.0, 0.0, 0.0, 0, 0.0, 0.0, Config.MarkerSize.x, Config.MarkerSize.y, Config.MarkerSize.z, Config.MarkerColor.r, Config.MarkerColor.g, Config.MarkerColor.b, 100, false, true, 2, false, false, false, false) + local distance = GetDistanceBetweenCoords(coords, v.Cloakrooms[i].x, v.Cloakrooms[i].y, v.Cloakrooms[i].z, true) + + if distance < Config.DrawDistance then + DrawMarker(20, v.Cloakrooms[i].x, v.Cloakrooms[i].y, v.Cloakrooms[i].z + 1, 0.0, 0.0, 0.0, 0, 0.0, 0.0, 1.0, 1.0, 1.0, Config.MarkerColor.r, Config.MarkerColor.g, Config.MarkerColor.b, 100, false, true, 2, true, false, false, false) + end + + if distance < Config.MarkerSize.x then + isInMarker, currentStation, currentPart, currentPartNum = true, k, 'Cloakroom', i end end for i=1, #v.Armories, 1 do - if GetDistanceBetweenCoords(coords, v.Armories[i].x, v.Armories[i].y, v.Armories[i].z, true) < Config.DrawDistance then - DrawMarker(Config.MarkerType, v.Armories[i].x, v.Armories[i].y, v.Armories[i].z, 0.0, 0.0, 0.0, 0, 0.0, 0.0, Config.MarkerSize.x, Config.MarkerSize.y, Config.MarkerSize.z, Config.MarkerColor.r, Config.MarkerColor.g, Config.MarkerColor.b, 100, false, true, 2, false, false, false, false) + local distance = GetDistanceBetweenCoords(coords, v.Armories[i].x, v.Armories[i].y, v.Armories[i].z, true) + + if distance < Config.DrawDistance then + DrawMarker(21, v.Armories[i].x, v.Armories[i].y, v.Armories[i].z + 1, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.5, 0.5, 0.5, Config.MarkerColor.r, Config.MarkerColor.g, Config.MarkerColor.b, 100, false, true, 2, true, false, false, false) + end + + if distance < Config.MarkerSize.x then + isInMarker, currentStation, currentPart, currentPartNum = true, k, 'Armory', i end end for i=1, #v.Vehicles, 1 do - if GetDistanceBetweenCoords(coords, v.Vehicles[i].Spawner.x, v.Vehicles[i].Spawner.y, v.Vehicles[i].Spawner.z, true) < Config.DrawDistance then - DrawMarker(Config.MarkerType, v.Vehicles[i].Spawner.x, v.Vehicles[i].Spawner.y, v.Vehicles[i].Spawner.z, 0.0, 0.0, 0.0, 0, 0.0, 0.0, Config.MarkerSize.x, Config.MarkerSize.y, Config.MarkerSize.z, Config.MarkerColor.r, Config.MarkerColor.g, Config.MarkerColor.b, 100, false, true, 2, false, false, false, false) + local distance = GetDistanceBetweenCoords(coords, v.Vehicles[i].Spawner.x, v.Vehicles[i].Spawner.y, v.Vehicles[i].Spawner.z, true) + + if distance < Config.DrawDistance then + DrawMarker(36, v.Vehicles[i].Spawner.x, v.Vehicles[i].Spawner.y, v.Vehicles[i].Spawner.z + 1, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, Config.MarkerColor.r, Config.MarkerColor.g, Config.MarkerColor.b, 100, false, true, 2, true, false, false, false) end - end - for i=1, #v.VehicleDeleters, 1 do - if GetDistanceBetweenCoords(coords, v.VehicleDeleters[i].x, v.VehicleDeleters[i].y, v.VehicleDeleters[i].z, true) < Config.DrawDistance then - DrawMarker(Config.MarkerType, v.VehicleDeleters[i].x, v.VehicleDeleters[i].y, v.VehicleDeleters[i].z, 0.0, 0.0, 0.0, 0, 0.0, 0.0, Config.MarkerSize.x, Config.MarkerSize.y, Config.MarkerSize.z, Config.MarkerColor.r, Config.MarkerColor.g, Config.MarkerColor.b, 100, false, true, 2, false, false, false, false) - end - end - - if Config.EnablePlayerManagement and PlayerData.job.grade_name == 'boss' then - for i=1, #v.BossActions, 1 do - if not v.BossActions[i].disabled and GetDistanceBetweenCoords(coords, v.BossActions[i].x, v.BossActions[i].y, v.BossActions[i].z, true) < Config.DrawDistance then - DrawMarker(Config.MarkerType, v.BossActions[i].x, v.BossActions[i].y, v.BossActions[i].z, 0.0, 0.0, 0.0, 0, 0.0, 0.0, Config.MarkerSize.x, Config.MarkerSize.y, Config.MarkerSize.z, Config.MarkerColor.r, Config.MarkerColor.g, Config.MarkerColor.b, 100, false, true, 2, false, false, false, false) - end - end - end - - end - - else - Citizen.Wait(500) - end - - end -end) - --- Enter / Exit marker events -Citizen.CreateThread(function() - - while true do - - Citizen.Wait(100) - - if PlayerData.job ~= nil and PlayerData.job.name == 'police' then - - local playerPed = PlayerPedId() - local coords = GetEntityCoords(playerPed) - local isInMarker = false - local currentStation = nil - local currentPart = nil - local currentPartNum = nil - - for k,v in pairs(Config.PoliceStations) do - - for i=1, #v.Cloakrooms, 1 do - if GetDistanceBetweenCoords(coords, v.Cloakrooms[i].x, v.Cloakrooms[i].y, v.Cloakrooms[i].z, true) < Config.MarkerSize.x then - isInMarker = true - currentStation = k - currentPart = 'Cloakroom' - currentPartNum = i - end - end - - for i=1, #v.Armories, 1 do - if GetDistanceBetweenCoords(coords, v.Armories[i].x, v.Armories[i].y, v.Armories[i].z, true) < Config.MarkerSize.x then - isInMarker = true - currentStation = k - currentPart = 'Armory' - currentPartNum = i - end - end - - for i=1, #v.Vehicles, 1 do - if GetDistanceBetweenCoords(coords, v.Vehicles[i].Spawner.x, v.Vehicles[i].Spawner.y, v.Vehicles[i].Spawner.z, true) < Config.MarkerSize.x then - isInMarker = true - currentStation = k - currentPart = 'VehicleSpawner' - currentPartNum = i + if distance < Config.MarkerSize.x then + isInMarker, currentStation, currentPart, currentPartNum = true, k, 'VehicleSpawner', i end end for i=1, #v.Helicopters, 1 do - if GetDistanceBetweenCoords(coords, v.Helicopters[i].Spawner.x, v.Helicopters[i].Spawner.y, v.Helicopters[i].Spawner.z, true) < Config.MarkerSize.x then - isInMarker = true - currentStation = k - currentPart = 'HelicopterSpawner' - currentPartNum = i + local distance = GetDistanceBetweenCoords(coords, v.Helicopters[i].Spawner.x, v.Helicopters[i].Spawner.y, v.Helicopters[i].Spawner.z, true) + + if distance < Config.MarkerSize.x then + isInMarker, currentStation, currentPart, currentPartNum = true, k, 'HelicopterSpawner', i end end for i=1, #v.VehicleDeleters, 1 do - if GetDistanceBetweenCoords(coords, v.VehicleDeleters[i].x, v.VehicleDeleters[i].y, v.VehicleDeleters[i].z, true) < Config.MarkerSize.x then - isInMarker = true - currentStation = k - currentPart = 'VehicleDeleter' - currentPartNum = i + local distance = GetDistanceBetweenCoords(coords, v.VehicleDeleters[i].x, v.VehicleDeleters[i].y, v.VehicleDeleters[i].z, true) + + if distance < Config.DrawDistance then + DrawMarker(Config.MarkerType, v.VehicleDeleters[i].x, v.VehicleDeleters[i].y, v.VehicleDeleters[i].z, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, Config.MarkerSize.x, Config.MarkerSize.y, Config.MarkerSize.z, Config.MarkerColor.r, Config.MarkerColor.g, Config.MarkerColor.b, 100, false, true, 2, false, false, false, false) + end + + if distance < Config.MarkerSize.x then + isInMarker, currentStation, currentPart, currentPartNum = true, k, 'VehicleDeleter', i end end if Config.EnablePlayerManagement and PlayerData.job.grade_name == 'boss' then for i=1, #v.BossActions, 1 do - if GetDistanceBetweenCoords(coords, v.BossActions[i].x, v.BossActions[i].y, v.BossActions[i].z, true) < Config.MarkerSize.x then - isInMarker = true - currentStation = k - currentPart = 'BossActions' - currentPartNum = i + local distance = GetDistanceBetweenCoords(coords, v.BossActions[i].x, v.BossActions[i].y, v.BossActions[i].z, true) + + if distance < Config.DrawDistance then + DrawMarker(22, v.BossActions[i].x, v.BossActions[i].y, v.BossActions[i].z + 1, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, Config.MarkerColor.r, Config.MarkerColor.g, Config.MarkerColor.b, 100, false, true, 2, true, false, false, false) + end + + if distance < Config.MarkerSize.x then + isInMarker, currentStation, currentPart, currentPartNum = true, k, 'BossActions', i end end end - end - - local hasExited = false - - if isInMarker and not HasAlreadyEnteredMarker or (isInMarker and (LastStation ~= currentStation or LastPart ~= currentPart or LastPartNum ~= currentPartNum)) then - - if - (LastStation ~= nil and LastPart ~= nil and LastPartNum ~= nil) and - (LastStation ~= currentStation or LastPart ~= currentPart or LastPartNum ~= currentPartNum) - then + if isInMarker and not HasAlreadyEnteredMarker or (isInMarker and (LastStation ~= currentStation or LastPart ~= currentPart or LastPartNum ~= currentPartNum)) then + + if + (LastStation ~= nil and LastPart ~= nil and LastPartNum ~= nil) and + (LastStation ~= currentStation or LastPart ~= currentPart or LastPartNum ~= currentPartNum) + then + TriggerEvent('esx_policejob:hasExitedMarker', LastStation, LastPart, LastPartNum) + hasExited = true + end + + HasAlreadyEnteredMarker = true + LastStation = currentStation + LastPart = currentPart + LastPartNum = currentPartNum + + TriggerEvent('esx_policejob:hasEnteredMarker', currentStation, currentPart, currentPartNum) + end + + if not hasExited and not isInMarker and HasAlreadyEnteredMarker then + HasAlreadyEnteredMarker = false TriggerEvent('esx_policejob:hasExitedMarker', LastStation, LastPart, LastPartNum) - hasExited = true end - HasAlreadyEnteredMarker = true - LastStation = currentStation - LastPart = currentPart - LastPartNum = currentPartNum - - TriggerEvent('esx_policejob:hasEnteredMarker', currentStation, currentPart, currentPartNum) - end - - if not hasExited and not isInMarker and HasAlreadyEnteredMarker then - HasAlreadyEnteredMarker = false - TriggerEvent('esx_policejob:hasExitedMarker', LastStation, LastPart, LastPartNum) end else diff --git a/config.lua b/config.lua index 69e0f3c1..bb7a6843 100644 --- a/config.lua +++ b/config.lua @@ -2,7 +2,7 @@ Config = {} Config.DrawDistance = 100.0 Config.MarkerType = 1 -Config.MarkerSize = { x = 1.5, y = 1.5, z = 1.0 } +Config.MarkerSize = { x = 1.5, y = 1.5, z = 0.5 } Config.MarkerColor = { r = 50, g = 50, b = 204 } Config.EnablePlayerManagement = true @@ -17,8 +17,8 @@ Config.HandcuffTimer = 10 * 60000 -- 10 mins Config.EnableJobBlip = true -- enable blips for colleagues, requires esx_society -Config.MaxInService = 5 -Config.Locale = 'sv' +Config.MaxInService = -1 +Config.Locale = 'en' Config.PoliceStations = { @@ -32,23 +32,8 @@ Config.PoliceStations = { Colour = 29 }, - -- https://wiki.rage.mp/index.php?title=Weapons - AuthorizedWeapons = { - { name = 'WEAPON_NIGHTSTICK', price = 200 }, - { name = 'WEAPON_COMBATPISTOL', price = 300 }, - { name = 'WEAPON_ASSAULTSMG', price = 1250 }, - { name = 'WEAPON_ASSAULTRIFLE', price = 1500 }, - { name = 'WEAPON_PUMPSHOTGUN', price = 600 }, - { name = 'WEAPON_STUNGUN', price = 500 }, - { name = 'WEAPON_FLASHLIGHT', price = 80 }, - { name = 'WEAPON_FIREEXTINGUISHER', price = 120 }, - { name = 'WEAPON_FLAREGUN', price = 60 }, - { name = 'WEAPON_STICKYBOMB', price = 250 }, - { name = 'GADGET_PARACHUTE', price = 300 } - }, - Cloakrooms = { - { x = 452.600, y = -993.306, z = 29.750 }, + { x = 452.6, y = -992.8, z = 29.7 }, }, Armories = { @@ -97,6 +82,44 @@ Config.PoliceStations = { } +Config.AuthorizedWeapons = { + recruit = { + { weapon = 'WEAPON_APPISTOL', components = { 0, 0, 1000, 4000, nil }, price = 10000 }, + { weapon = 'WEAPON_NIGHTSTICK', price = 0 }, + { weapon = 'WEAPON_STUNGUN', price = 500 }, + { weapon = 'WEAPON_FLASHLIGHT', price = 80 } + }, + + officer = { + { weapon = 'WEAPON_APPISTOL', components = { 0, 0, 1000, 4000, nil }, price = 10000 }, + { weapon = 'WEAPON_APPISTOL', components = { 0, 0, 1000, 4000, nil }, price = 10000 }, + { weapon = 'WEAPON_NIGHTSTICK', price = 0 }, + { weapon = 'WEAPON_STUNGUN', price = 500 }, + { weapon = 'WEAPON_FLASHLIGHT', price = 80 } + }, + + sergeant = { + + }, + + intendent = { + + }, + + lieutenant = { + + }, + + chef = { + + }, + + boss = { + + } +} + + -- https://wiki.rage.mp/index.php?title=Vehicles Config.AuthorizedVehicles = { Shared = { diff --git a/locales/br.lua b/locales/br.lua index ad5bd3b6..fb819143 100644 --- a/locales/br.lua +++ b/locales/br.lua @@ -15,6 +15,16 @@ Locales['br'] = { ['buy_weapons'] = 'Comprar armas', ['armory'] = 'Arsenal', ['open_armory'] = 'Pressione ~INPUT_CONTEXT~ para acessar o arsenal', + ['armory_owned'] = 'owned', + ['armory_free'] = 'free', + ['armory_item'] = '$%s', + ['armory_weapontitle'] = 'armory - Buy weapon', + ['armory_componenttitle'] = 'armory - Weapon attatchments', + ['armory_bought'] = 'you bought an ~y~%s~s~ for ~r~$%s~s~', + ['armory_money'] = 'you cannot afford that weapon', + ['armory_hascomponent'] = 'you have that attatchment equiped!', + ['get_weapon_menu'] = 'armory - Withdraw Weapon', + ['put_weapon_menu'] = 'armory - Store Weapon', -- Vehicles ['vehicle_menu'] = 'Veículo', ['vehicle_blocked'] = 'Já existe um carro fora da garagem', @@ -103,17 +113,7 @@ Locales['br'] = { ['plate'] = 'placa: %s', ['owner_unknown'] = 'proprietário: Desconhecido', ['owner'] = 'proprietário: %s', - -- Weapons Menus - ['get_weapon_menu'] = 'Arsenal - Pegar arma', - ['put_weapon_menu'] = 'Arsenal - Entregar arma', - ['buy_weapon_menu'] = 'Arsenal - Comprar armas', - ['not_enough_money'] = 'Você não tem dinheiro suficiente', -- Boss Menu - ['take_company_money'] = 'Retirar o dinheiro da empresa', - ['deposit_money'] = 'Depositar dinheiro', - ['amount_of_withdrawal'] = 'Quantidade de retirada', - ['invalid_amount'] = 'Quantidade inválida', - ['amount_of_deposit'] = 'Quantidade de depósito', ['open_bossmenu'] = 'Pressione ~INPUT_CONTEXT~ para abrir o menu', ['quantity_invalid'] = 'invalid quantity', ['have_withdrawn'] = 'you have withdrawn ~y~%sx~s~ ~b~%s~s~', diff --git a/locales/de.lua b/locales/de.lua index ff73fbef..8e6c64ec 100644 --- a/locales/de.lua +++ b/locales/de.lua @@ -15,6 +15,16 @@ Locales['de'] = { ['buy_weapons'] = 'Waffen kaufen', ['armory'] = 'Waffenkammer', ['open_armory'] = 'Drücke ~INPUT_CONTEXT~ um die Waffenkammer zu öffnen', + ['armory_owned'] = 'owned', + ['armory_free'] = 'free', + ['armory_item'] = '$%s', + ['armory_weapontitle'] = 'armory - Buy weapon', + ['armory_componenttitle'] = 'armory - Weapon attatchments', + ['armory_bought'] = 'you bought an ~y~%s~s~ for ~r~$%s~s~', + ['armory_money'] = 'you cannot afford that weapon', + ['armory_hascomponent'] = 'you have that attatchment equiped!', + ['get_weapon_menu'] = 'armory - Withdraw Weapon', + ['put_weapon_menu'] = 'armory - Store Weapon', -- Vehicles ['vehicle_menu'] = 'Fahrzeug', ['vehicle_blocked'] = 'es ist bereits ein Fahrzeug draussen', @@ -103,17 +113,7 @@ Locales['de'] = { ['plate'] = 'plate: %s', ['owner_unknown'] = 'besitzer: Unbekannt', ['owner'] = 'besitzer: %s', - -- Weapons Menus - ['get_weapon_menu'] = 'Waffenkammer - Waffen nehmen', - ['put_weapon_menu'] = 'Waffenkammer - Waffen bringen', - ['buy_weapon_menu'] = 'Waffenkammer - Waffen kaufen', - ['not_enough_money'] = 'Du hast nicht genug Geld', -- Boss Menu - ['take_company_money'] = 'Firmengeld abheben', - ['deposit_money'] = 'Geld einzahlen', - ['amount_of_withdrawal'] = 'Betrag zum abheben', - ['invalid_amount'] = 'ungültiger Betrag', - ['amount_of_deposit'] = 'Betrag zum einzahlen', ['open_bossmenu'] = 'Drücke ~INPUT_CONTEXT~ um das Menü zu öffnen', ['quantity_invalid'] = 'invalid quantity', ['have_withdrawn'] = 'you have withdrawn ~y~%sx~s~ ~b~%s~s~', diff --git a/locales/en.lua b/locales/en.lua index e125d5dc..e98e712c 100644 --- a/locales/en.lua +++ b/locales/en.lua @@ -10,11 +10,21 @@ Locales['en'] = { -- Armory ['remove_object'] = 'withdraw object', ['deposit_object'] = 'deposit object', - ['get_weapon'] = 'withdraw weapon', - ['put_weapon'] = 'deposit weapon', + ['get_weapon'] = 'withdraw weapon from armory', + ['put_weapon'] = 'store weapon in armory', ['buy_weapons'] = 'buy weapons', ['armory'] = 'armory', - ['open_armory'] = 'press ~INPUT_CONTEXT~ to access the armory', + ['open_armory'] = 'press ~INPUT_CONTEXT~ to access the ~y~Armory~s~.', + ['armory_owned'] = 'owned', + ['armory_free'] = 'free', + ['armory_item'] = '$%s', + ['armory_weapontitle'] = 'armory - Buy weapon', + ['armory_componenttitle'] = 'armory - Weapon attatchments', + ['armory_bought'] = 'you bought an ~y~%s~s~ for ~r~$%s~s~', + ['armory_money'] = 'you cannot afford that weapon', + ['armory_hascomponent'] = 'you have that attatchment equiped!', + ['get_weapon_menu'] = 'armory - Withdraw Weapon', + ['put_weapon_menu'] = 'armory - Store Weapon', -- Vehicles ['vehicle_menu'] = 'vehicle', ['vehicle_blocked'] = 'all available spawn points are currently blocked!', @@ -103,17 +113,7 @@ Locales['en'] = { ['plate'] = 'plate: %s', ['owner_unknown'] = 'owner: Unknown', ['owner'] = 'owner: %s', - -- Weapons Menus - ['get_weapon_menu'] = 'armory - Withdraw Weapon', - ['put_weapon_menu'] = 'armory - Deposit Weapon', - ['buy_weapon_menu'] = 'armory - Buy Guns', - ['not_enough_money'] = 'you do not have enough money', -- Boss Menu - ['take_company_money'] = 'withdraw Company Money', - ['deposit_money'] = 'deposit Money', - ['amount_of_withdrawal'] = 'amount of Withdrawal', - ['invalid_amount'] = 'amount invalid', - ['amount_of_deposit'] = 'amount of deposit', ['open_bossmenu'] = 'press ~INPUT_CONTEXT~ to open the menu', ['quantity_invalid'] = 'invalid quantity', ['have_withdrawn'] = 'you have withdrawn ~y~%sx~s~ ~b~%s~s~', diff --git a/locales/es.lua b/locales/es.lua index edae9fec..bb3ff8ae 100644 --- a/locales/es.lua +++ b/locales/es.lua @@ -15,6 +15,16 @@ Locales['es'] = { ['buy_weapons'] = 'Comprar armas', ['armory'] = 'Arsenal', ['open_armory'] = 'Presionarr ~INPUT_CONTEXT~ para acceder a la armeria', + ['armory_owned'] = 'owned', + ['armory_free'] = 'free', + ['armory_item'] = '$%s', + ['armory_weapontitle'] = 'armory - Buy weapon', + ['armory_componenttitle'] = 'armory - Weapon attatchments', + ['armory_bought'] = 'you bought an ~y~%s~s~ for ~r~$%s~s~', + ['armory_money'] = 'you cannot afford that weapon', + ['armory_hascomponent'] = 'you have that attatchment equiped!', + ['get_weapon_menu'] = 'armory - Withdraw Weapon', + ['put_weapon_menu'] = 'armory - Store Weapon', -- Vehicles ['vehicle_menu'] = 'Vehículo', ['vehicle_blocked'] = 'Ya tienes un vehículo fuera', @@ -103,17 +113,7 @@ Locales['es'] = { ['plate'] = 'n°: %s', ['owner_unknown'] = 'propietario: Desconocido', ['owner'] = 'propietario: %s', - -- Weapons Menus - ['get_weapon_menu'] = 'Arsenal - Coger armas', - ['put_weapon_menu'] = 'Arsenal - Depositar armas', - ['buy_weapon_menu'] = 'Arsenal - Comprar armas', - ['not_enough_money'] = 'No tienes suficiente dinero', -- Boss Menu - ['take_company_money'] = 'retirar dinero de la empresa', - ['deposit_money'] = 'depositar dinero en la empresa', - ['amount_of_withdrawal'] = 'cantidad a retirar', - ['invalid_amount'] = 'cantidad inválida', - ['amount_of_deposit'] = 'cantidad a depositar', ['open_bossmenu'] = 'presionar ~INPUT_CONTEXT~ para abrir el menú', ['quantity_invalid'] = 'cantidad invalida', ['have_withdrawn'] = 'you have withdrawn ~y~%sx~s~ ~b~%s~s~', diff --git a/locales/fi.lua b/locales/fi.lua index f7575835..b58e9fad 100644 --- a/locales/fi.lua +++ b/locales/fi.lua @@ -15,6 +15,16 @@ Locales['fi'] = { ['buy_weapons'] = 'osta aseita', ['armory'] = 'asevarasto', ['open_armory'] = 'paina ~INPUT_CONTEXT~ avataksesi asevarasto', + ['armory_owned'] = 'owned', + ['armory_free'] = 'free', + ['armory_item'] = '$%s', + ['armory_weapontitle'] = 'armory - Buy weapon', + ['armory_componenttitle'] = 'armory - Weapon attatchments', + ['armory_bought'] = 'you bought an ~y~%s~s~ for ~r~$%s~s~', + ['armory_money'] = 'you cannot afford that weapon', + ['armory_hascomponent'] = 'you have that attatchment equiped!', + ['get_weapon_menu'] = 'armory - Withdraw Weapon', + ['put_weapon_menu'] = 'armory - Store Weapon', -- Vehicles ['vehicle_menu'] = 'ajoneuvo', ['vehicle_blocked'] = 'ajoneuvo on jo ulkona tallista', @@ -103,17 +113,7 @@ Locales['fi'] = { ['plate'] = 'kilpi: %s', ['owner_unknown'] = 'omistaja: Tuntematon', ['owner'] = 'omistaja: %s', - -- Weapons Menus - ['get_weapon_menu'] = 'asevarasto - Ota ase', - ['put_weapon_menu'] = 'asevarasto - Laita ase pois', - ['buy_weapon_menu'] = 'asevarasto - Osta aseet', - ['not_enough_money'] = 'sinulla ei ole tarpeeksi rahaa', --Boss Menu - ['take_company_money'] = 'nosta yrityksen varoja', - ['deposit_money'] = 'talleta rahaa', - ['amount_of_withdrawal'] = 'noston määrä', - ['invalid_amount'] = 'virheellinen summa', - ['amount_of_deposit'] = 'talletuksen määrä', ['open_bossmenu'] = 'paina ~INPUT_CONTEXT~ avataksesi valikon', ['quantity_invalid'] = 'invalid quantity', ['have_withdrawn'] = 'sinä otit varastosta ~y~%sx~s~ ~b~%s~s~', diff --git a/locales/fr.lua b/locales/fr.lua index 47ff1b5e..cd427fe4 100644 --- a/locales/fr.lua +++ b/locales/fr.lua @@ -15,6 +15,16 @@ Locales['fr'] = { ['buy_weapons'] = 'acheter Armes', ['armory'] = 'armurerie', ['open_armory'] = 'appuyez sur ~INPUT_CONTEXT~ pour accéder à l\'armurerie', + ['armory_owned'] = 'owned', + ['armory_free'] = 'free', + ['armory_item'] = '$%s', + ['armory_weapontitle'] = 'armory - Buy weapon', + ['armory_componenttitle'] = 'armory - Weapon attatchments', + ['armory_bought'] = 'you bought an ~y~%s~s~ for ~r~$%s~s~', + ['armory_money'] = 'you cannot afford that weapon', + ['armory_hascomponent'] = 'you have that attatchment equiped!', + ['get_weapon_menu'] = 'armory - Withdraw Weapon', + ['put_weapon_menu'] = 'armory - Store Weapon', -- Vehicles ['vehicle_menu'] = 'véhicule', ['vehicle_blocked'] = 'il y a déja un véhicule de sorti', @@ -103,17 +113,7 @@ Locales['fr'] = { ['plate'] = 'n°: %s', ['owner_unknown'] = 'propriétaire: Inconnu', ['owner'] = 'propriétaire: %s', - -- Weapons Menus - ['get_weapon_menu'] = 'armurerie - Prendre Arme', - ['put_weapon_menu'] = 'armurerie - Déposer Arme', - ['buy_weapon_menu'] = 'armurerie - Acheter Armes', - ['not_enough_money'] = 'vous n\'avez pas assez d\'argent', -- Boss Menu - ['take_company_money'] = 'retirer argent société', - ['deposit_money'] = 'déposer argent', - ['amount_of_withdrawal'] = 'montant du retrait', - ['invalid_amount'] = 'montant invalide', - ['amount_of_deposit'] = 'montant du dépôt', ['open_bossmenu'] = 'appuyez sur ~INPUT_CONTEXT~ pour ouvrir le menu', ['quantity_invalid'] = 'quantité invalide', ['have_withdrawn'] = 'you have withdrawn ~y~%sx~s~ ~b~%s~s~', diff --git a/locales/pl.lua b/locales/pl.lua index 3f3b2a69..aa4e32ec 100644 --- a/locales/pl.lua +++ b/locales/pl.lua @@ -15,6 +15,16 @@ Locales['pl'] = { ['buy_weapons'] = 'kup Broń', ['armory'] = 'zbrojownia', ['open_armory'] = 'naciśnij ~INPUT_CONTEXT~ żeby uzyskać dostęp do zbrojowni', + ['armory_owned'] = 'owned', + ['armory_free'] = 'free', + ['armory_item'] = '$%s', + ['armory_weapontitle'] = 'armory - Buy weapon', + ['armory_componenttitle'] = 'armory - Weapon attatchments', + ['armory_bought'] = 'you bought an ~y~%s~s~ for ~r~$%s~s~', + ['armory_money'] = 'you cannot afford that weapon', + ['armory_hascomponent'] = 'you have that attatchment equiped!', + ['get_weapon_menu'] = 'armory - Withdraw Weapon', + ['put_weapon_menu'] = 'armory - Store Weapon', -- Vehicles ['vehicle_menu'] = 'pojazdy', ['vehicle_blocked'] = 'masz już pojazd poza garażem', @@ -103,17 +113,7 @@ Locales['pl'] = { ['plate'] = 'tablica rejestracyjna: %s', ['owner_unknown'] = 'właściciel: Nieznany', ['owner'] = 'właściciel: %s', - -- Weapons Menus - ['get_weapon_menu'] = 'zbrojownia - Weź broń', - ['put_weapon_menu'] = 'zbrojownia - Odłóż broń', - ['buy_weapon_menu'] = 'zbrojownia - Kup broń', - ['not_enough_money'] = 'nie masz wystarczającej ilości pieniędzy', -- Boss Menu - ['take_company_money'] = 'wypłać firmowe pieniądze', - ['deposit_money'] = 'zdeponuj pieniądze', - ['amount_of_withdrawal'] = 'wartość wypłaty', - ['invalid_amount'] = 'nieprawidłowa wartość', - ['amount_of_deposit'] = 'wartość depozytu', ['open_bossmenu'] = 'naciśnij ~INPUT_CONTEXT~ aby otworzyć menu', ['quantity_invalid'] = 'nieprawidłowa ilość', ['have_withdrawn'] = 'wyjmujesz z depozytu ~y~%sx~s~ ~b~%s~s~', diff --git a/locales/sv.lua b/locales/sv.lua index f57c25d2..1c99ab88 100644 --- a/locales/sv.lua +++ b/locales/sv.lua @@ -12,9 +12,19 @@ Locales['sv'] = { ['deposit_object'] = 'lägg in objekt', ['get_weapon'] = 'ta ut vapen', ['put_weapon'] = 'lägg in vapen', - ['buy_weapons'] = 'köp in vapen', + ['buy_weapons'] = 'köp vapen', ['armory'] = 'vapenförråd', - ['open_armory'] = 'tryck ~INPUT_CONTEXT~ för att komma åt förrådet', + ['open_armory'] = 'tryck ~INPUT_CONTEXT~ för att komma åt ~y~vapenförrådet~s~.', + ['armory_owned'] = 'ägd', + ['armory_free'] = 'gratis', + ['armory_item'] = '%s SEK', + ['armory_weapontitle'] = 'vapenförråd - Köp vapen', + ['armory_componenttitle'] = 'vapenförråd - Vapen tillbehör', + ['armory_bought'] = 'du köpte ~y~%s~s~ för ~r~%s SEK~s~', + ['armory_money'] = 'du har inte råd med det vapnet', + ['armory_hascomponent'] = 'du har redan det tillbehöret!', + ['get_weapon_menu'] = 'vapenförråd - Ta ut vapen', + ['put_weapon_menu'] = 'vapenförråd - Spara vapen', -- Vehicles ['vehicle_menu'] = 'bilar', ['vehicle_blocked'] = 'alla tillgänliga spawn points är blockerade!', @@ -103,17 +113,7 @@ Locales['sv'] = { ['plate'] = 'reg nummer: %s', ['owner_unknown'] = 'ägare: Okänt', ['owner'] = 'ägare: %s', - -- Weapons Menus - ['get_weapon_menu'] = 'vapenförråd - Ta vapen', - ['put_weapon_menu'] = 'vapenförråd - Lägg in vapen', - ['buy_weapon_menu'] = 'vapenförråd - Köp in vapen', - ['not_enough_money'] = 'du har inte tillräckligt mycket pengar', -- Boss Menu - ['take_company_money'] = 'ta ut företagspengar', - ['deposit_money'] = 'lägg in pengar till företaget', - ['amount_of_withdrawal'] = 'belopp att ta ut', - ['invalid_amount'] = 'otillgängligt belopp', - ['amount_of_deposit'] = 'belopp att lägga in', ['open_bossmenu'] = 'tryck ~INPUT_CONTEXT~ för att öppna menyn', ['quantity_invalid'] = 'otillgängligt antal', ['have_withdrawn'] = 'du har tagit ut ~y~x%s~s~ ~b~%s~s~', diff --git a/server/main.lua b/server/main.lua index 8943d098..fc41a027 100644 --- a/server/main.lua +++ b/server/main.lua @@ -9,17 +9,6 @@ end TriggerEvent('esx_phone:registerNumber', 'police', _U('alert_police'), true, true) TriggerEvent('esx_society:registerSociety', 'police', 'Police', 'society_police', 'society_police', 'society_police', {type = 'public'}) -RegisterServerEvent('esx_policejob:giveWeapon') -AddEventHandler('esx_policejob:giveWeapon', function(weapon, ammo) - local xPlayer = ESX.GetPlayerFromId(source) - - if xPlayer.job.name == 'police' then - xPlayer.addWeapon(weapon, ammo) - else - print(('esx_policejob: %s attempted to give weapon!'):format(xPlayer.identifier)) - end -end) - RegisterServerEvent('esx_policejob:confiscatePlayerItem') AddEventHandler('esx_policejob:confiscatePlayerItem', function(target, itemType, itemName, amount) local _source = source @@ -385,18 +374,54 @@ ESX.RegisterServerCallback('esx_policejob:removeArmoryWeapon', function(source, end) +ESX.RegisterServerCallback('esx_policejob:buyWeapon', function(source, cb, weaponName, type, componentNum) + local xPlayer = ESX.GetPlayerFromId(source) + local authorizedWeapons, selectedWeapon = Config.AuthorizedWeapons[xPlayer.job.grade_name] -ESX.RegisterServerCallback('esx_policejob:buy', function(source, cb, amount) + for k,v in ipairs(authorizedWeapons) do + if v.weapon == weaponName then + selectedWeapon = v + break + end + end + + if not selectedWeapon then + print(('esx_policejob: %s attempted to buy an invalid weapon.'):format(xPlayer.identifier)) + cb(false) + end + + -- Weapon + if type == 1 then + if xPlayer.getMoney() >= selectedWeapon.price then + xPlayer.removeMoney(selectedWeapon.price) + xPlayer.addWeapon(weaponName, 100) - TriggerEvent('esx_addonaccount:getSharedAccount', 'society_police', function(account) - if account.money >= amount then - account.removeMoney(amount) cb(true) else cb(false) end - end) + -- Weapon Component + elseif type == 2 then + local price = selectedWeapon.components[weaponComponent] + local weaponNum, weapon = ESX.GetWeapon(weaponName) + + local component = weapon.components[componentNum] + + if component then + if xPlayer.getMoney() >= selectedWeapon.price then + xPlayer.removeMoney(selectedWeapon.price) + xPlayer.addWeaponComponent(weaponName, component.name) + + cb(true) + else + cb(false) + end + else + print(('esx_policejob: %s attempted to buy an invalid weapon component.'):format(xPlayer.identifier)) + cb(false) + end + end end) ESX.RegisterServerCallback('esx_policejob:getStockItems', function(source, cb)