OnClientElementStreamOut: Difference between revisions
Jump to navigation
Jump to search
m (→Source) |
Dutchman101 (talk | contribs) m (t) |
||
(5 intermediate revisions by 4 users not shown) | |||
Line 2: | Line 2: | ||
__NOTOC__ | __NOTOC__ | ||
This event is triggered whenever a physical element is streamed out. This is triggered for all elements that are streamable, such as players, peds, vehicles, objects and markers when the local player is leaving the element. When this event is triggered, that element is no longer physical and is now virtualized by MTA. | This event is triggered whenever a physical element is streamed out. This is triggered for all elements that are streamable, such as players, peds, vehicles, objects and markers when the local player is leaving the element. When this event is triggered, that element is no longer physical and is now virtualized by MTA. | ||
__NOTOC__ {{Note|Be aware that this event triggers for local player (as itself being the element that got streamed out) when said local player dies and respawns, as this is the removal & recreation of entity local ped.}} | |||
==Parameters== | |||
No parameters. | |||
==Source== | ==Source== | ||
The [[event system#Event source|source]] of this event is the [[element]] that streamed out. | The [[event system#Event source|source]] of this event is the [[element]] that streamed out. | ||
==Remarks== | |||
This event is not triggered for elements that are streamed-in at the point of a [[destroyElement]] call. Use the [[onClientElementDestroy]] event in combination with the [[isElementStreamedIn]] function to handle such a case. | |||
==Example== | ==Example== | ||
This example shows you how to tell player that | This example shows you how to tell player that another player was streamed out and the distance between them and said player | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
addEventHandler( "onClientElementStreamOut", | addEventHandler( "onClientElementStreamOut", root, | ||
function ( ) | function () | ||
if getElementType( source ) == " | if getElementType(source) == "player" then | ||
local | local x, y, z = getElementPosition(localPlayer) | ||
local | local xh, xy, xz = getElementPosition(source) | ||
local distance = getDistanceBetweenPoints3D( | local distance = getDistanceBetweenPoints3D(x, y, z, xh, xy, xz ) | ||
outputChatBox( "A | outputChatBox( "A player has just streamed out. Distance to the player: " .. tostring(distance) .."." ) | ||
end | end | ||
end | end | ||
) | ) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Latest revision as of 03:39, 22 January 2023
This event is triggered whenever a physical element is streamed out. This is triggered for all elements that are streamable, such as players, peds, vehicles, objects and markers when the local player is leaving the element. When this event is triggered, that element is no longer physical and is now virtualized by MTA.
Parameters
No parameters.
Source
The source of this event is the element that streamed out.
Remarks
This event is not triggered for elements that are streamed-in at the point of a destroyElement call. Use the onClientElementDestroy event in combination with the isElementStreamedIn function to handle such a case.
Example
This example shows you how to tell player that another player was streamed out and the distance between them and said player
addEventHandler( "onClientElementStreamOut", root, function () if getElementType(source) == "player" then local x, y, z = getElementPosition(localPlayer) local xh, xy, xz = getElementPosition(source) local distance = getDistanceBetweenPoints3D(x, y, z, xh, xy, xz ) outputChatBox( "A player has just streamed out. Distance to the player: " .. tostring(distance) .."." ) end end )
See Also
Client element events
- onClientElementColShapeHit
- onClientElementColShapeLeave
- onClientElementDataChange
- onClientElementDestroy
- onClientElementDimensionChange
- onClientElementInteriorChange
- onClientElementModelChange
- onClientElementStreamIn
- onClientElementStreamOut
Client event functions
- triggerLatentServerEvent
- triggerServerEvent
- Shared
- addEvent
- addEventHandler
- cancelEvent
- cancelLatentEvent
- getEventHandlers
- getLatentEventHandles
- getLatentEventStatus
- removeEventHandler
- triggerEvent
- wasEventCancelled