Re: [REL] XML loader -
Mishanzanza - 06.06.2010
Oh wow, nice plugin!
Re: [REL] XML loader -
Agent Smith - 07.06.2010
Woow, This is really nice but is it possible to change infromation in the XML document?
Re: [REL] XML loader - Zeex - 07.06.2010
No, with this plugin you can only read them, writing features aren't supported yet but I'm planning to add them in future versions.
Re: [REL] XML loader -
Romanius - 07.06.2010
Can I load with this plugin MTA maps?
Re: [REL] XML loader -
Kyosaur - 07.06.2010
Quote:
Originally Posted by Romanius
Can I load with this plugin MTA maps?
|
Sure you can. I wrote a loading function today actually lol.
Код:
static
ObjectCount,
VehicleCount;
new ObjAttr[][] =
{
"model",
"posX",
"posY",
"posZ",
"rotX",
"rotY",
"rotZ",
"dimension",
"interior"
};
stock LoadMapFile(const path[], Float:DrawDistance = 200.0, VehRespawn = 20)
{
new
Str[9][40],
XML:Map = xml_open(path);
if(Map)
{
new
Objects = xml_get_int(Map, "count(map/object)"),
Vehicle = xml_get_int(Map, "count(map/vehicle)"),
Max = max(Vehicle,Objects);
for(new a=1,b=Max+1; a<b; a++)
{
if(Objects != 0 && Objects >= a)
{
for(new c=0; c<sizeof(ObjAttr); c++)
{
format(Str[c], sizeof(Str[]), "map/object[%d]/@%s",a,ObjAttr[c]);
}
CreateDynamicObject(xml_get_int(Map,Str[0]),xml_get_float(Map,Str[1]),xml_get_float(Map,Str[2]),xml_get_float(Map,Str[3]),xml_get_float(Map,Str[4]),xml_get_float(Map,Str[5]),xml_get_float(Map,Str[6]),xml_get_int(Map,Str[7]),xml_get_int(Map,Str[8]),-1,DrawDistance);
ObjectCount++;
}
if(Vehicle != 0 && Vehicle >= a)
{
for(new c=0; c<sizeof(ObjAttr); c++) //Same attributes for vehicles..
{
if(c == 4 || c == 5) continue;
format(Str[c], sizeof(Str[]), "map/vehicle[%d]/@%s",a,ObjAttr[c]);
}
CreateVehicleEx(xml_get_int(Map,Str[0]),xml_get_float(Map,Str[1]),xml_get_float(Map,Str[2]),xml_get_float(Map,Str[3]),xml_get_float(Map,Str[6]),xml_get_int(Map,Str[7]),xml_get_int(Map,Str[8]),-1,-1,VehRespawn);
VehicleCount++;
}
}
xml_close(Map);
return 1;
}
printf(" ** Map was not found at path \"%s\".", path);
return 1;
}
Its not the most efficient thing on the planet, but it gets the job done. At the moment it only supports MTA 1.0.
please note that this example uses incognito's streamer, and my own personal CreateVehicleEx function. You can easily adapt it to any format though.
EDIT: I updated the code, and managed to remove a loop; its still a little slow, so i suggest only using it under OnGameModeInit and OnFilterScriptInit. Please ignore the indentation lol, forums always mess it up :\.
Re: [REL] XML loader -
Agent Smith - 07.06.2010
Quote:
Originally Posted by Zeex
No, with this plugin you can only read them, writing features aren't supported yet but I'm planning to add them in future versions.
|
Cool, I might use this in my script when it has the writing features. Looks really good at the moment, Good work
Re: [REL] XML loader -
ReVo_ - 07.06.2010
File position? i created 'account.xml' on 'scriptfiles' and not work.
Re: [REL] XML loader -
Agent Smith - 07.06.2010
Quote:
Originally Posted by [TLV
ReVo_ ]
File position? i created 'account.xml' on 'scriptfiles' and not work.
|
If you used the one on the main page then I think it is.
Код:
.../scriptfiles/players
Re: [REL] XML loader -
ReVo_ - 07.06.2010
No,i put 'profile' in the /scriptfiles/players and not worked.
Re: [REL] XML loader -
Agent Smith - 08.06.2010
I just looked at the example and relised that you put the account.xml into the scriptfiles area and the ../profile is the stuff that is inside the .xml file. Maybe your not loading it right?
Re: [REL] XML loader -
Cold_Revenge - 03.08.2010
HELP
![Huh?](images/smilies/confused.gif)
Unable to connect XML
My code:
Код:
#define LANGUAGE_FILE_XML "Languages.xml"
new XML:LangXML;
forward XMLConnect();
forward XMLExit();
public OnFilterScriptInit()
{
XMLConnect();
}
public OnFilterScriptExit()
{
XMLExit();
}
public XMLConnect()
{
LangXML=xml_open(LANGUAGE_FILE_XML);
if(!LangXML)
{
SetConsoleTextColors(CONSOLE_RED);
printf("XML Bağlantısı Başarısız...");
SetConsoleTextColors(CONSOLE_DEFAULT);
return 1;
}
else
{
SetConsoleTextColors(CONSOLE_GREEN);
printf("XML Bağlantısı Başarılı...");
SetConsoleTextColors(CONSOLE_DEFAULT);
return 1;
}
}
public XMLExit()
{
xml_close(LangXML);
}
Re: [REL] XML loader - Zeex - 23.09.2010
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!
Re: [REL] XML loader -
Romanius - 24.09.2010
Zeex nice! But where examples for new version?
I cant use write functions without examples
Re: [REL] XML loader -
playbox12 - 11.10.2010
Thats actually amazing, nice work
Re: [REL] XML loader -
Romanius - 24.10.2010
Maybe create function to parse xml files from sites (like RSS) ? I can help you with this
Re: [REL] XML loader -
Tronix - 06.11.2010
XML is better than the files, if yes, why? Is faster, or what? I ask because i do not know XML.
Re: [REL] XML loader -
Remis - 07.11.2010
Quote:
Originally Posted by Tronix
XML is better than the files, if yes, why? Is faster, or what? I ask because i do not know XML.
|
Hi,
XML is a format. And XML files are also files. So you can't say that it is faster than anything.
It depends on the implantation whether something is faster or slower. This implantation should be at least as fast as pawn based INI and XML parsers or even faster. But it COULD be slower than ungeneric, undynamic, specialized file loading and saving code in pawn.
An INI file contains sections, comments and keys containing values:
[player1]
money=100
A XML file contains nested elements:
<root>
<player1>
<money>100</money>
</player1>
</root>
It is up to you which format you think is better to use.
Re: [REL] XML loader -
Tronix - 07.11.2010
So in total, it is the same. To read from a file specific key, we need a loop to check a file line by line. The XML is probably just a normal read / write to file. However, the design file is different. Well I'm saying?
I am pole, sorry for my english :P.
Re: [REL] XML loader -
rs.pect - 20.11.2010
This plugin isn't good for MTA loading. I've got a MTA map with about 5,000 objects and loading with this plugin took 53 seconds. File (fopen, fread) algorithm did this in about 1 second.
Re: [REL] XML loader -
Typhome - 20.11.2010
Nice plugin!