Skip to content

Commit

Permalink
🥷🏻 [v1.0.0] Latest stable
Browse files Browse the repository at this point in the history
  • Loading branch information
imkuroneko authored Mar 28, 2024
1 parent 8556dd2 commit f878357
Show file tree
Hide file tree
Showing 7 changed files with 234 additions and 0 deletions.
140 changes: 140 additions & 0 deletions client.lua
Original file line number Diff line number Diff line change
@@ -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)
42 changes: 42 additions & 0 deletions config.lua
Original file line number Diff line number Diff line change
@@ -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',
}
}
},
}
14 changes: 14 additions & 0 deletions fxmanifest.lua
Original file line number Diff line number Diff line change
@@ -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' }
7 changes: 7 additions & 0 deletions locales/en.json
Original file line number Diff line number Diff line change
@@ -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"
}
7 changes: 7 additions & 0 deletions locales/es.json
Original file line number Diff line number Diff line change
@@ -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"
}
7 changes: 7 additions & 0 deletions locales/pt-br.json
Original file line number Diff line number Diff line change
@@ -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"
}
17 changes: 17 additions & 0 deletions server.lua
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit f878357

Please sign in to comment.