Multi Theft Auto: Wiki:OnVehicleSpawn: Difference between revisions
Jump to navigation
Jump to search
Godpolice13 (talk | contribs) No edit summary |
Godpolice13 (talk | contribs) m (Godpolice13 moved page Category:OnVehicleSpawn to Multi Theft Auto: Wiki:OnVehicleSpawn) |
||
(10 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
<pageclass class="resource" subcaption="Resource"></pageclass> | <pageclass class="resource" subcaption="Resource"></pageclass> | ||
This Serverside Script adds the function: onVehicleSpawn. | |||
'''Download can be found at the''' [https://community.multitheftauto.com/index.php?p=resources&s=details&id=18374 MTA community page]'''.''' | |||
''' | |||
==Source== | ==Source== | ||
Line 24: | Line 22: | ||
function onVehicleSpawnCheck(vehicle) | function onVehicleSpawnCheck(vehicle) | ||
triggerEvent("onVehicleSpawn", vehicle) | triggerEvent("onVehicleSpawn", vehicle) | ||
end | end | ||
addEvent("onVehicleSpawnCheck", true) | addEvent("onVehicleSpawnCheck", true) | ||
Line 30: | Line 28: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
</section> | </section> | ||
==Example Code== | |||
<section name="Serverside Example" class="server" show="true"> | |||
<syntaxhighlight lang="lua"> | |||
local Vehicle = createVehicle(411, 100, 100, 100) | |||
addEventHandler("onVehicleSpawn", root, function() | |||
setElementPosition(source, 0, 0, 3) | |||
end) | |||
</syntaxhighlight> | |||
</section> | |||
'''Author: Godpolice13''' | |||
{{See also/Server event|Vehicle events}} |
Latest revision as of 16:56, 8 January 2021
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 ScriptaddEventHandler("onClientElementStreamIn", root, function() if getElementType(source) == "vehicle" then triggerServerEvent("onVehicleSpawnCheck", localPlayer, source) end end)
Click to collapse [-]
Serverside ScriptaddEvent("onVehicleSpawn", true) function onVehicleSpawnCheck(vehicle) triggerEvent("onVehicleSpawn", vehicle) end addEvent("onVehicleSpawnCheck", true) addEventHandler("onVehicleSpawnCheck", root, onVehicleSpawnCheck)
Example Code
Click to collapse [-]
Serverside Examplelocal Vehicle = createVehicle(411, 100, 100, 100) addEventHandler("onVehicleSpawn", root, function() setElementPosition(source, 0, 0, 3) 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