Resource:OnElementSpawn
Jump to navigation
Jump to search
This Serverside Script adds the function: onElementSpawn.
Download can be found at the MTA community page.
Source
The source of this event is the element that spawned.
Code
Click to collapse [-]
Clientside ScriptaddEventHandler("onClientElementStreamIn", root, function() if getElementType(source) == "vehicle" then triggerServerEvent("onElementSpawnCheck", localPlayer, source) end end)
Click to collapse [-]
Serverside ScriptaddEvent("onElementSpawn", true) function onElementSpawnCheck(element) triggerEvent("onElementSpawn", element) end addEvent("onElementSpawnCheck", true) addEventHandler("onElementSpawnCheck", root, onElementSpawnCheck)
Example Code
Click to collapse [-]
Serverside Examplelocal Vehicle = createVehicle(411, 100, 100, 100) addEventHandler("onElementSpawn", root, function() if getElementType(source) == "vehicle" then setElementPosition(source, 0, 0, 3) end end)
Author: Godpolice13
See Also
Vehicle events
- onTrailerAttach
- onTrailerDetach
- onVehicleDamage
- onVehicleEnter
- onVehicleExit
- onVehicleExplode
- onVehicleRespawn
- onVehicleStartEnter
- onVehicleStartExit
Event functions
- addEvent
- addEventHandler
- cancelEvent
- cancelLatentEvent
- getEventHandlers
- getLatentEventHandles
- getLatentEventStatus
- removeEventHandler
- triggerEvent
- wasEventCancelled