• 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!

XML Spell reader (8.1/8.2)

njitram

New Member
Joined
May 15, 2008
Messages
14
Reaction score
0
xmlspellreaderiw7.png


XML.php (name it what ever you like)
PHP:
<?php
	$file 			= "C:\ot\data\spells\spells.xml"; //This shows the place where PHP must read from
	$lastinstant 	= "Undead Legion"; //End of the last instand spell
	$lastconjur 	= "Thunderstorm"; //End of the last conjure spell
	$lastrne 		= "Drunkness"; //End of the last rune
		
	$title			= "XML Spells";
?>
<html> 
<head> 
<style type="text/css">
<!--
.sorc {
	background-color: #FF9900;
	font-weight: bold;
}
.msorc {
	background-color: #FF3300;
	font-weight: bold;
}
.druid {
	background-color: #0099FF;
	font-weight: bold;
}
.edruid {
	background-color: #0066FF;
	font-weight: bold;
}
.pally {
	background-color: #666600;
	font-weight: bold;
}
.epally {
	background-color: #663300;
	font-weight: bold;
}
.knight {
	background-color: #CCCCCC;
	font-weight: bold;
}
.eknight {
	background-color: #999999;
	font-weight: bold;
}
body,td,th {
	font-family: Verdana, Arial, Helvetica, sans-serif;
	font-size: 12px;
	color: #FFFFFF;
}
body {
	background-color: #000000;
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
}
.border {
	border: 1px solid #FFFFFF;
}
.all {
	background-color: #006600;
	font-weight: bold;
}
-->
</style>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><title><?php echo $title; ?></title></head> 
<body>
<br>
  <h1>Spells</h1>
<?php 	
	$searched = "\"";
	$searchname = "name\"";
	$searchwords = "words=\"";
	$searchlvl = "lvl=\"";
	$searchmlvl = "maglv=\"";
	$searchmanapercent = "manapercent=\"";
	$searchmana = "mana=\"";
	$searchvoc = "<vocation name=\"";
	$searchcount = "conjureCount=\"";
	$searchend = "</instant>";

function VoCshorter($var){
	if($var == "Sorcerer"){
		return "<span class=\"sorc\">Sorc</span>";
	} elseif($var == "Master Sorcerer"){
		return "<span class=\"msorc\">Ma. Sorc</span>";
	} elseif($var == "Paladin"){
		return "<span class=\"pally\">Pally</span>";
	} elseif($var == "Royal Paladin"){
		return "<span class=\"epally\">Ro. Pally</span>";
	} elseif($var == "Druid"){
		return "<span class=\"druid\">Druid</span>";
	} elseif($var == "Elder Druid"){
		return "<span class=\"edruid\">El. Druid</span>";
	} elseif($var == "Knight"){
		return "<span class=\"knight\">Knight</span>";
	} elseif($var == "Elite Knight"){
		return "<span class=\"eknight\">El. Knight</span>";
	} else {
	    return "$var";
	}
}
	$f = @fopen($file, "r"); 
	
if(!$f){ 
	print("<font color=\"red\"><b>Sorry, but we have encountered an error.<b></font><br><br>\n\n"); 
} else {
	$contents = fread($f, filesize($file)); 
	$temp = explode("<instant", $contents);
	print("<b>Instant Spells: </b><br>");
	$i = 1;
	print("<table border=0 cellspacing=0 cellpadding=2 bgcolor=#282828 class=border>");
	print("<tr height=15 bgcolor='#333333'><td width=160><b>Name</b></td>");
	print("<td width=160><b>Words</b></td>");
	print("<td align=center width=80><b>Level</b></td>");
	print("<td align=center width=80><b>Mana</b></td>");
	print("<td align=center width=452><b>Vocation</b></td></tr>");
	while($temp[$i] && $instantname[$i-1]!=$lastinstant)
	{    
		$temp2 = explode($searchname, $temp[$i]);
		$temp3 = explode($searched, $temp2[0]);
		$instantname[$i] = $temp3[1];
		$temp2 = explode($searchwords, $temp[$i]);
		$temp3 = explode($searched, $temp2[1]);
		$instantwords[$i] = $temp3[0];
		$temp2 = explode($searchlvl, $temp[$i]);
		$temp3 = explode($searched, $temp2[1]);
		$instantlvl[$i] = $temp3[0];
		$temp2 = explode($searchmana, $temp[$i]);
		$temp3 = explode($searched, $temp2[1]);
		$instantmana[$i] = $temp3[0];
		
		if($instantname[$i]!="Summon Creature"){
		
			print("<tr height=20><td>$instantname[$i]</td>");
			print("<td>$instantwords[$i]</td>");
			if($instantlvl[$i] == ''){
			   print("<td align=center>0</td>");
			} else {
			   print("<td align=center>$instantlvl[$i]</td>");
			}
				if($instantmana[$i]>0){
					print("<td align=center>$instantmana[$i]</td>");
				} else {
					$temp2 = explode($searchmanapercent, $temp[$i]);
					$temp3 = explode($searched, $temp2[1]);
					$instantmanapercent[$i] = $temp3[0];
					
					if($instantmanapercent[$i] > 0){
						print("<td align=center>$instantmanapercent[$i]%</td>");
					} else {
						print("<td align=center>No mana</td>");		
					}
				}
    	} else {
			print("<tr><td>$instantname[$i]</td>");
			print("<td>$instantwords[$i]</td>");
			print("<td align=center>$instantlvl[$i]</td>");
			print("<td align=center>Variable</td>");
        }
	
    $j = 1;
    print("<td>");
							if($instantname[$i]=="House Guest List" || $instantname[$i]=="House Subowner List" || $instantname[$i]=="House Door List" || $instantname[$i]=="House Kick"){
	  							echo "<span class=\"all\">All vocations</span>";
							}
		if($instantname[$i] == $lastinstant){    
			$temp4 = explode($searchend, $temp[$i]);
			$temp5 = explode("<vocation name=\"", $temp4[0]);
			while($temp5[$j]){
				$temp6 = explode($searched, $temp5[$j]);     
					if($temp5[$j+1]){
						$vars = VoCshorter($temp6[0]);
						print("$vars, ");   
					} else {    
						$vars = VoCshorter($temp6[0]);
						print("$vars ");
					}
				$j++;
			}
	
		} else {    
			$temp3 = explode("<vocation name=\"", $temp[$i]);
			while($temp3[$j]){
				$temp4 = explode($searched, $temp3[$j]);
				$tempora = $temp3[1];
					if($temp3[$j+1]){    
						$vars = VoCshorter($temp4[0]);
						print("$vars, ");   
					} else {
						$vars = VoCshorter($temp4[0]);
						print("$vars ");
					}
				$j++;
			}
		}
    print("</td></tr>");
        
    $i++;
    
}

print("</table>");
$temp = explode("<conjure", $contents);
print("<br><br><b>Conjure Spells: </b><br>");
$i = 1;
print("<table border=0 cellspacing=0 cellpadding=2 bgcolor=#282828 class=border>");
print("<tr height=15 bgcolor='#333333'><td width=160><b>Name</b></td>");
print("<td width=160><b>Words</b></td>");
print("<td align=center width=80><b>MLevel</b></td>");
print("<td align=center width=80><b>Mana</b></td>");
print("<td align=center width=120><b>Charges</b></td>");
print("<td width=328><b>Vocation</b></td></tr>");

	while($temp[$i] && $runename[$i-1]!=$lastconjur){    
		$temp2 = explode($searchname, $temp[$i]);
		$temp3 = explode($searched, $temp2[0]);
		$runename[$i] = $temp3[1];
		$temp2 = explode($searchwords, $temp[$i]);
		$temp3 = explode($searched, $temp2[1]);
		$runewords[$i] = $temp3[0];
		$temp2 = explode($searchlvl, $temp[$i]);
		$temp3 = explode($searched, $temp2[1]);
		$runelvl[$i] = $temp3[0];
		$temp2 = explode($searchmana, $temp[$i]);
		$temp3 = explode($searched, $temp2[1]);
		$runemana[$i] = $temp3[0];
		$temp2 = explode($searchcount, $temp[$i]);
		$temp3 = explode($searched, $temp2[1]);
		$runecount[$i] = $temp3[0];
		print("<tr height=20><td>$runename[$i]</td>"); 
		print("<td>$runewords[$i]</td>");
		$getname = $runename[$i];
		
		print("<td align=center>$runelvl[$i]</td>");
			if($runemana[$i]>0){            
				print("<td align=center>$runemana[$i]</td>");        
			} else {
				print("<td align=center>lol no mana needed? (BUG)</td>");     
			}
			
		$j = 1;
				if($runecount[$i] > 0){
					print("<td align=center>$runecount[$i]</td>");
				} else {
					print("<td align=center>No charges</td>");		
				}
		print("<td>");
		if($runename[$i] == $lastconjur){    
			$temp4 = explode($searchend, $temp[$i]);
			$temp5 = explode("<vocation name=\"", $temp4[0]);
			$mine = "";
			while($temp5[$j]){
				$temp6 = explode($searched, $temp5[$j]);            
				if($temp5[$j+1]){
					$vars = VoCshorter($temp6[0]);
					print("$vars, ");    
				} else {    
					$vars = VoCshorter($temp6[0]);
					print("$vars ");
				}
				$j++;
			}
	
		} else {    
			$temp3 = explode("<vocation name=\"", $temp[$i]);
			while($temp3[$j]){
				$temp4 = explode($searched, $temp3[$j]);
				if($temp3[$j+1]){    
					$vars = VoCshorter($temp4[0]);
					print("$vars, ");
				} else {
					$vars = VoCshorter($temp4[0]);
					print("$vars ");
				}
				$j++;
			}
		}
		print("</td></tr>\n");
			
		$i++;
		
	}
	
print("</table>");
$temp = explode("<rune", $contents);
print("<br><br><b>Runes: </b><br>");
$i = 1;
print("<table border=0 cellspacing=0 cellpadding=2 bgcolor=#282828 class=border>");
print("<tr height=15 bgcolor='#333333'><td width=200><b>Name</b></td>");
print("<td align=left width=90><b>MLevel</b></td>");
print("<td align=left width=650><b>Level</b></td>");

	while($temp[$i] && $runename[$i-1]!=$lastrne){    
		$temp2 = explode($searchname, $temp[$i]);
		$temp3 = explode($searched, $temp2[0]);
		$runename[$i] = $temp3[1];
		$temp2 = explode($searchlvl, $temp[$i]);
		$temp3 = explode($searched, $temp2[1]);
		$runelvl[$i] = $temp3[0];
		$temp2 = explode($searchmlvl, $temp[$i]);
		$temp3 = explode($searched, $temp2[1]);
		$runemlvl[$i] = $temp3[0];
		print("<tr height=20><td>$runename[$i]</td>"); 
		if($runemlvl[$i] == ''){
			print("<td align=left><span class=\"msorc\">??</span></td>");
		} else {
			print("<td align=left>$runemlvl[$i]</td>");
		}
		if($runelvl[$i] == ''){
			print("<td align=left><span class=\"msorc\">??</span></td>");
		} else {
			print("<td align=left>$runelvl[$i]</td>\n");
		}
		print("</tr>");
		$i++;
	}
}
print("</table>");
?> 
</body> 
</html>

Edit what ever you want therefore we are a community!
Only thing you have to edit is:
PHP:
$file 			= "C:\ot\data\spells\spells.xml"; //This shows the place where PHP must read from
	$lastinstant 	= "Undead Legion"; //End of the last instand spell
	$lastconjur 	= "Thunderstorm"; //End of the last conjure spell
	$lastrne 		= "Drunkness"; //End of the last rune

Goodluck!

P.s this might be handy: (only if you want to popup the window)
PHP:
<a href="#" onclick="window.open('./xml.php','RoXoR Spells',
'width=980,height=700,scrollbars=yes,toolbar=no,location=no'); return false"><font color="white">- Spells</font></a>
 
Last edited:
Much easier to make it with POT :)
http://otserv-aac.info/POT/OTS_SpellsList.html
How to use:
PHP:
<?PHP
include('pot/OTS.php');
$ots = POT::getInstance();
$allspells = new OTS_SpellsList("C:/TFS/data/spells/spells.xml");
$conjurelist = $allspells->getConjuresList();
foreach($conjurelist as $spellname)
{
	$spell = $allspells->getConjure($spellname);
	// you can get many informations about every spell
	$lvl = $spell->getLevel();
	$mlvl = $spell->getMagicLevel();
	$mana = $spell->getMana();
	$name = $spell->getName();
	$soul = $spell->getSoul();
	$spell_txt = $spell->getWords();
	$vocations = $spell->getVocations();
	$number_of_vocations = count($vocations);
	foreach($vocations as $vocation_to_add_name)
		$vocations_string .= $vocations_ids[$vocation_to_add_name].", ";
}
$instantlist = $allspells->getInstantsList();
foreach($instantlist as $spellname)
{
	$spell = $allspells->getInstant($spellname);
	// you can get many informations about every spell
	$lvl = $spell->getLevel();
	$mlvl = $spell->getMagicLevel();
	$mana = $spell->getMana();
	$name = $spell->getName();
	$soul = $spell->getSoul();
	$spell_txt = $spell->getWords();
	$vocations = $spell->getVocations();
	$number_of_vocations = count($vocations);
	foreach($vocations as $vocation_to_add_name)
		$vocations_string .= $vocations_ids[$vocation_to_add_name].", ";
}
?>
Of course it doesn't generate any data. Only show how to get informations about spells with POT.
 
Back
Top