Jump to content

[HELP] What's wrong with the script Spawn Vehicle?


dener189

Recommended Posts

This script aims to spawn the vehicle after you get what you want. But I was wondering why you are giving this error, and I was wondering if there was a way for the vehicle to disappear after a second out of it?

Server

markers = {
	{ 1175.854, -1308.407, 13}, --Hospital LS
	{ -2650.922, 585.387, 13.453}, --Hospital SF
	{ 1624.4620361328, 1818.3846435547, 9.8203125},  --Hospital LV
    { 1539.487, -1656.687, 12.547}, --DP LS
    { -1581.739, 651.289, 6.188}, --DP SF
    { 2256.035, 2477.413, 9.82}, --DP LV
  }


for i,v in ipairs (markers) do
	marker = createMarker(v[1], v[2], v[3], "cylinder", get("markerSize"), get("markerColorR"), get("markerColorG"), get("markerColorB"), get("markerAlpha"))
end

veh = {}

addEvent ("getCar", true)
addEventHandler ("getCar", getRootElement(),
function(car)
    if veh[source] and isElement( veh[source] ) then destroyElement( veh[source] ) 
	veh[source] = nil 
	end
    local carID = getVehicleModelFromName (car)
    local x,y,z = getElementPosition(source)
    local carName = getVehicleNameFromModel (carID)
    veh[source] = createVehicle(carID, x,y,z)
    setVehicleColor(veh[source], 255, 255, 255)
    warpPedIntoVehicle(source, veh[source])    
end
)

addEventHandler ( "onPlayerQuit", getRootElement(),	
function ()
	if veh[source] and isElement( veh[source] ) then destroyElement( veh[source] ) 
	veh[source] = nil 
	end
end)
	
function markerHit (hitPlayer, matchingDimension)
if isPedInVehicle (hitPlayer) then return end
if getElementType(hitPlayer) == "player" then
    triggerClientEvent ("openMean", hitPlayer)
end
end
addEventHandler ("onMarkerHit", resourceRoot, markerHit)

function markerLeave (hitPlayer, matchingDimension)
if getElementType(hitPlayer) == "player" then
   triggerClientEvent ("closeOpenMean", hitPlayer)
end
end
addEventHandler ("onMarkerLeave", resourceRoot, markerLeave)

 

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...