Skip to content

Commit d77f8dd

Browse files
committed
ESX : fix give vehicle
1 parent 833ce01 commit d77f8dd

2 files changed

Lines changed: 22 additions & 9 deletions

File tree

config.lua

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
Config = {}
33

44

5-
Config.Framework = 'qb-core' -- esx , esx-old , qb-core , qb-old
5+
Config.Framework = 'esx' -- esx , esx-old , qb-core , qb-old
66

7-
Config.SharedObject = 'QBCore:GetCoreObject' -- esx:getSharedObject , QBCore:GetCoreObject --- !! Just for old versions !!
7+
Config.SharedObject = 'esx:getSharedObject' -- esx:getSharedObject , QBCore:GetCoreObject --- !! Just for old versions !!
88

9-
Config.TextUI = 'qb-core' -- esx , qb-core , okokTextUI
9+
Config.TextUI = 'esx' -- esx , qb-core , okokTextUI
1010

1111
Config.Key = 38 -- 38 is E key
1212

13-
Config.Target = 'qb-target' -- ox_target , qb-target
13+
Config.Target = 'ox_target' -- ox_target , qb-target
1414

1515
Config.SQL = 'oxmysql' -- oxmysql , ghmattimysql , mysql-async
1616

server/main.lua

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -629,21 +629,34 @@ function AddVehicleToGarage(source, vehicleName, plate, garage, props)
629629

630630
-- Generate plate if not provided
631631
if not plate or plate == "" then
632-
plate = string.upper(ESX.Math.Trim(GetRandomNumber(1) .. GetRandomLetter(2) .. GetRandomNumber(3) .. GetRandomLetter(2)))
632+
plate = string.upper(ESX.Math.Trim(math.random(1, 9 ) .. math.random(00,99) .. math.random(1, 9) .. math.random(00,99)))
633+
end
634+
-- Just use props directly without modifying it
635+
-- If props is not a table with required fields, create proper structure
636+
if type(props) ~= "table" then
637+
props = {}
638+
end
639+
640+
if not props.plate then
641+
props.plate = plate
633642
end
634643

635-
local vehicleData = props or {model = vehicleName}
644+
if not props.model then
645+
props.model = GetHashKey(vehicleName)
646+
end
647+
648+
local vehicleData = props
636649
if type(vehicleData) ~= "table" then vehicleData = {model = vehicleName} end
637650

638651
exports['ata_core']:InsertSQL("owned_vehicles", {
639652
owner = playerIdentifier,
640653
plate = plate,
641654
vehicle = json.encode(vehicleData),
642655
stored = 1,
643-
garage_name = garage or "Central"
644-
})
656+
parking = garage or "SanAndreasAvenue"
657+
})
645658

646-
-- Set vehicle keys for ESX
659+
-- Set vehicle keys for ESX
647660
TriggerClientEvent('esx_vehiclelock:setVehicleOwned', source, plate)
648661

649662
return true, plate

0 commit comments

Comments
 (0)