GetResourceLoadTime: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
m (→See Also) |
||
(11 intermediate revisions by 6 users not shown) | |||
Line 4: | Line 4: | ||
==Syntax== | ==Syntax== | ||
{{New feature/item|3|1.0|840| | |||
<syntaxhighlight lang="lua"> | |||
int getResourceLoadTime ( resource res ) | |||
</syntaxhighlight> | |||
}} | |||
{{Deprecated_feature|3|1.0| | |||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
string getResourceLoadTime ( resource res ) | string getResourceLoadTime ( resource res ) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
}} | |||
{{OOP||[[resource]]:getLoadTime|loadTime}} | |||
===Required Arguments=== | ===Required Arguments=== | ||
Line 13: | Line 21: | ||
===Returns=== | ===Returns=== | ||
{{New feature|3|1.0 r840| | {{New feature|3|1.0 r840| | ||
If successful, 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. | ||
}} | }} | ||
{{Deprecated_feature|3|1.0| | {{Deprecated_feature|3|1.0| | ||
Line 23: | Line 31: | ||
==Example== | ==Example== | ||
This code outputs the date and time at which the scoreboard resource was last loaded. | This code outputs the date and time at which the scoreboard resource was last loaded. | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua" class="server"> | ||
local res = getResourceFromName ( "scoreboard" ) | local res = getResourceFromName ( "scoreboard" ) | ||
if res then | if res then | ||
outputConsole ( "scoreboard was last loaded on: " .. getResourceLoadTime(res) ) | 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 | |||
</syntaxhighlight> | |||
This code outputs the date and time at which the specified resource started. | |||
<syntaxhighlight lang="lua" class="server"> | |||
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 | end | ||
addCommandHandler("getResourceLoadTime", getLoadTime, false,false) --adds the command handler | |||
</syntaxhighlight> | </syntaxhighlight> | ||
==See Also== | ==See Also== | ||
{{ | {{Resource_functions|server}} |
Latest revision as of 22:47, 6 September 2024
Gets the date and time at which a resource was last loaded in the server.
Syntax
int getResourceLoadTime ( resource res )
OOP Syntax Help! I don't understand this!
- Method: resource:getLoadTime(...)
- Variable: .loadTime
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
- addResourceConfig
- addResourceMap
- callRemote
- copyResource
- createResource
- deleteResource
- getResourceACLRequests
- getResourceInfo
- getResourceLastStartTime
- getResourceLoadFailureReason
- getResourceLoadTime
- getResourceMapRootElement
- getResourceOrganizationalPath
- getResources
- isResourceArchived
- isResourceProtected
- refreshResources
- removeResourceFile
- renameResource
- restartResource
- setResourceInfo
- startResource
- stopResource
- updateResourceACLRequest
- Shared
- abortRemoteRequest
- call
- fetchRemote
- getResourceConfig
- getResourceDynamicElementRoot
- getResourceExportedFunctions
- getResourceFromName
- getResourceName
- getResourceRootElement
- getResourceState
- getThisResource
- getRemoteRequests
- getRemoteRequestInfo