I used to be utilizing a snippet for a /transfervehicle command script whereas my server was utilizing ESX 1.1.

I only in the near past switched to ESX V1-Ultimate and have been porting issues over. It was unlucky to see that the /transfervehicle script snippet from earlier than was not working so I rewrote a bit for my ESX v1-Ultimate server and right here we’re.

Credit: 3Bot – Authentic /transfervehicle

Gamers can switch owned autos amongst themselves with:
/switch IDHERE LICPL8HERE
Instance:

/switch 42 4KJ FS2

(Transferring my automobile to participant ID 42 with license plate ‘4KJ FS2’)

You’ll need mythic-notify for notifications or else remark them out and/or add your personal.

Right here is newbie pleasant useful resource in attachments, simply add:

guarantee vehicletransfer

to server.cfg

Alternatively right here is the code so you may add in to esx_vehicleshop>server>fundamental.lua :

RegisterCommand('switch', operate(supply,args)

myself = supply
different = args[1]

if(GetPlayerName(tonumber(args[1])))then

else
    ESX.ShowHelpNotification("Incorrect participant ID!")
    return
finish

native plate1 = args[2]
native plate2 = args[3]
native plate3 = args[4]
native plate4 = args[5]

if plate1 ~= nil then plate01 = plate1 else plate01 = "" finish
if plate2 ~= nil then plate02 = plate2 else plate02 = "" finish
if plate3 ~= nil then plate03 = plate3 else plate03 = "" finish
if plate4 ~= nil then plate04 = plate4 else plate04 = "" finish

native plate = (plate01 .. " " .. plate02 .. " " .. plate03 .. " " .. plate04)

native xPlayer = ESX.GetPlayerFromId(supply)

myID = xPlayer.identifier
myName = xPlayer.identify

native targetPlayer = ESX.GetPlayerFromId(args[1])
targetName = targetPlayer.identify

MySQL.Async.fetchAll(
        'SELECT * FROM owned_vehicles WHERE plate = @plate',
        {
            ['@plate'] = plate
        },
        operate(outcome)
            if outcome[1] ~= nil then
                native CarOwnerID = xPlayer.getIdentifier(outcome[1].proprietor)
                print("Automobile Switch", myID, CarOwnerID)
                if xPlayer.identifier == CarOwnerID then
                    print("Car Transfered")

                    knowledge = {}
                    TriggerClientEvent('mythic_notify:shopper:SendAlert', different, {
                     sort="inform",
                     textual content="Car with the plate" .. plate .. 'was transfered to you by: ' .. myName,
                     size = 4500, 
                    fashion = { 
                    ['background-color'] = '#DD8C1A',
                     ['color'] = '#FFFFFF' } 
                    })

                    MySQL.Sync.execute("UPDATE owned_vehicles SET [email protected] WHERE [email protected]", {['@owner'] = targetPlayer.identifier, ['@plate'] = plate})

                    TriggerClientEvent('mythic_notify:shopper:SendAlert', supply, {
                        sort="inform",
                        textual content="You may have transfered your automobile with the plate " .. plate .. 'to' .. targetName,
                        size = 4500, 
                       fashion = { 
                       ['background-color'] = '#DD8C1A',
                       ['color'] = '#FFFFFF' } 
                       })

                    else
                    TriggerClientEvent('mythic_notify:shopper:SendAlert', supply, {
                        sort="inform",
                        textual content="You don't personal that automobile!",
                        size = 4500, 
                        fashion = { 
                        ['background-color'] = '#DD8C1A',
                        ['color'] = '#FFFFFF' } 
                    })
                finish
            else
                TriggerClientEvent('mythic_notify:shopper:SendAlert', supply, {
                    sort="inform",
                    textual content="Error! Plate doesn't exist or typed incorrectly!",
                    size = 4500, 
                    fashion = { 
                    ['background-color'] = '#DD8C1A',
                    ['color'] = '#FFFFFF' } 
                })
            finish
        finish
)
finish)

I hope that is helpful to the neighborhood. :hugs:

transfervehicle.rar (1.3 KB)



Looking for paid scripts? Click here