Yeah haha... sry , i put all the code in case there is any doubt when someone wants to answer.
i think the specific part i want to modify is this
addEvent("SpawnMyVehicle", true)
addEventHandler("SpawnMyVehicle", root,
function(id)
if not playerVehicles[source] then playerVehicles[source] = {} end
if #playerVehicles[source] >= 1 then
exports.Script_Textos:createNewDxMessage("Solo Puedes Spawnear Un Vehiculos a La Vez", source, 255, 85, 0, true)
return
end
local data = dbPoll(dbQuery(db, "SELECT * FROM VehicleList WHERE Account = ? AND ID = ?", getAccountName(getPlayerAccount(source)), id), -1)
if type(data) == "table" and #data ~= 0 then
if getVehicleByID(id) then
exports.Script_Textos:createNewDxMessage("Su Vehiculo Ha Sido Spawneado", source, 255, 85, 0, true)
else
local color = split(data[1]["Colors"], ',')
r1 = color[1] or 255
g1 = color[2] or 255
b1 = color[3] or 255
r2 = color[4] or 255
g2 = color[5] or 255
b2 = color[6] or 255
vehicle = createVehicle(data[1]["Model"], data[1]["X"], data[1]["Y"], data[1]["Z"], 0, 0, data[1]["RotZ"])
setElementData(vehicle, "ID", id)
table.insert(playerVehicles[source],vehicle)
local fuelnu = data[1]["fuel"] or 100
local tune = fromJSON(data[1]["handling"])
-- outputChatBox(data[1]["handling"],source,255,0,0)
--outputChatBox(tostring(tune),source,255,0,255)
setElementData(vehicle, "vehicleFuel", fuelnu)
local upd = split(tostring(data[1]["Upgrades"]), ',')
for i, upgrade in ipairs(upd) do
addVehicleUpgrade(vehicle, upgrade)
end
local Paintjob = data[1]["Paintjob"] or 3
setVehiclePaintjob(vehicle, Paintjob)
setVehicleColor(vehicle, r1, g1, b1, r2, g2, b2)
if data[1]["HP"] <= 255.5 then data[1]["HP"] = 255 end
setElementHealth(vehicle, data[1]["HP"])
setElementData(vehicle, "Owner", source)
vv[vehicle] = setTimer(function(source)
if not isElement(source) then killTimer(vv[source]) vv[source] = nil end
if isElement(source) and getElementHealth(source) <= 255 then
setElementHealth(source, 255.5)
-- setVehicleDamageProof(source, true)
setVehicleEngineState(source, false)
end
end, 50, 0, vehicle)
addEventHandler("onVehicleDamage", vehicle,
function(loss)
local account = getAccountName(getPlayerAccount(getElementData(source, "Owner")))
setTimer(function(source) if isElement(source) then dbExec(db, "UPDATE VehicleList SET HP = ? WHERE Account = ? AND Model = ?", getElementHealth(source), account, getElementModel(source)) updateVehicleInfo(getElementData(source, "Owner")) end end, 100, 1, source)
end)
addEventHandler("onVehicleEnter", vehicle,
function(player)
if getElementHealth(source) <= 255.5 then
setVehicleEngineState(source, false)
else
if isVehicleDamageProof(source) then
setVehicleDamageProof(source, false)
end
end
end)
exports.Script_Textos:createNewDxMessage("Tu Vehiculo Ha Sido Spawneado", source, 255, 85, 0, true)
cur = getElementData(source,"spawnedcars") or {}
table.insert(cur,getVehicleNameFromModel(data[1]["Model"]))
setElementData(source,"spawnedcars",cur)
end
else
exports.Script_Textos:createNewDxMessage("Ocurrio Un Error", source, 255, 85, 0, true)
end
end)
I just want the vehicle spawns in the same position as the player
Thanks for the recommendation :))