[Plugin] [REL] XML loader
#41

Where does xml_open pull the file from?
Reply
#42

Quote:
Originally Posted by Ace_Menace
Посмотреть сообщение
Where does xml_open pull the file from?
Hi,

Seems to be from the "scriptfiles" folder. Line 46 of scripting.cpp:
Код:
if (bool(doc->load_file(complete_path(filename, "scriptfiles/"))))
"scriptfiles/" is the prefix, so it is the root.

I hope I could help, although it is ZeeXґs plugin.
Reply
#43

Hello, is it possible to edit XML file with a function?
Reply
#44

Yes, you need his new version:

Quote:
Originally Posted by Zeex
Посмотреть сообщение
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!
Use XML_SetValue
Reply
#45

Great work man.
Reply
#46

Quote:
Originally Posted by Remis
Посмотреть сообщение
Yes, you need his new version:



Use XML_SetValue
Alright, thanks
Reply
#47

Pls, give examples for new version of this plugin!
Reply
#48

Zeex please make examples to a new version of XML plugin beacose i dont understand this...
Reply
#49

pawn Код:
<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>
Got it ?
Reply
#50

how to put this on plugins ??
please help
Reply
#51

I need some help, I can't get my script to read an XML file with teleports:

XML file: http://pastebin.com/w0CsJ9b5

Load function:
pawn Код:
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;
}
The server crashes after:
pawn Код:
current_node = XML_GetFirstChild(current_node, "name");
XML_GetValue(current_node, Teleport[slot][NOMBRE], 32); // This call is crashing the server.
Reply
#52

Sorry for bump, but wondering if this plugin is still usable?


EDIT: Works fine

---

Compiled on Ubuntu 14.04 x86: http://toplel.us/xmlplugin/xml.so
Compiled on Windows 7 x64: http://toplel.us/xmlplugin/xml.dll
Include file: http://www.toplel.us/xmlplugin/xml.inc

Source: https://github.com/Zeex/samp-plugin-xml
Reply
#53

Does this project still up to date ?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)