[Release] CnRvehicles - my first script

Hello guys, this is the first script that I have ever made in FiveM. Not too many people will be able to use this in their servers, but I am mainly posting this for you all to critique my first script and tell me what I did right/wrong. Constructive criticism is more than welcome, but please don’t bash me because I didn’t do something right! I plan to use this script in the game mode that I am creating. For those of you that played CrazyBobs cops and Robbers on SA:MP, this is pretty much a ripoff of the crane system. I also believe that there is something like this in the original GTA:Online.

Please look at my code and let me know if you see ways that I can be more efficient, or let me know if you see any errors/ways to break the script! I am trying to learn and I need some tips and pointers! Thanks!

DISCLAIMER: This will most likely not work with any RP scripts because it was not made using any RP frameworks. This release is for input from other scripters!

This is mainly for game modes where you are able to steal vehicles from NPC’s!

Features:
-Ability to sell vehicles at the chop shop (located outside of Sandy Shores)
-Vehicle price decreases with damage

To-do list:
-Implement all vehicles in the game :heavy_check_mark:
-Add a timer so you can’t sell more than one vehicle in a specified time frame
-Events where one vehicle is worth more than another

Requirements:
-essentialmode

Screenshot:

And without further adue, here it is!

9 Likes

Looks good, keep the updates rolling :slight_smile:

isnt working just says cannot sell vehicle

The vehicle price didnt seem to change when damaging. Also the ability for it to give dirty money would be nice. INPUT_PICKUP can be fixed easily.

Only a handful of vehicles are in the script right now. I’m working on adding them all

What vehicle were you using? Also, since I don’t use the ESX framework, I can’t use dirty money.

i even read the list of vehicles from the file and it didnt work

1 Like

It is most likely because the name of the vehicle in the table is wrong, what vehicle were you using?

Fixed the names of the available vehicles, check GitHub.

Changed the way the vehicles prices are handled, and they now are based off of the vehicle class. This means that every vehicle in the game now has a price assigned to it, even boats and helicopters (although some of the prices may be odd). Also made the notifications look more sleek.

A huge thank you to @Vespura for the excellent feedback!

Works perfect with ESX. :smiley:

Can I work on this and make it vRP compatible for my pack? With credits to you of course

1 Like

Go for it.
(20characters)

Bonjour,

Great script I adore the idea! Especially easy has to configure the prices(prizes) of vehicles thank you.

On the other hand the money is give directly in the pocket without being of the dirty money. As to make to add

““xPlayer.addAccountMoney(‘black_money’, (vehprice))””

The normal commandto make(it)?

Thank you for your help

Hi If I sell a car it doesn’t give me the money?

Any errors in the F8 console when you go to sell your vehicle?

no errors everything is working but if I sell a car it doesn’t give me the money?

Do you have essentialmode installed and the database set up correctly?

Yes I do Checked everything

Good job! @jayden8250

Pretty simple, just edit the server.lua

Add to the top of the server.lua

ESX = nil

TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)


----------------------------------------------------------------------------------------------------


RegisterServerEvent("sellVehicle")
AddEventHandler("sellVehicle", function(vehPrice)
	local _source = source
	local xPlayer = ESX.GetPlayerFromId(_source)
	xPlayer.addAccountMoney('black_money', vehPrice)
	CancelEvent()
end)
3 Likes