GetResourceLoadTime: Difference between revisions
Jump to navigation
Jump to search
m (Fixed typo) |
|||
Line 34: | Line 34: | ||
if res then | if res then | ||
local time = getRealTime(getResourceLoadTime(res)) --Gets all the data we need from UNIX time format, see getRealTime() for more details | local time = getRealTime(getResourceLoadTime(res)) --Gets all the data we need from UNIX time format, see getRealTime() for more details | ||
outputConsole ( "scoreboard was last loaded on: " .. string.format("%i/%i/%i %i:%i:%i",time.monthday,time.month,time.year,time.hour,time.minute | outputConsole ( "scoreboard was last loaded on: " .. string.format("%i/%i/%i %i:%i:%i",time.monthday,time.month,time.year,time.hour,time.minute,time.second)) --this will be something like this: scoreboard was last loaded on: 10/07/2017 14:13:10 | ||
end | end | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Line 45: | Line 45: | ||
else | else | ||
local time = getRealTime(getRealTime().timestamp-getResourceLoadTime(resource)) | local time = getRealTime(getRealTime().timestamp-getResourceLoadTime(resource)) | ||
outputChatBox("The resource " .. res .. " started at " .. string.format("%i/%i/%i %i:%i:%i",time.monthday,time.month,time.year,time.hour,time.minute | outputChatBox("The resource " .. res .. " started at " .. string.format("%i/%i/%i %i:%i:%i",time.monthday,time.month,time.year,time.hour,time.minute,time.second)) | ||
end | end | ||
end | end |
Revision as of 10:29, 18 October 2017
Gets the date and time at which a resource was last loaded in the server.
Syntax
int getResourceLoadTime ( resource res )
Required Arguments
- res: the resource you want to know the load time of.
Returns
If successful, returns the UNIX timestamp when the resource was loaded, otherwise false. Use in conjunction with getRealTime in order to retrieve detailed information.
Example
This code outputs the date and time at which the scoreboard resource was last loaded.
local res = getResourceFromName ( "scoreboard" ) if res then local time = getRealTime(getResourceLoadTime(res)) --Gets all the data we need from UNIX time format, see getRealTime() for more details outputConsole ( "scoreboard was last loaded on: " .. string.format("%i/%i/%i %i:%i:%i",time.monthday,time.month,time.year,time.hour,time.minute,time.second)) --this will be something like this: scoreboard was last loaded on: 10/07/2017 14:13:10 end
This code outputs the date and time at which the specified resource started.
function getLoadTime(p,c,res) local resource = getResourceFromName(tostring(res)) if not res or not resource then outputChatBox("Syntax: /" .. c .. " [Resource Name]") else local time = getRealTime(getRealTime().timestamp-getResourceLoadTime(resource)) outputChatBox("The resource " .. res .. " started at " .. string.format("%i/%i/%i %i:%i:%i",time.monthday,time.month,time.year,time.hour,time.minute,time.second)) end end addCommandHandler("getResourceLoadTime", getLoadTime, false,false) --adds the command handler
See Also
- abortRemoteRequest
- call
- fetchRemote
- getResourceConfig
- getResourceDynamicElementRoot
- getResourceExportedFunctions
- getResourceFromName
- getResourceName
- getResourceRootElement
- getResourceState
- getThisResource
- getRemoteRequests
- getRemoteRequestInfo