CopyResource: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
(6 intermediate revisions by 4 users not shown) | |||
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
{{Server function}} | {{Server function}} | ||
This function copies a specified [[resource]] with a new name. | This function copies a specified [[resource]] with a new name. | ||
==Syntax== | ==Syntax== | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
resource copyResource ( resource theResource, string newResourceName [, string organizationalDir ] ) | |||
</syntaxhighlight> | </syntaxhighlight> | ||
{{OOP||[[resource]]:copy}} | |||
===Required Arguments=== | ===Required Arguments=== | ||
*'''theResource:''' the resource which is going to be copied | *'''theResource:''' the resource which is going to be copied | ||
*'''newResourceName:''' the name that the copied resource will receive | *'''newResourceName:''' the name that the copied resource will receive | ||
===Optional Arguments=== | |||
{{OptionalArg}} | |||
* '''organizationalDir''': A string containing the path where the resource should be copied to (e.g. "[gamemodes]/[amx]"). | |||
===Returns=== | ===Returns=== | ||
Returns | Returns the [[resource]] element of the copy. Returns ''false'' if the arguments are incorrect. | ||
==Example== | ==Example== | ||
Line 29: | Line 32: | ||
addCommandHandler ("backupresource",backupResouce) -- add command | addCommandHandler ("backupresource",backupResouce) -- add command | ||
</syntaxhighlight> | </syntaxhighlight> | ||
==Requirements== | |||
{{Requirements|1.1.1-9.03316|n/a|}} | |||
==See Also== | ==See Also== | ||
{{Resource_functions}} | {{Resource_functions}} |
Latest revision as of 22:51, 26 September 2016
This function copies a specified resource with a new name.
Syntax
resource copyResource ( resource theResource, string newResourceName [, string organizationalDir ] )
OOP Syntax Help! I don't understand this!
- Method: resource:copy(...)
Required Arguments
- theResource: the resource which is going to be copied
- newResourceName: the name that the copied resource will receive
Optional Arguments
NOTE: When using optional arguments, you might need to supply all arguments before the one you wish to use. For more information on optional arguments, see optional arguments.
- organizationalDir: A string containing the path where the resource should be copied to (e.g. "[gamemodes]/[amx]").
Returns
Returns the resource element of the copy. Returns false if the arguments are incorrect.
Example
-- This script can backup your resource with a easy command! /backupresource [resourcename] function backupResource (player,command,resourcetobackup) -- start the function if (resourcetobackup) and (getResourceFromName(resourcetobackup)) then -- check if the resource is exist copyResource (getResourceFromName(resourcetobackup),resourcetobackup .. "_backup") -- copy the resource and give it the name [resource]_backup outputChatBox ("Resource " .. resourcetobackup .. " succesfully backed up!",player,255,0,0,false) -- say it's OK! else -- if it isn't exist outputChatBox ("Resource can't be backed up! (don't forget the parameters!)",player,255,0,0,false) -- say it isn't exist! end end addCommandHandler ("backupresource",backupResouce) -- add command
Requirements
Minimum server version | 1.1.1-9.03316 |
---|---|
Minimum client version | n/a |
Note: Using this feature requires the resource to have the above minimum version declared in the meta.xml <min_mta_version> section. e.g. <min_mta_version server="1.1.1-9.03316" />
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
- call
- fetchRemote
- getResourceConfig
- getResourceDynamicElementRoot
- getResourceExportedFunctions
- getResourceFromName
- getResourceName
- getResourceRootElement
- getResourceState
- getThisResource
- getRemoteRequests
- getRemoteRequestInfo
- abortRemoteRequest