Multi Theft Auto: Wiki:OnVehicleSpawn

From Multi Theft Auto: Wiki
Revision as of 16:56, 8 January 2021 by Godpolice13 (talk | contribs) (Godpolice13 moved page Category:OnVehicleSpawn to Multi Theft Auto: Wiki:OnVehicleSpawn)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

This Serverside Script adds the function: onVehicleSpawn.

Download can be found at the MTA community page.

Source

The source of this event is the vehicle that spawned.

Code

Click to collapse [-]
Clientside Script
addEventHandler("onClientElementStreamIn", root, function()
	if getElementType(source) == "vehicle" then
		triggerServerEvent("onVehicleSpawnCheck", localPlayer, source)
	end
end)
Click to collapse [-]
Serverside Script
addEvent("onVehicleSpawn", true)

function onVehicleSpawnCheck(vehicle)
	triggerEvent("onVehicleSpawn", vehicle)
end
addEvent("onVehicleSpawnCheck", true)
addEventHandler("onVehicleSpawnCheck", root, onVehicleSpawnCheck)

Example Code

Click to collapse [-]
Serverside Example
local Vehicle = createVehicle(411, 100, 100, 100)

addEventHandler("onVehicleSpawn", root, function()
	setElementPosition(source, 0, 0, 3)
end)

Author: Godpolice13

See Also

Vehicle events


Event functions