GetLatentEventHandles: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Created page with "__NOTOC__ {{Server client function}} 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 [...")
 
m (Remove "need example" box)
 
(12 intermediate revisions by 5 users not shown)
Line 4: Line 4:


==Syntax==
==Syntax==
<section name="Server" class="server" show="true">
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
table getLatentEventHandles ( element player )
table getLatentEventHandles ( player thePlayer )
</syntaxhighlight>
</syntaxhighlight>
===Required Arguments===
*'''thePlayer:''' The player who is receiving the events.
</section>


===Required Arguments===
<section name="Client" class="client" show="true">
*'''player:''' (Only required if called on the server) The player who is receiving the events.
<syntaxhighlight lang="lua">
table getLatentEventHandles ( )
</syntaxhighlight>
</section>


===Returns===
===Returns===
Returns a table of handles or false if invalid arguments were passed.
Returns a table of handles or false if invalid arguments were passed.


==Example==
==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.
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
--TODO
 
-- 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>
</syntaxhighlight>
==Requirements==
{{Requirements|1.3.0-9.03772|1.3.0-9.03772|}}


==See Also==
==See Also==
{{Event functions}}
{{Event functions}}

Latest revision as of 09:58, 12 February 2024

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 [-]
Server
table getLatentEventHandles ( player thePlayer )

Required Arguments

  • thePlayer: The player who is receiving the events.
Click to collapse [-]
Client
table 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

Minimum server version 1.3.0-9.03772
Minimum client version 1.3.0-9.03772

Note: Using this feature requires the resource to have the above minimum version declared in the meta.xml <min_mta_version> section. e.g. <min_mta_version server="1.3.0-9.03772" client="1.3.0-9.03772" />

See Also