Sami_~> Posted February 7, 2018 Share Posted February 7, 2018 (edited) Whats the problem in the script? when i use the commands it is not working and even i had added permissions in acl. if not xmlLoadFile("resources.xml") then xml = xmlCreateFile("resources.xml", "root") xmlSaveFile(xml) xmlUnloadFile(xml) end function writeRunningResources(player, command, ctconfig) if ctconfig == "true" then if not fileExists("mtaserver.txt") then txt = fileCreate("mtaserver.txt") fileClose(txt) end resourceTable = getResources() txt = fileOpen("mtaserver.txt") for resourceKey, resourceValue in ipairs(resourceTable) do if getResourceState(resourceValue) == "running" then resourceName = getResourceName(resourceValue) text = fileRead(txt,9999999) fileWrite(txt, ""..text.." \n <resource src='"..resourceName.."' startup='1' protected='0' />" ) fileFlush(txt) end end fileClose(txt) -- untested! end xmlfile = xmlLoadFile("resources.xml") resourceTable = getResources() for resourceKey, resourceValue in ipairs(resourceTable) do if getResourceState(resourceValue) == "running" then resourceName = getResourceName(resourceValue) xmlNodeSetValue(xmlCreateChild(xmlfile, "resource"), resourceName) xmlSaveFile(xmlfile) end end outputChatBox("Wrote to XML!", root, 255, 0, 0, false) end addCommandHandler("getRunningResources", writeRunningResources, true) function loadResources() outputChatBox("Starting Resources, this can take a while...",root, 255, 0, 0, false) local rootNode = xmlLoadFile ( "resources.xml" ) local nums = xmlNodeGetChildren(rootNode) for i,node in ipairs(nums) do local resource = xmlNodeGetValue ( node ) startResource( getResourceFromName(resource), true) outputChatBox("Resource : "..resource.." started") end end addCommandHandler("loadResources", loadResources, true) Edited February 7, 2018 by Sami_~> Link to comment
Sami_~> Posted February 8, 2018 Author Share Posted February 8, 2018 18 hours ago, NeXuS™ said: Any errors? No Link to comment
keymetaphore Posted February 8, 2018 Share Posted February 8, 2018 Does the function get executed? Show meta.xml Link to comment
Sami_~> Posted February 8, 2018 Author Share Posted February 8, 2018 21 minutes ago, Biistamais said: Show meta.xml <meta> <info author="AJS" type="script" version="1.0" /> <script src="server.lua" type="server" /> <file src="resources.xml" download="false" /> <aclrequest> <right name="function.startResource" access="true"></right> </aclrequest> </meta> Link to comment
Sami_~> Posted February 8, 2018 Author Share Posted February 8, 2018 had Make a script which saves resources names in a text file but it is not working PLEASE ANYBODY CAN HELP ME if not fileExists("mtaserver.txt") then txt = fileCreate("mtaserver.txt") fileClose(txt) end function writeRunningResources() txt = fileOpen("mtaserver.txt") resourceTable = getResources() for resourceKey, resourceValue in ipairs(resourceTable) do if getResourceState(resourceValue) == "running" then resourceName = getResourceName(resourceValue) text = fileRead(txt,9999999) fileWrite(txt, ""..text.." \n <resource src='"..resourceName.."' startup='1' protected='0' />" ) fileFlush(txt) fileClose(txt) end addCommandHandler("getresources", writeRunningResources, true) Link to comment
Sami_~> Posted February 8, 2018 Author Share Posted February 8, 2018 I had Make an another script but it is not woking Plz Fix It local fileHandle = fileCreate("mtaserver.txt") function writeRunningResources() if getResourceState(resourceValue) == "running" then resourceName = getResourceState(resourceValue) text = fileRead(fileHandle,9999999) fileWrite(fileHandle, ""..text.." \n <resource src='"..resourceName.."' startup='1' protected='0' />" ) fileClose(fileHandle) addCommandHandler("getresources", writeRunningResources, true) Link to comment
NeXuS™ Posted February 8, 2018 Share Posted February 8, 2018 (edited) When I get home I'll fix your script. Btw, the code above is full of errors. Edited February 8, 2018 by NeXuS™ Link to comment
Sami_~> Posted February 9, 2018 Author Share Posted February 9, 2018 5 hours ago, NeXuS™ said: When I get home I'll fix your script Ok Link to comment
NeXuS™ Posted February 9, 2018 Share Posted February 9, 2018 (edited) local fileHandle = fileCreate("mtaserver.txt") function writeRunningResources() if not fileHandle then fileHandle = fileCreate("mtaserver.txt") end for i, k in pairs(getResources()) do if getResourceState(k) == "running" then fileWrite(fileHandle, "<resource src='" .. getResourceName(k) .. "' startup='1' protected='0'/>\n") end end outputChatBox("Got resources in the list.") fileClose(fileHandle) end addCommandHandler("getresources", writeRunningResources) Here. Edited February 9, 2018 by NeXuS™ 1 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