Jump to content

[Help] Update vehicles.xml without restart freeroam


Maark

Recommended Posts

I want to create a "system" to update any xml (or only the vehicles.xml) without restart the Freeroam.

Like, i create a second resource with alls xml's

ex: resouce1: freeroam, resource2 = xmllist, then i put in xml options in freeroam, the ':xmllist/vehicles.xml' for example. (everything alright)

But, when i restart the xmllist, do not update the freeroam, and i want create a command or a way to "refresh" the xml/gridlist.

I found a way, but it "duplicate" the freeroam window.

 

function testeeetalkei()
	wndCreateVehicle = {
	'wnd',
	text = 'Create vehicle',
	width = 300,
	controls = {
		{
			'lst',
			id='vehicles',
			width=280,
			height=340,
			columns={
				{text='Vehicle', attr='name'}
			},
			rows={xml=':xmllist/vehicles.xml', attrs={'id', 'name'}},
			onitemdoubleclick=createSelectedVehicle,
			DoubleClickSpamProtected=true,
		},
		{'btn', id='create', onclick=createSelectedVehicle, ClickSpamProtected=true},
		{'btn', id='close', closeswindow=true}
	}
	}
	wndMain = {
	'wnd',
	text = 'FR GUI',
	x = 10,
	y = 150,
	width = 280,
	controls = {
		{'lbl', text='Local player'},
		{'br'},
		{'btn', id='kill', onclick=killLocalPlayer},
		{'btn', id='skin', window=wndSkin},
		{'btn', id='anim', window=wndAnim},
		{'btn', id='weapon', window=wndWeapon},
		{'btn', id='clothes', window=wndClothes},
		{'btn', id='playergrav', text='grav', window=wndGravity},
		{'btn', id='warp', window=wndWarp},
		{'btn', id='stats', window=wndStats},
		{'btn', id='bookmarks', window=wndBookmarks},
		{'br'},

		{'chk', id='jetpack', onclick=toggleJetPack},
		{'chk', id='falloff', text='fall off bike', onclick=toggleFallOffBike},
		{'br'},

		{'chk', id='disablewarp', text='disable warp', onclick=toggleWarping},
		{'chk', id='disableknife', text='disable knifing', onclick=toggleKnifing},
		{'chk', id='antiram', text='anti-ramming (vehicle ghostmode)', onclick=toggleGhostmode},
		{'br'},

		{'lbl', text='Pos:'},
		{'lbl', id='xpos', text='x', width=45},
		{'lbl', id='ypos', text='y', width=45},
		{'lbl', id='zpos', text='z', width=45},
		{'btn', id='setpos', text='map', window=wndSetPos},
		{'btn', id='setinterior', text='int', window=wndSetInterior},
		{'br'},
		{'br'},

		{'lbl', text='Vehicles'},
		{'br'},
		{'lbl', text='Current:'},
		{'lbl', id='curvehicle'},
		{'br'},
		{'btn', id='createvehicle', window=wndCreateVehicle, text='create'},
		{'btn', id='repair', onclick=repairVehicle},
		{'btn', id='flip', onclick=flipVehicle},
		{'btn', id='upgrades', window=wndUpgrades},
		{'btn', id='color', onclick=openColorPicker},
		{'btn', id='paintjob', window=wndPaintjob},
		{'br'},
		{'chk', id='lightson', text='Lights on', onclick=forceLightsOn},
		{'chk', id='lightsoff', text='Lights off', onclick=forceLightsOff},
		{'br'},
		{'br'},

		{'lbl', text='Environment'},
		{'br'},
		{'btn', id='time', window=wndTime},
		{'chk', id='freezetime', text='freeze', onclick=toggleFreezeTime},
		{'btn', id='weather', window=wndWeather},
		{'btn', id='speed', window=wndGameSpeed}
	},
	oncreate = mainWndShow,
	onclose = mainWndClose
	}
	createWindow(wndMain, true)
	hideAllWindows()
end
addCommandHandler('test', testeeetalkei)

this way, i restart the xmllist resource and /test and works, but duplicate the window, anyone know how to do this without duplicate or create a function to delete old window or only update the xml? idk how to do it

 

(note: this code is in fr_client.Lua (clientside))

(note2: found some functions that work with xml:

function _buildWindow(wnd, baseWnd, parentWnd) -- at line 141 in gui.Lua
  -- some code...
  if wnd.rows then -- at line 227
		if wnd.rows.xml then
			-- get rows from xml
			bindGridListToTable(wnd, not gridListHasCache(wnd) and xmlToTable(wnd.rows.xml, wnd.rows.attrs) or false,
				wnd.expandlastlevel or wnd.expandlastlevel == nil)
		else
			-- rows hardcoded in window definition
			bindGridListToTable(wnd, not gridListHasCache(wnd) and wnd.rows or false, false)
		end
	end
  --- etc..
end

)

Edited by Maark
  • Confused 1
Link to comment
11 hours ago, #\_oskar_/# said:

 explain what you want?

i want get the vehicle/skins xml (list) in other resource, ex: "resource called: xmlList"
so, i create a command or a function to update it.
Like, i add another vehicle to Freeroam, i dont need restart freeroam, i just need restart the xmlList and do a command "ex: /restartvehiclelist"
and freeroam reload the xml without restarting

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