diff --git a/client.lua b/client.lua new file mode 100644 index 0000000..a5f312e --- /dev/null +++ b/client.lua @@ -0,0 +1,140 @@ +lib.locale() +local ox_inventory = exports.ox_inventory +local QBCore = exports['qb-core']:GetCoreObject() +local settingsMarker = Config.settings.markers +local PlayerGang = {} + +-- === get player data +RegisterNetEvent('QBCore:Client:OnPlayerLoaded', function() + QBCore.Functions.GetPlayerData(function(data) + PlayerGang = data.gang + end) +end) + +RegisterNetEvent('QBCore:Client:OnGangUpdate', function(data) + PlayerGang = data +end) + +-- === thread +Citizen.CreateThread(function() + if lib.isTextUIOpen() then + lib.hideTextUI() + end + + for _, gang in pairs(Config.Gangs) do + local color = gang.markerColor + + -- ===== stash + local pointStash = lib.points.new({ coords = gang.stash, distance = 2 }) + + local oxMarker = lib.marker.new({ + type = settingsMarker.iconStash, + coords = gang.stash, + width = 0.20, + height = 0.20, + color = { r = color.r, g = color.g, b = color.b, a = settingsMarker.alphaColor }, + }) + + function pointStash:nearby() + if PlayerGang.name ~= gang.id then return end + oxMarker:draw() + lib.showTextUI(locale('press_e_open_stash'), { icon = 'fas fa-box', position = 'left-center' }) + if IsControlJustPressed(0, 38) then + ox_inventory:openInventory('stash', { id = 'stash_gang_'..gang.id, groups = gang.id }) + end + end + + function pointStash:onExit() + if lib.isTextUIOpen() then + lib.hideTextUI() + end + end + + -- ===== vehicle menu + VehicleListMenu = {} + for model, label in pairs(gang.vehicles.options) do + VehicleListMenu[model] = { + title = label, + icon = 'fas fa-car', + event = 'neko_gangs:client:garage:spawnvehicle', + args = { prefix = gang.vehicles.pr, colors = gang.vehicles.colors, spawn = gang.garage, model = model } + } + end + + lib.registerContext({ + id = 'neko_gangs_garage_'..gang.id, + title = locale('vehicle_list_menu'), + options = VehicleListMenu + }) + + -- ===== garage + local pointGarage = lib.points.new({ coords = gang.garage, distance = 2 }) + + local oxGarage = lib.marker.new({ + type = settingsMarker.iconGgarage, + coords = gang.garage, + width = 0.20, + height = 0.20, + color = { r = color.r, g = color.g, b = color.b, a = settingsMarker.alphaColor }, + }) + + function pointGarage:nearby() + if PlayerGang.name ~= gang.id then return end + oxGarage:draw() + + if (GetPedInVehicleSeat(GetVehiclePedIsIn(PlayerPedId()), -1) == PlayerPedId()) then + lib.showTextUI(locale('press_e_save_vehicle'), { icon = 'fas fa-square-parking', position = 'left-center' }) + if IsControlJustPressed(0, 38) then + TriggerEvent('neko_gangs:client:garage:deletevehicle') + end + else + lib.showTextUI(locale('press_e_open_garage'), { icon = 'fas fa-car-side', position = 'left-center' }) + if IsControlJustPressed(0, 38) then + lib.hideTextUI() + lib.showContext('neko_gangs_garage_'..gang.id) + end + end + end + + function pointGarage:onExit() + if lib.isTextUIOpen() then + lib.hideTextUI() + end + end + end +end) + +-- === Eventos +RegisterNetEvent('neko_gangs:client:garage:spawnvehicle', function(data) + local vehModel = data.model + local vehPrefix = data.prefix + local vehColors = data.colors + local spawnPoint = data.spawn + + QBCore.Functions.SpawnVehicle(vehModel, function(veh) + SetVehicleNumberPlateText(veh, vehPrefix..tostring(math.random(010000, 999999))) + SetEntityHeading(veh, spawnPoint.w) + exports[Config.settings.fuel]:SetFuel(veh, 100.0) + TaskWarpPedIntoVehicle(PlayerPedId(), veh, -1) + SetEntityAsMissionEntity(veh, true, true) + SetVehicleDirtLevel(veh, 1.0) + SetVehicleCustomPrimaryColour(veh, vehColors.primary.r, vehColors.primary.g, vehColors.primary.b) + SetVehicleCustomSecondaryColour(veh, vehColors.secondary.r, vehColors.secondary.g, vehColors.secondary.b) + TriggerEvent("vehiclekeys:client:SetOwner", QBCore.Functions.GetPlate(veh)) + SetVehicleEngineOn(veh, true, true) + end, spawnPoint, true) +end) + +RegisterNetEvent('neko_gangs:client:garage:deletevehicle', function() + local car = GetVehiclePedIsIn(PlayerPedId(), true) + DeleteVehicle(car) + DeleteEntity(car) +end) + +-- === eventos fivem +AddEventHandler('onResourceStart', function(resourceName) + if resourceName ~= GetCurrentResourceName() then return end + QBCore.Functions.GetPlayerData(function(PlayerData) + PlayerGang = PlayerData.gang + end) +end) \ No newline at end of file diff --git a/config.lua b/config.lua new file mode 100644 index 0000000..9e327f1 --- /dev/null +++ b/config.lua @@ -0,0 +1,42 @@ +Config = Config or {} + +Config.settings = { + -- ===== settings for fuel + fuel = 'ps-fuel', -- ps-fuel, lj-fuel, LegacyFuel + + -- ===== settings for ox_inventory + stash = { + slots = 60, + weight = 300000 + }, + + -- ===== settings for markers :: https://docs.fivem.net/docs/game-references/markers/ + markers = { + iconGgarage = 36, + iconStash = 2, + alphaColor = 180 + } +} + +Config.Gangs = { + { + id = 'ballas', + label = 'Ballas', + markerColor = { r = 204, g = 51, b = 102 }, + stash = vector3(-41.1190, -1115.7319, 26.4367), + garage = vector4(-44.8715, -1116.6627, 26.4338, 2.7542), + vehicles = { + pr = 'BL', -- dos letras + colors = { + primary = { r = 223, g = 88, b = 145 }, + secondary = { r = 107, g = 31, b = 123 } + }, + options = { + buffalo2 = 'Buffalo Sport', + rumpo3 = 'RumpoXL', + manchez = 'Manchez', + chino2 = 'Lowrider', + } + } + }, +} \ No newline at end of file diff --git a/fxmanifest.lua b/fxmanifest.lua new file mode 100644 index 0000000..d6b5052 --- /dev/null +++ b/fxmanifest.lua @@ -0,0 +1,14 @@ +fx_version 'cerulean' +game 'gta5' +lua54 'yes' +-- =========================================================== +description 'Sistema de gestión de garages y stashes para organizaciones criminales para qb-core basado en ox_lib y ox_inventory' +author 'KuroNeko' +-- =========================================================== +version '1.0.0' + +-- =========================================================== +shared_scripts { '@ox_lib/init.lua', 'config.lua' } +server_scripts { 'server.lua' } +client_scripts { 'client.lua' } +files { 'locales/es.json' } \ No newline at end of file diff --git a/locales/en.json b/locales/en.json new file mode 100644 index 0000000..6d671b0 --- /dev/null +++ b/locales/en.json @@ -0,0 +1,7 @@ +{ + "vehicle_list_menu": "Vehicles", + "press_e_open_garage": "Press [E] to open the garage", + "press_e_save_vehicle": "Press [E] to save the vehicle", + "press_e_open_stash": "Press [E] to open the inventory", + "stash_label": "Inventory %s" +} \ No newline at end of file diff --git a/locales/es.json b/locales/es.json new file mode 100644 index 0000000..04f7688 --- /dev/null +++ b/locales/es.json @@ -0,0 +1,7 @@ +{ + "vehicle_list_menu" : "Vehículos", + "press_e_open_garage" : "Presiona [E] para abrir el garage", + "press_e_save_vehicle" : "Presiona [E] para guardar el vehículo", + "press_e_open_stash" : "Presiona [E] para abrir el inventario", + "stash_label" : "Inventario %s" +} \ No newline at end of file diff --git a/locales/pt-br.json b/locales/pt-br.json new file mode 100644 index 0000000..22b709f --- /dev/null +++ b/locales/pt-br.json @@ -0,0 +1,7 @@ +{ + "vehicle_list_menu": "Veículos", + "press_e_open_garage": "Pressione [E] para abrir a garagem", + "press_e_save_vehicle": "Pressione [E] para salvar o veículo", + "press_e_open_stash": "Pressione [E] para abrir o inventário", + "stash_label": "Inventário %s" +} \ No newline at end of file diff --git a/server.lua b/server.lua new file mode 100644 index 0000000..ef604e4 --- /dev/null +++ b/server.lua @@ -0,0 +1,17 @@ +lib.locale() +local ox_inventory = exports.ox_inventory +local settings = Config.settings.stash + +Citizen.CreateThread(function() + for _, gang in pairs(Config.Gangs) do + ox_inventory:RegisterStash( + 'stash_gang_'..gang.id, + locale('stash_label', gang.label), + settings.slots, + settings.weight, + nil, + { [gang.id] = 0 }, + { gang.stash } + ) + end +end) \ No newline at end of file