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
})
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)
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)
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)