Skip to content

Commit

Permalink
Merge pull request #470 from antond15/vehicle-storage
Browse files Browse the repository at this point in the history
feat(client): Allow more specific vehicle storage restrictions
  • Loading branch information
thelindat authored Jan 18, 2022
2 parents bcac968 + 1193669 commit f8ce76e
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 33 deletions.
17 changes: 15 additions & 2 deletions client.lua
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,11 @@ local function RegisterCommands()
local vehicle = GetVehiclePedIsIn(PlayerData.ped, false)

if NetworkGetEntityIsNetworked(vehicle) then
local checkVehicle = Vehicles.Storage[GetEntityModel(vehicle)]
if checkVehicle == 0 or checkVehicle == 2 then -- No storage or no glovebox
return
end

local plate = shared.playerslots and string.strtrim(GetVehicleNumberPlateText(vehicle)) or GetVehicleNumberPlateText(vehicle)
OpenInventory('glovebox', {id='glove'..plate, class=GetVehicleClass(vehicle), model=GetEntityModel(vehicle)})

Expand Down Expand Up @@ -490,9 +495,17 @@ local function RegisterCommands()
if locked == 0 or locked == 1 then
local checkVehicle = Vehicles.Storage[vehHash]
local open, vehBone
if checkVehicle == 1 then open, vehBone = 4, GetEntityBoneIndexByName(vehicle, 'bonnet')
elseif checkVehicle == nil then open, vehBone = 5, GetEntityBoneIndexByName(vehicle, 'boot') elseif checkVehicle == 2 then open, vehBone = 5, GetEntityBoneIndexByName(vehicle, 'boot') else --[[no vehicle nearby]] return end

if checkVehicle == nil then -- No data, normal trunk
open, vehBone = 5, GetEntityBoneIndexByName(vehicle, 'boot')
elseif checkVehicle == 3 then -- Trunk in hood
open, vehBone = 4, GetEntityBoneIndexByName(vehicle, 'bonnet')
else -- No storage or no trunk
return
end

if vehBone == -1 then vehBone = GetEntityBoneIndexByName(vehicle, Vehicles.trunk.boneIndex[vehHash] or 'platelight') end

position = GetWorldPositionOfEntityBone(vehicle, vehBone)
local distance = #(playerCoords - position)
local closeToVehicle = distance < 2 and (open == 5 and (checkVehicle == nil and true or 2) or open == 4)
Expand Down
66 changes: 35 additions & 31 deletions data/vehicles.lua
Original file line number Diff line number Diff line change
@@ -1,38 +1,42 @@
return {
-- 0 vehicle has no storage
-- 1 vehicle storage in the hood
-- 1 vehicle has no trunk storage
-- 2 vehicle has no glovebox storage
-- 3 vehicle has trunk in the hood
Storage = {
[`jester`] = 1,
[`adder`] = 1,
[`osiris`] = 0,
[`pfister811`] = 0,
[`penetrator`] = 0,
[`autarch`] = 0,
[`bullet`] = 0,
[`cheetah`] = 0,
[`cyclone`] = 0,
[`voltic`] = 0,
[`reaper`] = 1,
[`entityxf`] = 0,
[`t20`] = 0,
[`taipan`] = 0,
[`tezeract`] = 0,
[`torero`] = 1,
[`turismor`] = 0,
[`fmj`] = 0,
[`infernus `] = 0,
[`italigtb`] = 1,
[`italigtb2`] = 1,
[`nero2`] = 0,
[`vacca`] = 1,
[`vagner`] = 0,
[`visione`] = 0,
[`prototipo`] = 0,
[`zentorno`] = 0
[`jester`] = 3,
[`adder`] = 3,
[`osiris`] = 1,
[`pfister811`] = 1,
[`penetrator`] = 1,
[`autarch`] = 1,
[`bullet`] = 1,
[`cheetah`] = 1,
[`cyclone`] = 1,
[`voltic`] = 1,
[`reaper`] = 3,
[`entityxf`] = 1,
[`t20`] = 1,
[`taipan`] = 1,
[`tezeract`] = 1,
[`torero`] = 3,
[`turismor`] = 1,
[`fmj`] = 1,
[`infernus`] = 1,
[`italigtb`] = 3,
[`italigtb2`] = 3,
[`nero2`] = 1,
[`vacca`] = 3,
[`vagner`] = 1,
[`visione`] = 1,
[`prototipo`] = 1,
[`zentorno`] = 1,
[`trophytruck`] = 0,
[`trophytruck2`] = 0,
},

-- slots, maxWeight; default weight is 8000 per slot
glovebox = {
glovebox = {
[0] = {11, 88000}, -- Compact
[1] = {11, 88000}, -- Sedan
[2] = {11, 88000}, -- SUV
Expand All @@ -53,7 +57,7 @@ return {
[18] = {11, 88000}, -- Emergency
[19] = {11, 88000}, -- Military
[20] = {11, 88000}, -- Commercial (trucks)
['models'] = {
models = {
[`xa21`] = {11, 88000}
}
},
Expand All @@ -79,7 +83,7 @@ return {
[18] = {41, 328000}, -- Emergency
[19] = {41, 328000}, -- Military
[20] = {61, 488000}, -- Commercial
['models'] = {
models = {
[`xa21`] = {11, 10000}
},
boneIndex = {
Expand Down

0 comments on commit f8ce76e

Please sign in to comment.