CopyResource: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
-ffs-Sniper (talk | contribs) (Added optional argument, fixed returns and added note about revision) |
||
Line 2: | Line 2: | ||
{{Server function}} | {{Server function}} | ||
This function copies a specified [[resource]] with a new name. | This function copies a specified [[resource]] with a new name. | ||
'''Note:''' This function only works properly from 1.3.0-3912 (r3912). In case you are below r3912 you need to create a directory called "trash" inside of the "resources-cache" folder . | |||
==Syntax== | ==Syntax== | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
bool copyResource ( resource theResource, string newResourceName ) | bool copyResource ( resource theResource, string newResourceName[, string organizationalDir] ) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Line 11: | Line 13: | ||
*'''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 that was copied. Returns ''false'' if the arguments are incorrect | ||
==Example== | ==Example== |
Revision as of 22:38, 28 March 2012
This function copies a specified resource with a new name.
Note: This function only works properly from 1.3.0-3912 (r3912). In case you are below r3912 you need to create a directory called "trash" inside of the "resources-cache" folder .
Syntax
bool copyResource ( resource theResource, string newResourceName[, string organizationalDir] )
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 that was copied. 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
This template will be deleted.
See Also
- abortRemoteRequest
- call
- fetchRemote
- getResourceConfig
- getResourceDynamicElementRoot
- getResourceExportedFunctions
- getResourceFromName
- getResourceName
- getResourceRootElement
- getResourceState
- getThisResource
- getRemoteRequests
- getRemoteRequestInfo