21.11.2010, 13:10
Where does xml_open pull the file from?
if (bool(doc->load_file(complete_path(filename, "scriptfiles/"))))
I have made a new version which also has functions for document building/modification, if you want to try it out you can download it here. See include file for functions description. Have fun!
|
<player> // GetFirstChild( node of document, "player" )
<profile> // GetFirstChild( node of player, "profile" )
<password>asdf8s9ad7f2</password> // GetFirstChild( node of profile, "password" )
<sex>male</sex> // GetNextSibling( node of password, "sex" )
<age>18</age> // GetNextSibling( node of sex, "age" )
</profile>
<ingame> // GetNextSibling( node of profile, "ingame" )
<saved_position> // ....
<x>123.456</x>
<y>9871.8712</y>
<z>3.000</z>
</saved_position>
<money>100000</money>
<weapon name="Deagle" ammo="60" /> // to get name: GetAttribute ( node of weapon, "name", dest_string )
<weapon name="Minigun" ammo="5000" />
<weapon name="Chainsaw" ammo="0" />
</ingame>
</player>
stock Teleport_Cargar()
{
new XMLNode:current_node = XML_LoadDocument("teleports.xml");
if(current_node)
{
new slot;
current_node = XML_GetFirstChild(current_node, "teleports");
if(current_node)
{
new string[64];
new XMLNode:next_node;
current_node = XML_GetFirstChild(current_node);
while(current_node)
{
next_node = XML_GetNextSibling(current_node);
current_node = XML_GetFirstChild(current_node, "name");
XML_GetValue(current_node, Teleport[slot][NOMBRE], 32);
current_node = XML_GetNextSibling(current_node, "type");
XML_GetValue(current_node, string, sizeof(string));
Teleport[slot][TIPO] = strval(string);
current_node = XML_GetNextSibling(current_node, "command");
XML_GetValue(current_node, Teleport[slot][COMANDO], 32);
current_node = XML_GetNextSibling(current_node, "position");
current_node = XML_GetFirstChild(current_node, "x");
XML_GetValue(current_node, string, sizeof(string));
Teleport[slot][POS][0] = floatstr(string);
current_node = XML_GetNextSibling(current_node, "y");
XML_GetValue(current_node, string, sizeof(string));
Teleport[slot][POS][1] = floatstr(string);
current_node = XML_GetNextSibling(current_node, "z");
XML_GetValue(current_node, string, sizeof(string));
Teleport[slot][POS][2] = floatstr(string);
current_node = XML_GetNextSibling(current_node, "a");
XML_GetValue(current_node, string, sizeof(string));
Teleport[slot][POS][3] = floatstr(string);
current_node = next_node;
slot += 1;
}
}
printf("Teleports cargados: %i.", slot);
return 1;
}
return 0;
}
current_node = XML_GetFirstChild(current_node, "name");
XML_GetValue(current_node, Teleport[slot][NOMBRE], 32); // This call is crashing the server.