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 24: Line 24:


function onVehicleSpawnCheck(vehicle)
function onVehicleSpawnCheck(vehicle)
triggerEvent("onVehicleSpawn", vehicle)
triggerEvent("onVehicleSpawn", vehicle)
end
end
addEvent("onVehicleSpawnCheck", true)
addEvent("onVehicleSpawnCheck", true)
Line 30: Line 30:
</syntaxhighlight>
</syntaxhighlight>
</section>
</section>
==Example Code==
<section name="Serverside Example" class="server" show="true">
<syntaxhighlight lang="lua">
addEventHandler("onVehicleSpawn", root, function()
setElementPosition(source, 0, 0, 3)
end)
</syntaxhighlight>
</section>
'''Author: Godpolice13'''


{{See also/Server event|Vehicle events}}
{{See also/Server event|Vehicle events}}

Revision as of 16:11, 8 January 2021

This Serverside Script adds the function: onVehicleSpawn.

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)

Example Code

Click to collapse [-]
Serverside Example
addEventHandler("onVehicleSpawn", root, function()
	setElementPosition(source, 0, 0, 3)
end)

Author: Godpolice13

See Also

Vehicle events


Event functions

Shared