GetRemoteRequests: Difference between revisions
		
		
		
		
		
		Jump to navigation
		Jump to search
		
				
		
		
	
 (Fix version)  | 
				 (Fix clientside example)  | 
				||
| Line 40: | Line 40: | ||
This example prints how many request are currently pending.  | This example prints how many request are currently pending.  | ||
<syntaxhighlight lang="lua">  | <syntaxhighlight lang="lua">  | ||
function CMD_requestInfo(  | function CMD_requestInfo(_, resourceName)  | ||
     local res = resourceName and getResourceFromName(resourceName) or not resourceName and nil  |      local res = resourceName and getResourceFromName(resourceName) or not resourceName and nil  | ||
     if(res == false) then  |      if(res == false) then  | ||
         outputChatBox("There is no resource named '" .. resourceName .. "'"  |          outputChatBox("There is no resource named '" .. resourceName .. "'")  | ||
         return  |          return  | ||
     elseif(res and getResourceState(res) ~= "running") then  |      elseif(res and getResourceState(res) ~= "running") then  | ||
         outputChatBox("The provided resource '" .. resourceName .. "' is not running"  |          outputChatBox("The provided resource '" .. resourceName .. "' is not running")  | ||
         return  |          return  | ||
     end  |      end  | ||
| Line 53: | Line 53: | ||
     local requests = getRemoteRequests(res)  |      local requests = getRemoteRequests(res)  | ||
     outputChatBox(("There are %d request%s running"):format(#requests, #requests == 1 and '' or 's')  |      outputChatBox(("There are %d request%s running"):format(#requests, #requests == 1 and '' or 's'))  | ||
end  | end  | ||
Revision as of 06:08, 8 October 2019
Gets all Template:FetchRemote and Template:CallRemote requests currently running.
Syntax
bool getRemoteRequests ( [ resource theResource = nil ] )
Optional Arguments
- theResource: the resource to get all requests from
 
Returns
Returns a table with all requests, false if an invalid resource was provided
Example
Click to collapse [-]
ServerThis example prints how many request are currently pending.
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 .. "'", player)
        return
    elseif(res and getResourceState(res) ~= "running") then
        outputChatBox("The provided resource '" .. resourceName .. "' is not running", player)
        return
    end
    local requests = getRemoteRequests(res)
	
    outputChatBox(("There are %d request%s running"):format(#requests, #requests == 1 and '' or 's'), player)
end
addCommandHandler("requestinfo", CMD_requestInfo)
Click to collapse [-]
ClientThis example prints how many request are currently pending.
function CMD_requestInfo(_, 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)
	
    outputChatBox(("There are %d request%s running"):format(#requests, #requests == 1 and '' or 's'))
end
addCommandHandler("requestinfo", CMD_requestInfo)
This template will be deleted.
See Also
- abortRemoteRequest
 - call
 - fetchRemote
 - getResourceConfig
 - getResourceDynamicElementRoot
 - getResourceExportedFunctions
 - getResourceFromName
 - getResourceName
 - getResourceRootElement
 - getResourceState
 - getThisResource
 - getRemoteRequests
 - getRemoteRequestInfo