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

Description:

This plugin you can give vehicle with custom or random plate number into player’s garage with command, also you can delete a vehicle by plate number

image

Commands:

In game: (give permission in config)

Give a car to the target player: /givecar [playerID] [vehicle] <plate>
Note: If plate is none will randomly generate a new plate

Delete a owned car by plate: /delcarplate [plate]

On console: (prefix need change to “_”)

_givecar [playerID] [car] <plate>
_delcarplate [plate]

Config:

Config = {}
Config.Locale = 'en' -- en, tw

Config.ReceiveMsg = true

-- Allow below identifier player to execute commands
Config.Admins = {
--  "steam:110000112b4917e",
  ""
}

Images:

image

Notifications

擷取
image
image

Update

2020/8/28

  • Now you can custom a plate with “space”
  • Better command syntax

2020/11/6

  • No essentialmode required anymore
  • Give command permission in config

Requirements

Download

GitHub

If you have SQL error try changing the code line 82 in server.lua SQL sytax :
(Thanks @bekoy for finding the problem)

MySQL.Async.execute('INSERT INTO owned_vehicles (owner, plate, vehicle, stored) VALUES (@owner, @plate, @vehicle, @stored)',

change to :

MySQL.Async.execute('INSERT INTO owned_vehicles (owner, plate, vehicle) VALUES (@owner, @plate, @vehicle)',

and delete or disable line 87 in server.lua :

['@stored']  = 1

change to :

--['@stored']  = 1

If helped you please leave give me a like :heart:

23 Likes

just admin can do that?

sure, if you are admin or superadmin in user group database can do this

1 Like

how can i limit the use to superadmin only?

1 Like

go to server.lua and search this
TriggerEvent('es:addGroupCommand', 'givecar', 'admin', function(source, args, user)
change to this
TriggerEvent('es:addGroupCommand', 'givecar', 'superadmin', function(source, args, user)

Done :smiley:

1 Like

I love this script :slight_smile: Thanks for sharing! :+1:

1 Like

Of course. I’m an idiot. hahahaha

how do you make it work for addon cars ?

Use the spawn name inside the stream folder.
Screenshot_644

doesnt work already tried , tells me that there is no such car

is the addon car can using command to spawn?
if can, won’t have this problem

With me works with all addons. When I execute the command, I am informed that there is no car but 1 second later the license plate is generated and the car is parked. It was never a problem.

ER_PARSE_ERROR: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'stored)
how to fix this ?

nice script! just one problem… when i give a car it says its stored in garage… but no car is in garage? any help on this please

just only one car or each car happens?

did you ever fix this?

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'stored) getting then when trying to give someone a car?

check owned_vehicles in your data base dose the “stored” presence?

yes its there

i can buy cars from the dealership no problem when i try and do it this way, i get this error