HasElementDataSubscriber
Jump to navigation
Jump to search
This function returns whether a player is subscribed to specific element data. This function is used together with setElementData in "subscribe" mode.
Syntax
bool hasElementDataSubscriber ( element theElement, string key, player thePlayer )
OOP Syntax Help! I don't understand this!
- Method: element:hasDataSubscriber(...)
Required Arguments
- theElement: The element you wish to check whether the player is subscribed to.
- key: The key you wish to check whether the player is subscribed to.
- thePlayer: The player you wish to check.
Returns
Returns true if the player is subscribed, false otherwise.
Example
Click to collapse [-]
Serverlocal nameOfOurElementData = "random" --// name our element data for i,v in ipairs(getElementsByType("player")) do --// loop through all the players on the server setElementData(v, nameOfOurElementData, true, "subscribe") --// set our element data to all players on server end function checkIsSubscribed(plr,cmd, key) if not key then return end --// check if you've typed element data key local randomPlayer = getRandomPlayer() --// getting random player from server local isSubscribed = hasElementDataSubscriber(randomPlayer, tostring(key), randomPlayer) --// use our function if not isSubscribed then --// if random player is not subscribed to given element data key then add him to subscription addElementDataSubscriber(randomPlayer, tostring(key), randomPlayer) outputChatBox("Element data key: "..tostring(key).." is now subscribed to: "..getPlayerName(randomPlayer), plr, 255, 255, 255, true) else --// if he is subscribed to given element data then remove him from subscription removeElementDataSubscriber(randomPlayer, tostring(key), randomPlayer) outputChatBox(getPlayerName(randomPlayer).." has been removed from subscription from element data key: "..tostring(key), plr, 255, 255, 255, true) end end addCommandHandler("checksub", checkIsSubscribed, false, false) --// creating command /checksub not restricted and not CASE sensitive --// EXAMPLE: /checksub random
Requirements
This template will be deleted.
See Also
- addElementDataSubscriber
- clearElementVisibleTo
- cloneElement
- getElementSyncer
- getElementZoneName
- hasElementDataSubscriber
- isElementVisibleTo
- removeElementData
- removeElementDataSubscriber
- setElementSyncer
- setElementVisibleTo
- 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