GetRemoteRequestInfo: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(fix magically added typo)
(fix description)
Line 16: Line 16:
==Example==
==Example==
<section name="Server" class="server" show="true">
<section name="Server" class="server" show="true">
This example gets infos about all pending requests
This example gets infos about all pending requests and prints them in debugscript
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
function CMD_requestInfo(player, _, resourceName)
function CMD_requestInfo(player, _, resourceName)
Line 44: Line 44:
</section>
</section>
<section name="Client" class="client" show="true">
<section name="Client" class="client" show="true">
This example gets infos about all pending requests
This example gets infos about all pending requests and prints them in debugscript
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
function CMD_requestInfo(player, _, resourceName)
function CMD_requestInfo(player, _, resourceName)

Revision as of 06:26, 8 October 2019

Gets informations of an fetchRemote or callRemote request info.

Syntax

bool getRemoteRequestInfo ( request theRequest )

Required Arguments

Returns

Returns a table when valid, false otherwise

Example

Click to collapse [-]
Server

This example gets infos about all pending requests and prints them in debugscript

function CMD_requestInfo(player, _, resourceName)
    local res = resourceName and getResourceFromName(resourceName) or not resourceName and nil
	
    if(res == false) then
        outputServerLog("There is no resource named '" .. resourceName .. "'")
        return
    elseif(res and getResourceState(res) ~= "running") then
        outputServerLog("The provided resource '" .. resourceName .. "' is not running")
        return
    end
	
    local requests = getRemoteRequests(res)
	
    for _, request in ipairs(requests) do
        local requestInfo = getRemoteRequestInfo(request)
		
        if(requestInfo) then
            iprint(requestInfo)
        end
    end
end

addCommandHandler("requestinfo", CMD_requestInfo)
Click to collapse [-]
Client

This example gets infos about all pending requests and prints them in debugscript

function CMD_requestInfo(player, _, resourceName)
    local res = resourceName and getResourceFromName(resourceName) or not resourceName and nil
	
    if(res == false) then
        outputChatBox("There is no resource named '" .. resourceName .. "'")
        return
    elseif(res and getResourceState(res) ~= "running") then
        outputChatBox("The provided resource '" .. resourceName .. "' is not running")
        return
    end
	
    local requests = getRemoteRequests(res)
	
    for _, request in ipairs(requests) do
        local requestInfo = getRemoteRequestInfo(request)
		
        if(requestInfo) then
            iprint(requestInfo)
        end
    end
end

addCommandHandler("requestinfo", CMD_requestInfo)


This template will be deleted.

See Also