• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

[Request/Help] Equipment shower with item info

I'm not noob :) Every(almost) single script I have found on otland or otfans I have learned from and edited myself to fit my needs. So I'm not noob =)

I didn't call u noob, i mean all ppl over otl ;d
 
ok, but can you support us a bit Chojrak?:D
some small hint how to make it not parse xml every time maybe?
pliiiiiiiiiiiiis
 
ok, but can you support us a bit Chojrak?:D
some small hint how to make it not parse xml every time maybe?
pliiiiiiiiiiiiis

I did parser that creates big php array with items, output looks like:
Code:
$items = array(
	100 => array("name" => "void")
);

Then $item = $items[$top["itemtype"]]; and for example: $item["armor"] in characters.php :p
 
some attributes allows more than one tag in xml, what makes script even harder :D

and now I got stuck on debian with 9gb hdd without access to my win hdd so I'll have small break probably
 
yay, almost done items.xml rewriter to make file containing only items with weight :D

well, almost is bad word because making full array with attribute names will take some time but base is ready
and shower base is also ready so... :D
actually I'll release simple version with name, description, weight and nothing more.
Everyone will have to add things he/she want to have.

when using all attributes from this list file is smaller than 300kb, but its still quite big for parsing every time so some hint how to store it in memory since first parsing will be awesome
 
Last edited:
yay, almost done items.xml rewriter to make file containing only items with weight :D

well, almost is bad word because making full array with attribute names will take some time but base is ready
and shower base is also ready so... :D
actually I'll release simple version with name, description, weight and nothing more.
Everyone will have to add things he/she want to have.

when using all attributes from this list file is smaller than 300kb, but its still quite big for parsing every time so some hint how to store it in memory since first parsing will be awesome

how should be the format of the output file (array) ?


lua example for rewriter
Lua:
local att = {"weight", "description", "name"}

function onSay(cid, words, param, channel)
    local file, txt = "data/items/items.xml", ""
    local open = io.open(file, "r")
    if open then
        for line in io.lines(file) do
            if (line:find("attribute") or line:find("item id")) then
                for _, i in ipairs(att) do
                    if (line:find(i)) then
                        txt = txt .. line
                    end
                end
            end
            open:close()
        end
        local newFile = io.open("data/itanzplx.xml", "w")
        if newFile then
            newFile:write(txt)
            newFile:close()
        end
    end
    return true
end

if you give me some extra info i could help to auto rewrite a new file (php / xml / txt dont really care)
 
Last edited:
I made php rewriter from xml to xml making only items with weight and writing only attributes from array, and then rewriten it to rewriter making phparray(need small manual fixing cause I cannot fwrite "$something somethingelse", it writes only "somethingelse" in file)
gonna check today if this way script will work noticable faster
 
I made php rewriter from xml to xml making only items with weight and writing only attributes from array, and then rewriten it to rewriter making phparray(need small manual fixing cause I cannot fwrite "$something somethingelse", it writes only "somethingelse" in file)
gonna check today if this way script will work noticable faster

Ehm, no offense, but people like u shouldn't develop such things like public AAC. ;p
 
well, I add things that are 100% working in most cases so my php knowlege doesnt matter so much I think,
about table rewritten to php array: yeah, working like 10x faster, but still ~2seconds on my pc so its too slow
damn it, executing 10 queries will be way faster, gonna try making working items table in db(with all attributes ofc)
ehh, I give up for now, I cannot write down a query correctly(too much apostrophes and other strange short-line symbols)
 
Last edited:
PHP:
<?php
	$file = file_get_contents('http://svn.otland.net/public/viewvc.cgi/forgottenserver/tags/0.3.6pl1/data/items/items.xml?revision=80&view=co');
	$xml = new DOMDocument();
	$xml->loadXML($file);
	$attrs = array(
		'type',
		'name',
		'plural',
		'description',
		'runespellname',
		'weight',
		'showcount',
		'armor',
		'defense',
		'extradefense', 'extradef',
		'attack',
		'extraattack', 'extraatk',
		'attackspeed',
		'rotateto',
		'moveable', 'movable',
		'blockprojectile',
		'allowpickupable',
		'floorchange',
		'corpsetype',
		'containersize',
		'fluidsource',
		'writeable',
		'readable',
		'maxtextlen',
		'writeonceitemid',
		'worth',
		'forceserialize', 'forceserialization', 'forcesave',
		'leveldoor',
		'weapontype',
		'slottype',
		'ammotype',
		'shoottype',
		'effect',
		'range',
		'stopduration',
		'decayto',
		'transformequipto',
		'transformdeequipto',
		'duration',
		'showduration',
		'charges',
		'showcharges',
		'showattributes',
		'breakchance',
		'ammoaction',
		'hitchance',
		'maxhitchance',
		'preventloss',
		'preventdrop',
		'invisible',
		'speed',
		'healthgain',
		'healthticks',
		'managain',
		'manaticks',
		'manashield',
		'skillsword',
		'skillaxe',
		'skillclub',
		'skilldist',
		'skillfish',
		'skillshield',
		'skillfist',
		'maxhealthpoints', 'maxhitpoints',
		'maxhealthpercent', 'maxhitpointspercent',
		'maxmanapoints',
		'maxmanapercent', 'maxmanapointspercent',
		'soulpoints',
		'soulpercent', 'soulpointspercent',
		'magiclevelpoints', 'magicpoints',
		'magiclevelpercent', 'magicpointspercent',
		'increasemagicvalue',
		'increasemagicpercent',
		'increasehealingvalue',
		'increasehealingpercent',
		'absorbpercentall',
		'absorbpercentelements',
		'absorbpercentmagic',
		'absorbpercentenergy',
		'absorbpercentfire',
		'absorbpercentpoison', 'absorbpercentearth',
		'absorbpercentice',
		'absorbpercentholy',
		'absorbpercentdeath',
		'absorbpercentlifedrain',
		'absorbpercentmanadrain',
		'absorbpercentdrown',
		'absorbpercentphysical',
		'absorbpercenthealing',
		'absorbpercentundefined',
		'reflectpercentall',
		'reflectpercentelements',
		'reflectpercentmagic',
		'reflectpercentenergy',
		'reflectpercentfire',
		'reflectpercentpoison', 'reflectpercentearth',
		'reflectpercentice',
		'reflectpercentholy',
		'reflectpercentdeath',
		'reflectpercentlifedrain',
		'reflectpercentmanadrain',
		'reflectpercentdrown',
		'reflectpercentphysical',
		'reflectpercenthealing',
		'reflectpercentundefined',
		'reflectchanceall',
		'reflectchanceelements',
		'reflectchancemagic',
		'reflectchanceenergy',
		'reflectchancefire',
		'reflectchancepoison', 'reflectchanceearth',
		'reflectchanceice',
		'reflectchanceholy',
		'reflectchancedeath',
		'reflectchancelifedrain',
		'reflectchancemanadrain',
		'reflectchancedrown',
		'reflectchancephysical',
		'reflectchancehealing',
		'reflectchanceundefined',
		'suppressshock', 'suppressenergy',
		'suppressburn', 'suppressfire',
		'suppresspoison', 'suppressearth',
		'suppressfreeze', 'suppressice',
		'suppressdazzle', 'suppressholy',
		'suppresscurse', 'suppressdeath',
		'suppressdrown',
		'suppressphysical',
		'suppresshaste',
		'suppressparalyze',
		'suppressdrunk',
		'suppressregeneration',
		'suppresssoul',
		'suppressoutfit',
		'suppressinvisible',
		'suppressinfight',
		'suppressexhaust',
		'suppressmuted',
		'suppresspacified',
		'suppresslight',
		'suppressattributes',
		'suppressmanashield',
		'elementphysical',
		'elementfire',
		'elementenergy',
		'elementearth',
		'elementice',
		'elementholy',
		'elementdeath',
		'elementlifedrain',
		'elementmanadrain',
		'elementhealing',
		'elementundefined',
		'replaceable', 'replacable',
		'partnerdirection',
		'maletransformto',
		'femaletransformto',
		'transformto'
	);
	$items = array();

	foreach($xml->getElementsByTagName('item') as $item)
	{
		if($item->getAttribute('id'))
		{
			if($item->getAttribute('name'))
				$items[$item->getAttribute('id')]['name'] = $item->getAttribute('name');
				
			if($item->getAttribute('article'))
				$items[$item->getAttribute('id')]['article'] = $item->getAttribute('article');
				
			if($item->getAttribute('plural'))
				$items[$item->getAttribute('id')]['plural'] = $item->getAttribute('plural');
				
			foreach($item->getElementsByTagName('attribute') as $attr)
			{
				foreach($attrs as $attr_)
				{
					if(strtolower($attr->getAttribute('key')) == $attr_)
						$items[$item->getAttribute('id')][$attr_] = $attr->getAttribute('value');
					elseif(strtolower($attr->getAttribute('key')) == 'field')
					{
						$items[$item->getAttribute('id')]['fieldtype'] = $attr->getAttribute('value');
						$fieldAttrs = array('damage', 'ticks', 'count', 'start');
						$dmg = 1;

						foreach($attr->getElementsByTagName('attribute') as $field)
							foreach($fieldAttrs as $fattr)
							{
								if(strtolower($field->getAttribute('key')) == 'start')
									$items[$item->getAttribute('id')]['startingdamage'] = $field->getAttribute('value');
								elseif(strtolower($field->getAttribute('key')) == 'damage')
									if($items[$item->getAttribute('id')]['startingdamage'] > 0)
										$items[$item->getAttribute('id')]['totaldamage'] = $field->getAttribute('value');
									else
									{
										if($dmg == 1)
											$items[$item->getAttribute('id')]['stepindamage'] = $field->getAttribute('value');
										else
											$items[$item->getAttribute('id')]['conditiondamage'] = $field->getAttribute('value');
											
										$dmg = 0;
									}

								elseif(strtolower($field->getAttribute('key')) == $fattr)
									$items[$item->getAttribute('id')][$fattr] = $field->getAttribute('value');
							}
					}
				}
			}
		}
	}
	
	var_dump($items);
?>
 
thats a huge one
gonna check it in npp cause php code winddow is way too small
yeah, attributes list is way better than mine, but needs to delete some of them cause they are useless
its parsing ALL items in file right? hardcore

this one works quite nice, just have way smaller list of attributes and you need to put variable name manually in created phpfile
Code:
<?php 
function loadItems()
{
	$doc = new DOMDocument;
    $items = array();
    $doc->load('c:/xampp/htdocs/items.xml');
    foreach($doc->getElementsByTagName('item') as $item)
    {
        $from = $item->getAttribute('fromid'); $to = $item->getAttribute('toid'); $id = $item->getAttribute('id');
        if($from && $to)
            $id = $from;
        else if(!$id)
            continue;
        $items[$id] = array();
		$items[$id]['id']= $id;
        $items[$id]['article'] = $item->getAttribute('article') or 'a';
        $items[$id]['name'] = $item->getAttribute('name') or 'Unknown';
        $items[$id]['plural'] = $item->getAttribute('plural') or 'Unknowns';
        foreach($item->getElementsByTagName('attribute') as $attr)
            $items[$id][$attr->getAttribute('key')] = $attr->getAttribute('value');
            if($id != $from)
				continue;
			for($i = $from + 1; $i <= $to; $i++)
               $items[$i] = $items[$id];
    }
    return $items;
}
$attributes=array(
'attack', 'extraattack', 'defense', 'extradef', 'extradefense', 'description', 
'range', 'armor', 'speed', 'magiclevelpoints', 'skillSword', 'skillClub', 'skillAxe', 'skillFist', 'skillShield', 'skillDist', 'skillFish',
'weight', 'duration', 'charges', 'absorbPercentAll', 'absorbPercentDeath', 'absorbPercentHoly', 'absorbPercentEarth', 'absorbPercentPoison', 
'absorbPercentEnergy', 'absorbPercentPhysical', 'absorbPercentFire', 'absorbPercentIce', 'absorbPercentManaDrain', 'elementEnergy',
'elementFire', 'elementIce', 'elementEarth', 'containerSize', 'healthTicks', 'healthGain', 'manaTicks', 'manaGain'
);
$it = loadItems();
$myFile = "c:/xampp/htdocs/items.php";
$fh = fopen($myFile, 'w');
fwrite($fh, "<?php\n");
fwrite($fh, "$itemstable=array(\n");
foreach ($it as $item)
{
	if (isset($item['weight']))
	{
		fwrite($fh, "".$item['id']." => array( \"name\" => \"".$item['name']."\"");
		foreach ($attributes as $at)
		{
			if (isset($item[$at]))	fwrite($fh, ", \"".$at."\" => \"".$item[$at]."\"");
		}
	fwrite($fh, "),\n");
	}
}
fwrite($fh, ")");
?>

well, so it creates TONS of USELES data
well, maybe someone want to make all ingame items list but you know
filtering by checking weight is best option I think
 
Last edited:
I would like to know where should I put it, cause I was tryin' to put in on characters.php, but it doesn't work... Anyone can help me with this script?
 
I would like to know where should I put it, cause I was tryin' to put in on characters.php, but it doesn't work... Anyone can help me with this script?

Cuz this script is only parsing XML file.
 
Back
Top