GetLatentEventHandles: Difference between revisions
Jump to navigation
Jump to search
ThePiotrek (talk | contribs) mNo edit summary |
|||
Line 23: | Line 23: | ||
==Example== | ==Example== | ||
<syntaxhighlight lang="lua"> | This command is triggering an latent-event to server, and if you write the command again and the trigger still didn't end then you have to wait. | ||
<syntaxhighlight lang="lua"> | |||
-- CLIENT SIDE: | |||
local lastTriggerd = false | |||
addCommandHandler("trigger",function() | |||
local triggers = getLatentEventHandles() -- get all latent events | |||
if triggers[lastTriggerd] then -- you can use (getLatentEventStatus) too! | |||
outputChatBox("Wait until the trigger ("..lastTriggerd..") ends!",255,0,0) | |||
return | |||
end | |||
triggerLatentServerEvent("LatentEventsCheck",20000,resourceRoot,localPlayer) | |||
lastTriggerd = #getLatentEventHandles() -- set the lastTriggerd with the id for last event triggerd | |||
end) | |||
-- SERVER SIDE: | |||
addEvent("LatentEventsCheck",true) | |||
addEventHandler("LatentEventsCheck",root,function (thePlayer) | |||
outputChatBox("Latent trigger done from: " .. getPlayerName(thePlayer), root,math.random(255),0,0) | |||
end) | |||
</syntaxhighlight> | |||
==Requirements== | ==Requirements== |
Revision as of 20:40, 12 December 2023
Script Example Missing Function GetLatentEventHandles needs a script example, help out by writing one. | |
Before submitting check out Editing Guidelines Script Examples. |
Gets the currently queued latent events. The last one in the table is always the latest event queued. Each returned handle can be used with getLatentEventStatus or cancelLatentEvent
Syntax
Click to collapse [-]
Servertable getLatentEventHandles ( player thePlayer )
Required Arguments
- thePlayer: The player who is receiving the events.
Click to collapse [-]
Clienttable getLatentEventHandles ( )
Returns
Returns a table of handles or false if invalid arguments were passed.
Example
This command is triggering an latent-event to server, and if you write the command again and the trigger still didn't end then you have to wait.
-- CLIENT SIDE: local lastTriggerd = false addCommandHandler("trigger",function() local triggers = getLatentEventHandles() -- get all latent events if triggers[lastTriggerd] then -- you can use (getLatentEventStatus) too! outputChatBox("Wait until the trigger ("..lastTriggerd..") ends!",255,0,0) return end triggerLatentServerEvent("LatentEventsCheck",20000,resourceRoot,localPlayer) lastTriggerd = #getLatentEventHandles() -- set the lastTriggerd with the id for last event triggerd end) -- SERVER SIDE: addEvent("LatentEventsCheck",true) addEventHandler("LatentEventsCheck",root,function (thePlayer) outputChatBox("Latent trigger done from: " .. getPlayerName(thePlayer), root,math.random(255),0,0) end)
Requirements
This template will be deleted.
See Also
- addEvent
- addEventHandler
- cancelEvent
- cancelLatentEvent
- getEventHandlers
- getLatentEventHandles
- getLatentEventStatus
- removeEventHandler
- triggerEvent
- wasEventCancelled