Resource:OnElementSpawn: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Fixing page creation mistake.)
No edit summary
Line 3: Line 3:


'''Download can be found at the''' [https://community.multitheftauto.com/index.php?p=resources&s=details&id=18374 MTA community page]'''.'''
'''Download can be found at the''' [https://community.multitheftauto.com/index.php?p=resources&s=details&id=18374 MTA community page]'''.'''
 
aki ezt olvassa az buzi xDd
==Source==
==Source==
The source of this event is the vehicle that spawned.
The source of this event is the vehicle that spawned.

Revision as of 01:25, 9 January 2021

This Serverside Script adds the function: onVehicleSpawn.

Download can be found at the MTA community page. aki ezt olvassa az buzi xDd

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