Hi everybody, I tryed change the esx_vehicleshop. I want to add vehicleName column to owned_vehicles table.
So, if i buy a car, that have to add a car name to vehicleName column. But i can’t. Help me please.
RegisterServerEvent('esx_vehicleshop:setVehicleOwnedPlayerId')
AddEventHandler('esx_vehicleshop:setVehicleOwnedPlayerId', function (playerId, vehicleProps)
local xPlayer = ESX.GetPlayerFromId(playerId)
MySQL.Async.execute(
'INSERT INTO owned_vehicles (vehicle, owner) VALUES (@vehicle, @owner)',
{
['@vehicle'] = json.encode(vehicleProps),
['@owner'] = xPlayer.identifier,
},
function (rowsChanged)
TriggerClientEvent('esx:showNotification', playerId, _U('vehicle_belongs', vehicleProps.plate))
end
)
end)
Yes, but it doesn’t work
I create a column " model" in the owned_vehicles
add in the code this:
local hashVehicule = v.vehicle.model
local vehicleName = GetDisplayNameFromVehicleModel(hashVehicule)
[’@model’] = vehicleName,
But it nothing. What is the right way?
RegisterServerEvent('esx_vehicleshop:setVehicleOwned')
AddEventHandler('esx_vehicleshop:setVehicleOwned', function (vehicleProps)
local _source = source
local xPlayer = ESX.GetPlayerFromId(source)
local hashVehicule = v.vehicle.model
local vehicleName = GetDisplayNameFromVehicleModel(hashVehicule)
MySQL.Async.execute(
'INSERT INTO owned_vehicles (vehicle, owner, model) VALUES (@vehicle, @owner, @model)',
{
['@vehicle'] = json.encode(vehicleProps),
['@owner'] = xPlayer.identifier,
['@model'] = vehicleName,
},
function (rowsChanged)
TriggerClientEvent('esx:showNotification', _source, _U('vehicle').. vehicleProps.plate .. _('belongs'))
end
)
end)
RegisterServerEvent('esx_vehicleshop:setVehicleOwnedPlayerId')
AddEventHandler('esx_vehicleshop:setVehicleOwnedPlayerId', function (playerId, vehicleProps)
local xPlayer = ESX.GetPlayerFromId(playerId)
local hashVehicule = v.vehicle.model
local vehicleName = GetDisplayNameFromVehicleModel(hashVehicule)
MySQL.Async.execute(
'INSERT INTO owned_vehicles (vehicle, owner, model) VALUES (@vehicle, @owner, @model)',
{
['@vehicle'] = json.encode(vehicleProps),
['@owner'] = xPlayer.identifier,
['@model'] = vehicleName
},
function (rowsChanged)
TriggerClientEvent('esx:showNotification', playerId, _U('vehicle') .. vehicleProps.plate .. _('belongs'))
end
)
end)
RegisterServerEvent('esx_vehshopprice:buy')
AddEventHandler('esx_vehshopprice:buy', function ()
local mysource = source
local price = 4000
local xPlayer = ESX.GetPlayerFromId(source)
if(xPlayer.getMoney() >= price) then
xPlayer.removeMoney((price))
TriggerClientEvent('esx_vehicleshop:openPersonnalVehicleMenudva', mysource)
else
TriggerClientEvent('esx:showNotification', mysource, ('У вас нету денег'))
end
end)
RegisterServerEvent('esx_vehicleshop:setVehicleOwnedSociety')
AddEventHandler('esx_vehicleshop:setVehicleOwnedSociety', function (society, vehicleProps)
local _source = source
local xPlayer = ESX.GetPlayerFromId(source)
local hashVehicule = v.vehicle.model
local vehicleName = GetDisplayNameFromVehicleModel(hashVehicule)
MySQL.Async.execute(
'INSERT INTO owned_vehicles (vehicle, owner, model) VALUES (@vehicle, @owner, @model)',
{
['@vehicle'] = json.encode(vehicleProps),
['@owner'] = 'society:' .. society,
['@model'] = vehicleName
},
function (rowsChanged)
end
)
end)