GetLatentEventStatus: Difference between revisions
Jump to navigation
Jump to search
(Created page with "__NOTOC__ {{Server client function}} Gets the status of one queued latent event. ==Syntax== Server: <syntaxhighlight lang="lua"> table getLatentEventStatus( element player, int handle ) </syntaxhighlight> ...") |
Fernando187 (talk | contribs) (Remove obsolete Requirements section) |
||
(5 intermediate revisions by 2 users not shown) | |||
Line 4: | Line 4: | ||
==Syntax== | ==Syntax== | ||
Server | |||
<section name="Server" class="server" show="true"> | |||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
table getLatentEventStatus( | table getLatentEventStatus( player thePlayer, int handle ) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Client | ===Required Arguments=== | ||
*'''thePlayer:''' The player who is receiving the event. | |||
*'''handle:''' A handle previous got from [[getLatentEventHandles]]. | |||
</section> | |||
<section name="Client" class="client" show="true"> | |||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
table getLatentEventStatus( int handle ) | table getLatentEventStatus( int handle ) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
===Required Arguments=== | ===Required Arguments=== | ||
*''' | *'''handle:''' A handle previous got from [[getLatentEventHandles]]. | ||
</section> | |||
===Returns=== | ===Returns=== | ||
Returns a table with the following info or false if invalid arguments were passed | Returns a table with the following info or false if invalid arguments were passed: | ||
*'''tickStart:''' A number | *'''tickStart:''' A number estimating how many ticks until the data transfer starts (Negative means the transfer has already started) | ||
*'''tickEnd:''' A number | *'''tickEnd:''' A number estimating how many ticks until the data transfer completes | ||
*'''totalSize:''' A number representing how many bytes in total this transfer will transfer | *'''totalSize:''' A number representing how many bytes in total this transfer will transfer | ||
*'''percentComplete:''' A number between 0-100 saying how much is done | *'''percentComplete:''' A number between 0-100 saying how much is done | ||
==Example== | ==Example== | ||
<section name="Client" class="client" show="true"> | |||
The example starts a latent event and outputs the status of the transfer to the client console | |||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
-- | function beginTransfer() | ||
triggerLatentServerEvent("blah", resourceRoot, myVeryLongString) -- Start latent event | |||
myHandle = getLatentEventHandles()[#getLatentEventHandles()] -- Get last latent event handle | |||
myTimer = setTimer( updateStatus, 1000, 0 ) -- Output status once a second | |||
end | |||
function updateStatus() | |||
local status = getLatentEventStatus(myHandle) -- Get latent event status | |||
if not status then | |||
killTimer(myTimer) -- getLatentEventStatus returns false when the handle is no longer valid | |||
else | |||
outputConsole( "Transfer status:" | |||
.. " tickStart:" .. tostring(status.tickStart) | |||
.. " tickEnd:" .. tostring(status.tickEnd) | |||
.. " totalSize:" .. tostring(status.totalSize) | |||
.. " percentComplete:" .. tostring(status.percentComplete) | |||
) | |||
end | |||
end | |||
</syntaxhighlight> | </syntaxhighlight> | ||
</section> | |||
==See Also== | ==See Also== | ||
{{Event functions}} | {{Event functions}} |
Latest revision as of 15:45, 7 November 2024
Gets the status of one queued latent event.
Syntax
Click to collapse [-]
Servertable getLatentEventStatus( player thePlayer, int handle )
Required Arguments
- thePlayer: The player who is receiving the event.
- handle: A handle previous got from getLatentEventHandles.
Click to collapse [-]
Clienttable getLatentEventStatus( int handle )
Required Arguments
- handle: A handle previous got from getLatentEventHandles.
Returns
Returns a table with the following info or false if invalid arguments were passed:
- tickStart: A number estimating how many ticks until the data transfer starts (Negative means the transfer has already started)
- tickEnd: A number estimating how many ticks until the data transfer completes
- totalSize: A number representing how many bytes in total this transfer will transfer
- percentComplete: A number between 0-100 saying how much is done
Example
Click to collapse [-]
ClientThe example starts a latent event and outputs the status of the transfer to the client console
function beginTransfer() triggerLatentServerEvent("blah", resourceRoot, myVeryLongString) -- Start latent event myHandle = getLatentEventHandles()[#getLatentEventHandles()] -- Get last latent event handle myTimer = setTimer( updateStatus, 1000, 0 ) -- Output status once a second end function updateStatus() local status = getLatentEventStatus(myHandle) -- Get latent event status if not status then killTimer(myTimer) -- getLatentEventStatus returns false when the handle is no longer valid else outputConsole( "Transfer status:" .. " tickStart:" .. tostring(status.tickStart) .. " tickEnd:" .. tostring(status.tickEnd) .. " totalSize:" .. tostring(status.totalSize) .. " percentComplete:" .. tostring(status.percentComplete) ) end end
See Also
- addEvent
- addEventHandler
- cancelEvent
- cancelLatentEvent
- getEventHandlers
- getLatentEventHandles
- getLatentEventStatus
- removeEventHandler
- triggerEvent
- wasEventCancelled