addEvent("onClientRequestRespawn", true)
addEventHandler("onClientRequestRespawn", getRootElement(),
function(mapInfo, mapOptions, gameOptions,vehicleData)
outputChatBox ( "Map info: ".. mapInfo )
outputChatBox ( "Map name: ".. mapInfo.name )
if (ismapDM(mapInfo.name) == 1) then
-- source is the player that requested respawn.
-- spawn at the position where last saved.
triggerClientEvent(source, 'onClientCall_race', source, "Spectate.stop", 'manual')
triggerEvent('onClientRequestSpectate', source, false)
spawnPlayer(source, vehicleData.posX, vehicleData.posY, vehicleData.posZ)
local vehicle = exports.race:getPlayerVehicle(source)
warpPedIntoVehicle(source, vehicle)
triggerClientEvent(source, 'onClientCall_race', source, "Spectate.stop", 'manual')
setElementData(source, "race.spectating", true)
setElementData(source, "status1", "dead")
setElementData(source, "status2", "")
--setElementData(source, "state", "training")
setElementData(source, "race.finished", true)
setCameraTarget(source, source)
setElementData(vehicle, "race.collideworld", 1)
setElementData(vehicle, "race.collideothers", 0)
setElementData(source, "race.alpha", 255)
setElementData(vehicle, "race.alpha", 255)
setElementHealth(vehicle, vehicleData.health)
setElementModel(vehicle, 481) -- fix motor sound.
setElementModel(vehicle, tonumber(vehicleData.model))
setElementPosition(vehicle, vehicleData.posX, vehicleData.posY, vehicleData.posZ)
setElementRotation(vehicle, vehicleData.rotX, vehicleData.rotY, vehicleData.rotZ)
if(vehicleData.nitro ~= nil)then
addVehicleUpgrade(vehicle, tonumber(vehicleData.nitro))
end
setElementFrozen(vehicle, true)
toggleAllControls(source, true)
setVehicleLandingGearDown(vehicle, true)
setTimer(delayedRespawn, 2000, 1, source, vehicle, vehicleData)
elseif (ismapDM(mapInfo.name) == 2) then
cancelEvent()
elseif (ismapDM(mapInfo.name) == 3) then
cancelEvent()
end
end)
See what does it output.