Help i cant get a vehicle model name from the server side

Hey i need help for a things that im tring to figure it out for hours but i cant get the solution.

i need to get the vehicle model name

server side:

			local model = --WHAT SHOULD I NEED TO PUT HERE?
            local pricee = 69

			local result = MySQL.Sync.execute('DELETE FROM owned_vehicles WHERE plate = @plate', {
				['@plate'] = plate
			})
			
            MySQL.Async.execute('INSERT INTO cardealer_vehicles (vehicle, price) VALUES (@vehicle, @price)', {
                ['@vehicle'] = model,
                ['@price']   = pricee
            })

please a littel help?

Try this. get model from client and send to server side
Client:

local plate = GetVehicleNumberPlateText(target_vehicle)
local model = string.lower(GetDisplayNameFromVehicleModel(GetEntityModel(target_vehicle)))
TriggerServerEvent("car:add", plate, model)

Server:

RegisterServerEvent("car:add")
AddEventHandler("car:add", function(plate, model)
    local pricee = 69

    local result = MySQL.Sync.execute('DELETE FROM owned_vehicles WHERE plate = @plate', {
        ['@plate'] = plate
    })
    
    MySQL.Async.execute('INSERT INTO cardealer_vehicles (vehicle, price) VALUES (@vehicle, @price)', {
        ['@vehicle'] = model,
        ['@price']   = pricee
    })
end)

hey thanks for the answer i tried it but nothing work i send the full code maybe u can help me better

server

RegisterCommand('addintoshop', function(source, args)
	if havePermission(source) then
		if args[1] == nil then
			TriggerClientEvent('esx:showNotification', source, '~r~/addintoshop <plate>')
		else
			local plate = args[1]
			if #args > 1 then
				for i=2, #args do
					plate = plate.." "..args[i]
				end		
			end
			plate = string.upper(plate)

			local model = ???????? HELP
            local pricee = 69

			local result = MySQL.Sync.execute('DELETE FROM owned_vehicles WHERE plate = @plate', {
				['@plate'] = plate
			})
			
            MySQL.Async.execute('INSERT INTO cardealer_vehicles (vehicle, price) VALUES (@vehicle, @price)', {
                ['@vehicle'] = model,
                ['@price']   = pricee
            })

			if result == 1 then
				TriggerClientEvent('esx:showNotification', source, _U('del_car', plate))
			elseif result == 0 then
				TriggerClientEvent('esx:showNotification', source, _U('del_car_error', plate))
			end		
		end
	else
		TriggerClientEvent('esx:showNotification', source, '~r~You don\'t have permission to do this command!')
	end		
end)

Client:

RegisterCommand('addintoshop', function(source, args)
    ...
    local plate = GetVehicleNumberPlateText(target_vehicle)
    local model = string.lower(GetDisplayNameFromVehicleModel(GetEntityModel(target_vehicle)))
    TriggerServerEvent("car:add", args, model)
end)

Server:

RegisterServerEvent("car:add")
AddEventHandler("car:add", function(args, model)
    if havePermission(source) then
		if args[1] == nil then
			TriggerClientEvent('esx:showNotification', source, '~r~/addintoshop <plate>')
		else
			local plate = args[1]
			if #args > 1 then
				for i=2, #args do
					plate = plate.." "..args[i]
				end		
			end
			plate = string.upper(plate)

			local model = model
            local pricee = 69

			local result = MySQL.Sync.execute('DELETE FROM owned_vehicles WHERE plate = @plate', {
				['@plate'] = plate
			})
			
            MySQL.Async.execute('INSERT INTO cardealer_vehicles (vehicle, price) VALUES (@vehicle, @price)', {
                ['@vehicle'] = model,
                ['@price']   = pricee
            })

			if result == 1 then
				TriggerClientEvent('esx:showNotification', source, _U('del_car', plate))
			elseif result == 0 then
				TriggerClientEvent('esx:showNotification', source, _U('del_car_error', plate))
			end		
		end
	else
		TriggerClientEvent('esx:showNotification', source, '~r~You don\'t have permission to do this command!')
	end	
end)
1 Like

Hello thanks again for the answer I tried but it still doesnt work now i tell you the problems.


This 3 dot what are they for? because with them nothing works, but if i delete this 3 dots it works but says CARNOTFOUND in the db.


Screenshot 2022-08-24 171049

Now i will try somethings waiting for your answer.

now its working

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

	local ped = GetPlayerPed(-1)
	local veh = GetVehiclePedIsIn(ped, false)
	local modelHash = GetEntityModel(veh)
    local model = GetDisplayNameFromVehicleModel(modelHash)

    TriggerServerEvent("car:add", args, model)
end)