Author Topic: Can we use XML for 0.4?  (Read 2712 times)

0 Members and 1 Guest are viewing this topic.

Offline Honey.

  • Made Man
  • ***
  • Posts: 111
    • View Profile
Can we use XML for 0.4?
« on: October 13, 2014, 03:41:51 pm »
Hi,

I wanted to ask whether we can use XML files for 0.4.If yes that please tell me the basic functions and if no then please tell me the best replace for XML.I wanted to use it for this :

Quote from: stormeus
To save the path of the bus, you'd have to run a timer every 100ms and save it in an XML file or hash table with its own ID, which is created by making a variable that starts at zero and adding 1 every time the timer runs (so you'd get BusLoc0, BusLoc1, BusLoc2, etc.).

To load the bus' path, you'd load the XML file and read it in a while loop, with a counter that starts at 0 and increases every time the loop runs. As long as the loop can find an XML node with the name BusLoc<COUNTER>, it will write each location into a table that is stored in the server's memory.

You would then create a timer that runs every 100ms, the same rate you were saving the locations at, and move a vehicle to the next position in the table until it reaches the end and resets itself to BusLoc0.

Offline Flockshot

  • Street Thug
  • *
  • Posts: 29
    • View Profile
Re: Can we use XML for 0.4?
« Reply #1 on: October 13, 2014, 05:56:16 pm »
I dont know about XML but you can use .ini file if you want to save location

save by
Code: [Select]
WriteIniString( "yourfile.ini", "Position", "Pos", format( "%.4f %.4f %.4f", player.Pos.x, player.Pos.y, player.Pos.z ) );
and get by
Code: [Select]
local coord = ReadIniString( "yourfile.ini", "Position", "Pos" );

They are from Warcheif.

If you want a timer that save the pos automaticly than you also have to make a integer outside the timer and add 1 to it at the end of timer.

Code: [Select]
local i=0;

function mytimer(player)
{
WriteIniString( "yourfile.ini", "Position" + i, "Pos" + i , format( "%.4f %.4f %.4f", player.Pos.x, player.Pos.y, player.Pos.z ) );
i++
}
dont forget to add i in the Position and Pos.we add it so the name dont match with any previous save as it will replace the previous other than making a new.
For reading u will use a for loop and u will ++ the number and get the positon.
also dont forget to split it in x,y,z
by
Code: [Select]
local splitpos = split( coord, " " );
local pos = Vector(split[0].tofloat(), split[1].tofloat(), split[2].tofloat());
« Last Edit: October 13, 2014, 06:09:05 pm by Flockshot »