[Release][ESX] Give or delete owned vehicle to database (plate can custom or random generate)

I have use this about 5 month . it works perfectly . but now i wanna change to esx_advancedvehicleshop . any idea how to change the event ?

i can give car to player if i didnt put the plate… but if i put the plate it will print out unknown vehicle model. anyone can help?

You have to make a change in client/main.lua

81 - ESX.TriggerServerCallback(‘esx_advancedvehicleshop:isPlateTaken’, function (isPlateTaken)

tq for the tips . but i already giveup with esx_advancedvehicleshop haha

1 Like

Hey Actually Good Release But I Am Here With A Bug And Fix For That , When We Are Giving A Vehicle To A Player, The Vehicle Directly Goes To The Impound Not The Garage , So I Quickly Went To The server.lua And Took a Look Into The Code, Under MySql Async You Gave Only 5 Values Which Was Triggering The owned_vehicles (owner, plate, vehicle, stored, type)
But The Issue Here Is You Haven’t Gave state Value Here , State Row (0,1) Decides Weather The Vehicle Should Be Stored In The Garage Or Should Be Outside In Impound or Somewhere Else , So Actually 0 , 1 Here 1 = Vehicle In Garage And 0= Vehicle Is Outside The Garage , So What I Did Was , I Went To Line 145 In server.lua And Replaced This Code With This

MySQL.Async.execute(‘INSERT INTO owned_vehicles (owner, plate, vehicle, stored, type) VALUES (@owner, @plate, @vehicle, @stored, @type)’,
{
[’@owner’] = xPlayer.identifier,
[’@plate’] = vehicleProps.plate,
[’@vehicle’] = json.encode(vehicleProps),
[’@stored’] = 1,
[‘type’] = vehicleType
}, function ()

Change It To :

MySQL.Async.execute(‘INSERT INTO owned_vehicles (owner, plate, vehicle, stored, type,
state) VALUES (@owner, @plate, @vehicle, @stored, @type, @state)’,
{
[’@owner’] = xPlayer.identifier,
[’@plate’] = vehicleProps.plate,
[’@vehicle’] = json.encode(vehicleProps),
[’@stored’] = 1,
[@state] = 1,
[‘type’] = vehicleType
}, function ()

Thank You :smile:

Hello i have one error i need give car with tebex command but this error going always on my rcon :
SCRIPT ERROR: @esx_givevehicle/server/main.lua:166: attempt to index a nil value (local ‘xPlayer’)

command works fine, but when i give me a car, it says that i got it but my garage is still empty.
what now? xd

look in your impound

The Script can’t find the Player on the Server.

Solved

How? Always nice to help others.

how though?

image

When I try to display a vehicle either Addon or vanilla, I get this error.

Found a solution for you guy’s problem

MySQL.Sync.execute("INSERT INTO owned_vehicles (owner, plate, vehicle, stored) VALUES (@owner, @plate, @vehicle, @stored)"

Needs to be

MySQL.Sync.execute("INSERT INTO owned_vehicles (owner, plate, vehicle, `stored`) VALUES (@owner, @plate, @vehicle, @stored)"

stored is a word used in mysql, so you have to use ` to make sure your database doesnt confuse it for a syntax.

1 Like

Me too. any fix?

Fixed it! Go to line 145 and change to:
MySQL.Async.execute(‘INSERT INTO owned_vehicles (owner, plate, vehicle, state) VALUES (@owner, @plate, @vehicle, @state)’,
{
[’@owner’] = xPlayer.identifier,
[’@plate’] = vehicleProps.plate,
[’@vehicle’] = json.encode(vehicleProps),
[’@state’] = 1,

this doesnt seem to work on my fx server, every time i use the commands it tells me i do not have the correct permissions yet im server admin, can you help @MINO1

can anyone help me with this error please esx_givevehicle/server/main.lua:168: bad argument #1 to ‘pairs’ (table expected, got nil)

can someone help me i have this error: @esx_givevehicle/server/main.lua:166: attempt to index a nil value

Make yourself an admin in db