[Release] [ESX] /transfervehicle (Simple script addon to transfer your vehicles)

@3Bot Can you do a port to eden garage?

Finally !!! thanks man great work :mascot:
sell

2 Likes

With my older esx_vehicleshop I have a problem that I can’t figure it out the vehicles’ name. I mean I can see their mod but I can’t see the car’s model name so it’s hard to find my users’ car if I want to remove some of it.

Other thing is that if I put the new esx_vehicleshop in, then do I need to remove the older SQL tables like owner_vehicle owned_vehicle etc and then insert the new or? How can I add a new coulumn ?

hello i see this is only for Essential Mode but is it possible to make it to Dunkos Vrp or if u/anyone now a script for dunkos vrp with the same feature to transfer vehicles? :smiley:
Greeting, Silvester :smiley:

what if only car dealer can use this command?

You can implement it so it checks for what job you have. But sort of defeats the point as what if a player wants to sell his car to his friend or a cardealer.

How do I find out my plate if I dont look in the database file?

You can download wk_wrs for plate registration. Its a radar for policemen

Ye i have that, it was more for the other citizens rather than the police selling vheicles, it would mean I would have to located a police officer to check a plate

can I arrange to seize the vehicle and make the seized vehicle payable to me ?, because I am looking for a script for forced removal (tow truck) without accessing the database??

I don’t know what is wrong but I can’t make it work. Can someone please help me?

You have to put it in esx_vehicleshop server/main.lua at the very bottom. Just paste it in there.

I did that than I wrote command and it didn’t worked.

Did you restart the resource before you tried the command?

Yes, I tried

Does your owned_vehicles table have the plate column in it? Also I did modify his code to something better. Put this in the end of the file.

RegisterCommand('givecar', function(source, args)

	myself = source

	if args[1] ~= nil then
		other = args[1]
	else
		TriggerClientEvent('chatMessage', source, "SYSTEM", {255, 0, 0}, "Incorrect player ID!")
		return
	end
	
	if(GetPlayerName(tonumber(args[1]))) then
			
	else	
        TriggerClientEvent('chatMessage', source, "SYSTEM", {255, 0, 0}, "Incorrect player ID!")
		return
	end

	mySteamID = GetPlayerIdentifiers(source)
	mySteam = mySteamID[1]
	myID = ESX.GetPlayerFromId(source).identifier
	myName = ESX.GetPlayerFromId(source).name

	targetSteamID = GetPlayerIdentifiers(args[1])
	targetSteamName = ESX.GetPlayerFromId(args[1]).name
	targetSteam = targetSteamID[1]
	
	table.remove(args, 1)

	local plate = ""

	for k,v in pairs(args) do
		plate = plate .. v .. " "
	end
	
	plate = string.sub(plate, 1, -2)
	
	MySQL.Async.fetchAll(
        'SELECT * FROM owned_vehicles WHERE plate = @plate',
        {
            ['@plate'] = plate
        },
        function(result)
            if result[1] ~= nil then
                local playerName = ESX.GetPlayerFromIdentifier(result[1].owner).identifier
				local pName = ESX.GetPlayerFromIdentifier(result[1].owner).name
				CarOwner = playerName
				
				if myID == CarOwner then
					
					data = {}
						TriggerClientEvent('chatMessage', other, "^4Vehicle with the plate ^*^1" .. plate .. "^r^4was transfered to you by: ^*^2" .. myName)
			 
						MySQL.Sync.execute("UPDATE owned_vehicles SET owner=@owner WHERE plate=@plate", {['@owner'] = targetSteam, ['@plate'] = plate})
						TriggerClientEvent('chatMessage', source, "^4You have ^*^3transfered^0^4 your vehicle with the plate ^*^1" .. plate .. " ^r^4to ^*^2".. targetSteamName)
				else
					print("Did not transfer")
					TriggerClientEvent('chatMessage', source, "^*^1You do not own the vehicle")
				end
			else
				TriggerClientEvent('chatMessage', source, "^1^*ERROR: ^r^0This vehicle plate does not exist or the plate was incorrectly written.")
            end
		
        end
    )
end)

can fix to not givecar to myself ?

It’s already a part of the code to not be able to give it to yourself.

Yes I have Screenshot

In that case, if you use my code, and put it at the very bottom of the script, it should work flawlessly