Master_MTA Posted August 23, 2017 Share Posted August 23, 2017 (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 August 23, 2017 by Master_MTA Link to comment
XJMLN Posted August 23, 2017 Share Posted August 23, 2017 Code work, check is your backup resource where you have this code have a ACL to copyResource. Link to comment
Master_MTA Posted August 23, 2017 Author Share Posted August 23, 2017 5 minutes ago, XJMLN said: Code work, check is your backup resource where you have this code have a ACL to copyResource. 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. it's not work the wrong in fileRename function Link to comment
Master_MTA Posted August 24, 2017 Author Share Posted August 24, 2017 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 Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now