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

[Modern AAC] Spell list

tosse12

Panchira Project Member
Joined
Jun 10, 2007
Messages
864
Reaction score
9
Location
Sweden
Before you start adding this to your page I must warn you! This isn't a Perfect script!

This script is based of Znote Automatic Donation script.

Anyways, if you want an example before adding this script visit: Panchira - The World of Epics

How to install:
Create a new file in views page folder in modern AAC.
Call it: spells.php

Add this code:
PHP:
<style type="text/css">
td {
    color: white;
    height: 20px;
    color: #666;
}

</style>
<?php 

if(!defined('BASEPATH')) exit('No direct script access allowed'); 

$DIR = '*:/*/*/data/spells/'; 
     
if(is_dir($DIR)) { 
    $spells = simplexml_load_file($DIR.'spells.xml'); 
	$table_color_1 = 'black';
	$table_color_2 = '#080808';
?> 
<h2>Spells </h2>
<table style= border="0px" cellspacing="0px" cellpadding="4px" width="100%">
<tr  bgcolor="#101010 ">
<th style="color: #FF4500">Spell Name</th>
<th style="color: #FF4500">Words</th>
<th style="color: #FF4500">Mana Cost</th>
<th style="color: #FF4500">Level Required</th>
</tr>


<?php
$i = 1;
foreach($spells as $spell) {
$color = ($i % 2 ? $table_color_1 : $table_color_2);
$i++;

    echo '
	<tr bgcolor="'.$color.'" id="spell_list">
		<td style="font-size: 10pt;">'.$spell['name'].'</td>
		<td style="font-size: 10pt;">'.$spell['words'].'</td>
		<td style="font-size: 10pt;">'.$spell['mana'].'</td>
		<td style="font-size: 10pt;">'.$spell['lvl'].'</td>
	</tr>';
}
}
else{alert('Error loading spells. Directory address must be correct.');}
?>
</table>

Edit the DIR path to your server path, Example:
Code:
$DIR = 'C:/coke/tibia/otserv/data/spells/';

Then you should be finnished!

Once again, see the example site before using this code, coz this isn't 100% perfect.
(Php isn't my thing! :D)

You may modify it how every you want it!
 
Update: Removes Spell runes, but not Paralyze.
PHP:
<style type="text/css">
td {
    color: white;
    height: 20px;
    color: #666;
}

</style>
<?php 

if(!defined('BASEPATH')) exit('No direct script access allowed'); 

$DIR = 'C:/tibia/panchira/data/spells/'; 
     
if(is_dir($DIR)) { 
    $spells = simplexml_load_file($DIR.'spells.xml'); 
	$table_color_1 = 'black';
	$table_color_2 = '#080808';
?> 
<h2>Spells</h2>
<table style= border="0px" cellspacing="0px" cellpadding="4px" width="100%">
<tr  bgcolor="#101010 ">
<th style="color: #FF4500">Spell Name</th>
<th style="color: #FF4500">Words</th>
<th style="color: #FF4500">Mana Cost</th>
<th style="color: #FF4500">Level Required</th>
</tr>

<?php
$i = 1;
foreach($spells as $spell) {
$color = ($i % 2 ? $table_color_1 : $table_color_2);
$i++;
	if ($spell['mana'] >= 1) {
    echo '
	<tr bgcolor="'.$color.'" id="spell_list">
		<td style="font-size: 10pt;">'.$spell['name'].'</td>
		<td style="font-size: 10pt;">'.$spell['words'].'</td>
		<td style="font-size: 10pt;">'.$spell['mana'].'</td>
		<td style="font-size: 10pt;">'.$spell['lvl'].'</td>
	</tr>';
	}
}
}
else{alert('Error loading spells. Directory address must be correct.');}
?>
</table>
 
Sorry for the double post (Can't edit in this section... not premium atm<_<

This is an edit, which removes the Paralyze rune effect name from the list (The paralzye spell to create the rune is still remaining!)

PHP:
<style type="text/css">
td {
    color: white;
    height: 20px;
    color: #666;
}

</style>
<?php 

if(!defined('BASEPATH')) exit('No direct script access allowed'); 

$DIR = 'C:/tibia/panchira/data/spells/'; 
     
if(is_dir($DIR)) { 
    $spells = simplexml_load_file($DIR.'spells.xml'); 
	$table_color_1 = 'black';
	$table_color_2 = '#080808';
?> 
<h2>Spells</h2>
<table style= border="0px" cellspacing="0px" cellpadding="4px" width="100%">
<tr  bgcolor="#101010 ">
<th style="color: #FF4500">Spell Name</th>
<th style="color: #FF4500">Words</th>
<th style="color: #FF4500">Mana Cost</th>
<th style="color: #FF4500">Level Required</th>
</tr>

<?php
$i = 1;
foreach($spells as $spell) {
$color = ($i % 2 ? $table_color_1 : $table_color_2);
$i++;
	if ($spell['mana'] >= 1 and $spell['words'] > null) {
    echo '
	<tr bgcolor="'.$color.'" id="spell_list">
		<td style="font-size: 10pt;">'.$spell['name'].'</td>
		<td style="font-size: 10pt;">'.$spell['words'].'</td>
		<td style="font-size: 10pt;">'.$spell['mana'].'</td>
		<td style="font-size: 10pt;">'.$spell['lvl'].'</td>
	</tr>';
	}
}
}
else{alert('Error loading spells. Directory address must be correct.');}
?>
</table>

A question to someone who are quite good in php (Paxton? Stian?), How I can be able to add a sort function to this script? :p I really would like to sort the Spell Name from A-> Z
 
very nice i love it. i made it only display my custom spells by directing it to mods/customspells. kinda basic it doesnt display required vocations but thats alright.
 
Nice, I changed it a little... check it here mtibia - the fenix version!

PHP:
<style type="text/css"> 
td { 
    color: black; 
    height: 20px; 
    color: #666; 
} 

</style> 
<?php  

if(!defined('BASEPATH')) exit('No direct script access allowed');  

$DIR = '/home/serv/data/spells/';  
      
if(is_dir($DIR)) {  
    $spells = simplexml_load_file($DIR.'spells.xml');  
    $table_color_1 = '#FFFFFF'; 
    $table_color_2 = '#C9C9C9'; 
?>  
<h2>Spells </h2> 
<table style= border="0px" cellspacing="0px" cellpadding="4px" width="100%"> 
<tr bgcolor="#C9C9C9"> 
<th style="color: #black">Spell Name</th> 
<th style="color: #black">Words</th> 
<th style="color: #black">Mana Cost</th> 
<th style="color: #black">Level Required</th>
</tr> 


<?php 
$i = 1; 
foreach($spells as $spell) { 
$color = ($i % 2 ? $table_color_1 : $table_color_2); 
$i++; 
if ($spell['mana'] >= 1 and $spell['words'] > null){
    echo ' 
    <tr bgcolor="'.$color.'" id="spell_list"> 
        <td style="font-size: 10pt;"><font color="black"> '.$spell['name'].'</font> </td> 
        <td style="font-size: 10pt;"><font color="black">'.$spell['words'].'</font></td> 
        <td style="font-size: 10pt;"><font color="black">'.$spell['mana'].'</font></td> 
        <td style="font-size: 10pt;"><font color="black">'.$spell['lvl'].'</font></td>
    </tr>'; 
	} 
} 
} 
else{alert('Error loading spells. Directory address must be correct.');} 
?> 
</table>

I would love if someone could fix the vocation part and show which vocations may use the spells and if it is premium or not.
 
Maybe you could improve this:

PHP:
<?PHP
require("config.php");
$ots = POT::getInstance();
$ots->connect(POT::DB_MYSQL, connection());
$SQL = $ots->getDBHandle();

$allowed_order_by = array('name', 'spell', 'spell_type', 'mana', 'lvl', 'mlvl', 'soul');
$vocation_id = $_REQUEST['vocation_id'];
$order = $_REQUEST['order'];
if(in_array($order, $allowed_order_by))
	$orderby = $order;
else
	$orderby = 'name';

$spells = $SQL->query('SELECT * FROM z_spells WHERE hide_spell != 1 ORDER BY '.$orderby.', lvl');
echo  '<FORM ACTION="?subtopic=spells" METHOD=post>
<TABLE BORDER=0 CELLSPACING=1 CELLPADDING=4 WIDTH=100%>
<TR BGCOLOR='.$config['site']['vdarkborder'].'><TD CLASS=white><B>Spell Search</B></TD></TR>
<TR BGCOLOR='.$config['site']['darkborder'].'><TD>Only for vocation: <SELECT NAME="vocation_id">';
echo  '<OPTION VALUE="a:a" ';
if('a:a' == $vocation_id)
	echo  'SELECTED';
echo  '>All';

foreach($vocation_name[0] as $prom => $arr)
	foreach($arr as $voc_id => $voc_name)
	{
		echo  '<OPTION VALUE="'.$prom.';'.$voc_id.'"';
		if($prom.';'.$voc_id == $vocation_id && $vocation_id != "a:a" && $vocation_id != '')
			echo  ' SELECTED';
		echo  '/>'.$voc_name;
	}
echo  '</SELECT><input type="hidden" name="order" value="'.$orderby.'">&nbsp;&nbsp;&nbsp;<INPUT TYPE=image NAME="Submit" ALT="Submit" SRC="'.$layout_name.'/images/buttons/sbutton_submit.gif" BORDER=0 WIDTH=120 HEIGHT=18></TD><TR>
</TABLE></FORM>';

echo  '<TABLE BORDER=0 CELLSPACING=1 CELLPADDING=4 WIDTH=100%><TR BGCOLOR='.$config['site']['vdarkborder'].'><TD CLASS=white><B><a href="?subtopic=spells&vocation_id='.$vocation_id.'&order=name"><font CLASS=white>Name</a></B></TD><TD CLASS=white><B><a href="?subtopic=spells&vocation_id='.$vocation_id.'&order=spell"><font CLASS=white>Sentence</a></B></TD><TD CLASS=white><B><a href="?subtopic=spells&vocation_id='.$vocation_id.'&order=spell_type"><font CLASS=white>Type<br/>(count)</a></B></TD><TD CLASS=white><B><a href="?subtopic=spells&vocation_id='.$vocation_id.'&order=mana"><font CLASS=white>Mana</a></B></TD><TD CLASS=white><B><a href="?subtopic=spells&vocation_id='.$vocation_id.'&order=lvl"><font CLASS=white>Exp.<br/>Level</a></B></TD><TD CLASS=white><B><a href="?subtopic=spells&vocation_id='.$vocation_id.'&order=mlvl"><font CLASS=white>Magic<br/>Level</a></B></TD><TD CLASS=white><B><a href="?subtopic=spells&vocation_id='.$vocation_id.'&order=soul"><font CLASS=white>Soul</a></B></TD><TD CLASS=white><B>PACC</B></TD><TD CLASS=white><B>For<br/>Vocations:</B></TD></TR>';
if($vocation_id != 'a:a' && $vocation_id != '')
{
	foreach($vocation_name[0] as $prom => $arr)
		foreach($arr as $voc_id => $voc_name)
			if($prom.';'.$voc_id == $vocation_id)
				$voc_n = $voc_name;
	foreach($spells as $spell)
	{
		$spell_vocations = explode(",", $spell['vocations']);
		if(in_array($vocation_id, $spell_vocations) || empty($spell['vocations']))
		{
			if(is_int($number_of_rows / 2)) { $bgcolor = $config['site']['lightborder']; } else { $bgcolor = $config['site']['darkborder']; } $number_of_rows++;
			echo  '<TR BGCOLOR="'.$bgcolor.'"><TD>'.$spell['name'].'</TD><TD>'.$spell['spell'].'</TD>';
			if($spell['spell_type'] == 'conjure')
				echo  '<TD>'.$spell['spell_type'].'('.$spell['conj_count'].')</TD>';
			else
				echo  '<TD>'.$spell['spell_type'].'</TD>';
			echo  '<TD>'.$spell['mana'].'</TD><TD>'.$spell['lvl'].'</TD><TD>'.$spell['mlvl'].'</TD><TD>'.$spell['soul'].'</TD><TD>'.$spell['pacc'].'</TD><TD>'.$voc_n.'</TD></TR>';
		}
	}
}
else
{
	foreach($spells as $spell)
	{
		$spell_vocations = explode(",", $spell['vocations']);
		$showed_vocations = 0;
		$vocs = '';
		foreach($spell_vocations as $voc)
		{
			$voc_info = explode(";", $voc);
			if(!empty($vocation_name[0][$voc_info[0]][$voc_info[1]]))
			{
				$vocs .= $vocation_name[0][$voc_info[0]][$voc_info[1]];
				if($showed_vocations != count($spell_vocations))
					$vocs .= '<br/>';
			}
		}
		if(is_int($number_of_rows / 2)) { $bgcolor = $config['site']['lightborder']; } else { $bgcolor = $config['site']['darkborder']; } $number_of_rows++;
		echo  '<TR BGCOLOR="'.$bgcolor.'"><TD>'.$spell['name'].'</TD><TD>'.$spell['spell'].'</TD>';
		if($spell['spell_type'] == 'conjure')
			echo  '<TD>'.$spell['spell_type'].'('.$spell['conj_count'].')</TD>';
		else
			echo  '<TD>'.$spell['spell_type'].'</TD>';
		echo  '<TD>'.$spell['mana'].'</TD><TD>'.$spell['lvl'].'</TD><TD>'.$spell['mlvl'].'</TD><TD>'.$spell['soul'].'</TD><TD>'.$spell['pacc'].'</TD><TD><font size="1">'.$vocs.'</font></TD></TR>';
	}
}

echo  '</TABLE>';
?>
 
@kito2
your last post here with the spell table, dont work. i get error on line 8 and 9. I think i must execute querys in PMA.
 
PHP:
<style type="text/css">  
td {  
    color: white;  
    height: 20px;  
    color: #666;  
}  

</style>  
<?php   

if(!defined('BASEPATH')) exit('No direct script access allowed');   

$DIR = 'C:/trunk.r3884/data/spells/';   
       
if(is_dir($DIR)) {   
    $spells = simplexml_load_file($DIR.'spells.xml');   
    $table_color_1 = '#D4C0A1';  
    $table_color_2 = '#F1E0C6';  
?> 

   
<h2><center>Attack Spells</center></h2>  

<table border="1px" cellspacing="3px" cellpadding="1px" width="100%">  
<tr  bgcolor="#F1E0C6">  
<th style="color: black; text-align: center">Spell Name</th>  
<th style="color: black; text-align: center">Words</th>  
<th style="color:  black; text-align: center">Mana Cost</th>  
<th style="color:  black; text-align: center">Level Required</th>  
<th style="color: black; text-align: center">Premium Required</th>  
</tr>  






<?php  
$i = 0;  
foreach($spells as $spell) {  
$color = ($i % 2 ? $table_color_1 : $table_color_2);  


	if (!$spell['id'])  {
		
		
		$i++;  
		$spell['prem'] = ($spell['prem'] > 0) ? 'YES' : 'NO';
		echo '  
		
		<tr class="highlight" bgcolor="'.$color.'" id="spell_list">  
			<td><center>'.$spell['name'].'</center></td> 
			<td style="font-size: 10pt;"><center>'.$spell['words'].'</center></td>  
			<td style="font-size: 10pt;"><center>'.$spell['mana'].'</center></td>  
			<td style="font-size: 10pt;"><center>'.$spell['lvl'].'</center></td>  
			<td style="font-size: 10pt;"><center> '.$spell['prem'].'  </center></td>  
		</tr>';
	}
	
}  
}  

else{alert('Error loading spells. Directory address must be correct.');}  
echo '</table>'; 
?>

i just added the column Premium, and it won't show the runes
 
Back
Top