IsElementSyncer: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
mNo edit summary |
||
(8 intermediate revisions by 4 users not shown) | |||
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
{{Client function}} | {{Client function}} | ||
This function checks whether an [[element]] is | This function checks whether an [[element]] is synced by the local player or not. Accepted elements are [[ped|peds]] and [[vehicle|vehicles]]. | ||
==Syntax== | ==Syntax== | ||
Line 7: | Line 7: | ||
bool isElementSyncer ( element theElement ) | bool isElementSyncer ( element theElement ) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
{{New feature/item|3.0141|1.4.0|6993|{{OOP||[[element]]:isSyncer|syncedByLocalPlayer}}}} | |||
===Required Arguments=== | ===Required Arguments=== | ||
Line 12: | Line 13: | ||
===Returns=== | ===Returns=== | ||
Returns ''true'' if the passed element is | Returns ''true'' if the passed element is synced by the local player, ''false'' otherwise. | ||
==Example== | ==Example== | ||
<section name="Client" class="client" show="true"> | <section name="Client" class="client" show="true"> | ||
This example draws a string above peds synced by local player in 50m proximity | |||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
-- | function renderSyncedElements () | ||
-- Retrieve ped elements streamed in | |||
for k,el in ipairs (getElementsByType('ped', root, true)) do | |||
repeat | |||
if (not isElementSyncer(el)) then | |||
-- Skip if local player isn't syncer | |||
break | |||
end | |||
local pedX, pedY, pedZ = getElementPosition (el) | |||
local sX, sY, sD = getScreenFromWorldPosition (pedX, pedY, pedZ + 1.2) | |||
if (not sX) or (sD > 50) then | |||
-- Not on screen or too far away | |||
break | |||
end | |||
dxDrawText ('Syncer', sX, sY, 0, 0, tocolor(255,255,255,255), 20 / sD, 'arial') | |||
until true | |||
end | |||
end | |||
addEventHandler ('onClientRender', root, renderSyncedElements) | |||
</syntaxhighlight> | </syntaxhighlight> | ||
</section> | </section> | ||
Line 23: | Line 45: | ||
==See Also== | ==See Also== | ||
{{Client element functions}} | {{Client element functions}} | ||
Latest revision as of 02:22, 1 January 2015
This function checks whether an element is synced by the local player or not. Accepted elements are peds and vehicles.
Syntax
bool isElementSyncer ( element theElement )
OOP Syntax Help! I don't understand this!
- Method: element:isSyncer(...)
- Variable: .syncedByLocalPlayer
Required Arguments
- theElement: The element to check.
Returns
Returns true if the passed element is synced by the local player, false otherwise.
Example
Click to collapse [-]
ClientThis example draws a string above peds synced by local player in 50m proximity
function renderSyncedElements () -- Retrieve ped elements streamed in for k,el in ipairs (getElementsByType('ped', root, true)) do repeat if (not isElementSyncer(el)) then -- Skip if local player isn't syncer break end local pedX, pedY, pedZ = getElementPosition (el) local sX, sY, sD = getScreenFromWorldPosition (pedX, pedY, pedZ + 1.2) if (not sX) or (sD > 50) then -- Not on screen or too far away break end dxDrawText ('Syncer', sX, sY, 0, 0, tocolor(255,255,255,255), 20 / sD, 'arial') until true end end addEventHandler ('onClientRender', root, renderSyncedElements)
See Also
- getElementBoneMatrix
- getElementBonePosition
- getElementBoneRotation
- getElementBoundingBox
- getElementDistanceFromCentreOfMassToBaseOfModel
- getElementLighting
- getElementRadius
- isElementCollidableWith
- isElementLocal
- isElementOnScreen
- isElementStreamable
- isElementStreamedIn
- isElementSyncer
- isElementWaitingForGroundToLoad
- setElementBoneMatrix
- setElementBonePosition
- setElementBoneRotation
- setElementCollidableWith
- setElementStreamable
- updateElementRpHAnim
- Shared
- attachElements
- createElement
- destroyElement
- detachElements
- getAttachedElements
- getElementAlpha
- getElementAttachedOffsets
- getElementAttachedTo
- getElementByIndex
- getElementByID
- getElementChild
- getElementChildren
- getElementChildrenCount
- getElementCollisionsEnabled
- getElementColShape
- getElementData
- getAllElementData
- hasElementData
- getElementDimension
- getElementHealth
- getElementID
- getElementInterior
- getElementMatrix
- getElementModel
- getElementParent
- getElementPosition
- getElementRotation
- getElementsByType
- getElementsWithinColShape
- getElementsWithinRange
- getElementType
- getElementVelocity
- getLowLODElement
- getRootElement
- isElement
- isElementAttached
- isElementCallPropagationEnabled
- isElementDoubleSided
- isElementFrozen
- isElementInWater
- isElementLowLOD
- isElementWithinColShape
- isElementWithinMarker
- setElementAlpha
- setElementAngularVelocity
- getElementAngularVelocity
- setElementAttachedOffsets
- setElementCallPropagationEnabled
- setElementCollisionsEnabled
- setElementData
- setElementDimension
- setElementDoubleSided
- setElementFrozen
- setElementHealth
- setElementID
- setElementInterior
- setElementModel
- setElementParent
- setElementPosition
- setElementRotation
- setElementVelocity
- setLowLODElement
- getPedContactElement
- getResourceDynamicElementRoot
- getResourceRootElement