|
Tag: Redirect target changed |
| (2 intermediate revisions by 2 users not shown) |
| Line 1: |
Line 1: |
| <pageclass class="resource" subcaption="Resource"></pageclass>
| | #redirect [[Resource:OnElementSpawn]] |
| 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==
| |
| The source of this event is the vehicle that spawned.
| |
| | |
| ==Code==
| |
| <section name="Clientside Script" class="client" show="true">
| |
| <syntaxhighlight lang="lua">
| |
| addEventHandler("onClientElementStreamIn", root, function()
| |
| if getElementType(source) == "vehicle" then
| |
| triggerServerEvent("onVehicleSpawnCheck", localPlayer, source)
| |
| end
| |
| end)
| |
| </syntaxhighlight>
| |
| </section>
| |
| <section name="Serverside Script" class="server" show="true">
| |
| <syntaxhighlight lang="lua">
| |
| addEvent("onVehicleSpawn", true)
| |
| | |
| function onVehicleSpawnCheck(vehicle)
| |
| triggerEvent("onVehicleSpawn", vehicle)
| |
| end
| |
| addEvent("onVehicleSpawnCheck", true)
| |
| addEventHandler("onVehicleSpawnCheck", root, onVehicleSpawnCheck)
| |
| </syntaxhighlight>
| |
| </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}}
| |