Multi Theft Auto: Wiki:OnVehicleSpawn: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 5: Line 5:
'''Source''': https://google.com
'''Source''': https://google.com
</div>
</div>
==Source==
The source of this event is the vehicle that spawned.


==Code==
==Code==

Revision as of 16:01, 8 January 2021

blabl

Source: https://google.com

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)