AbortRemoteRequest: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(initial)
 
(Remove obsolete Requirements section)
 
(9 intermediate revisions by 5 users not shown)
Line 1: Line 1:
{{Server client function}}
{{Server client function}}
__NOTOC__
__NOTOC__
{{New feature/item|3.0158|1.5.7|20307|
Aborts a [[FetchRemote|fetchRemote]] or [[CallRemote|callRemote]] request.
Aborts a [[FetchRemote|fetchRemote]] or [[CallRemote|callRemote]] request.
 
}}
==Syntax==
==Syntax==
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
table abortRemoteRequest( request theRequest )
bool abortRemoteRequest( request theRequest )
</syntaxhighlight>
</syntaxhighlight>


===Required Arguments===
===Required Arguments===
* '''theRequest''': the element returned from [[FetchRemote|fetchRemote]] or [[CallRemote|callRemote]]
* '''theRequest''': returned from [[FetchRemote|fetchRemote]], [[CallRemote|callRemote]] or [[GetRemoteRequests|getRemoteRequests]]


==Returns==
==Returns==
Line 15: Line 16:


==Example==
==Example==
<section name="Shared" class="shared" show="true">
This example aborts all requests.
this example aborts all pending requests of currently running resource.
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
function CMD_abortRequests()
function CMD_abortRequests()
Line 22: Line 22:
     for _, request in ipairs(requests) do
     for _, request in ipairs(requests) do
         abortRemoteRequest()
         abortRemoteRequest(request)
     end
     end
end
end
Line 28: Line 28:
addCommandHandler("abortrequests", CMD_abortRequests)
addCommandHandler("abortrequests", CMD_abortRequests)
</syntaxhighlight>
</syntaxhighlight>
</section>
{{Requirements|1.5.7-9.20307|1.5.7-9.20307}}


==See Also==
==See Also==
{{Resource functions}}
{{Resource functions}}

Latest revision as of 17:17, 7 November 2024

Aborts a fetchRemote or callRemote request.

Syntax

bool abortRemoteRequest( request theRequest )

Required Arguments

Returns

Returns true on success, false when invalid request was provided

Example

This example aborts all requests.

function CMD_abortRequests()
    local requests = getRemoteRequests()
	
    for _, request in ipairs(requests) do
        abortRemoteRequest(request)
    end
end

addCommandHandler("abortrequests", CMD_abortRequests)

See Also