Jump to content

why The script is not working?


Sami_~>

Recommended Posts

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 by Sami_~>
Link to comment
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

 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

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
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 by NeXuS™
  • Thanks 1
Link to comment

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...