getLatentEventHandles | Multi Theft Auto: Wiki Skip to content

getLatentEventHandles

Client-side
Server-side
Shared

Gets the currently queued latent events. The last one in the table is always the latest event queued.

Client Syntax

table getLatentEventHandles ( )

Returns

  • table: result

Returns a table of handles, otherwise false if invalid arguments were passed.

Server Syntax

table getLatentEventHandles ( ​player thePlayer )
Required Arguments
  • thePlayer: The player who is receiving the events.

Returns

  • table: result

Returns a table of handles, otherwise false if invalid arguments were passed.

Code Examples

client

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 CODE
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 CODE
addEvent("LatentEventsCheck", true)
addEventHandler("LatentEventsCheck", root, function(thePlayer)
outputChatBox("Latent trigger done from: " .. getPlayerName(thePlayer), root, math.random(255), 0, 0)
end)