Jump to content

copyResource


Master_MTA

Recommended Posts

Posted (edited)

hi i am really didn't know what is the wrong in that code

local ff=fileCreate('Buckups/test.txt')

function backupResource (player,command,resourcetobackup)
  if (resourcetobackup) and (getResourceFromName(resourcetobackup)) then 
    copyResource (getResourceFromName(resourcetobackup),resourcetobackup .. "_backup")
	fileRename(resourcetobackup .. "_backup",':'..getResourceName(getThisResource())..'/Buckups'..resourcetobackup .. "_backup")
    outputChatBox ("Resource " .. resourcetobackup .. " succesfully backed up!",player,255,0,0,false)
  else 
    outputChatBox ("Resource can't be backed up! (don't forget the parameters!)",player,255,0,0,false)
  end
end
addCommandHandler ("backupresource",backupResource)

 

Edited by Master_MTA

Skype 01100001 01101100 01101001 01011111 01101101 01110100 00110001 00111001 00111001 00111001

every thing is gonna be alright

every thing is gonna be okay

it's gonna be a good good life

that's what my therapist say

Posted

up

Skype 01100001 01101100 01101001 01011111 01101101 01110100 00110001 00111001 00111001 00111001

every thing is gonna be alright

every thing is gonna be okay

it's gonna be a good good life

that's what my therapist say

Posted
5 minutes ago, XJMLN said:

Code work, check is your backup resource where you have this code have a ACL to copyResource.

hPe9ptI.png

thx i will check it

21 minutes ago, XJMLN said:

Code work, check is your backup resource where you have this code have a ACL to copyResource.

hPe9ptI.png

it's not work the wrong in fileRename function

Skype 01100001 01101100 01101001 01011111 01101101 01110100 00110001 00111001 00111001 00111001

every thing is gonna be alright

every thing is gonna be okay

it's gonna be a good good life

that's what my therapist say

Posted

thx' all

i am created my own function

function copyResourceIntoResource(res,tores)
local ta={}
local conf=xmlLoadFile( ':'..res..'/meta.xml' )
	local cildren=xmlNodeGetChildren(conf)
		local function isreg(value,msr)
			if #msr==0 then return false end
				for l,c in pairs(msr) do
					if c==value or (#split(c,',')>1 and split(c,',')[1]==value) then return l end
			end
		return false
	end
		for k=1,#cildren do
			local name=xmlNodeGetName(cildren[k])
				local jj=isreg(name,ta)
					if jj~=false then
					ta[jj]=ta[jj]..','..name
				else
					table.insert(ta,name)
			end
		end
	fileCopy(':'..res..'/'..'meta.xml', tores..'/'..res.."/meta.xml")
	for k,v in pairs(ta)do
		local spl=#split(v,',')
			for m=0,spl-1 do
				local chil=xmlFindChild (conf,split(v,',')[1],m)
				local at=xmlNodeGetAttribute(chil,'src')
				if at then
					 fileCopy(':'..res..'/'..at, tores..'/'..res.."/"..at)
					 if #ta==k then 	xmlUnloadFile(conf) return true end
				end
			end
		end
return false

end

 

Skype 01100001 01101100 01101001 01011111 01101101 01110100 00110001 00111001 00111001 00111001

every thing is gonna be alright

every thing is gonna be okay

it's gonna be a good good life

that's what my therapist say

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...