Hi all, this is a simple spell system, it gets the info from spells.xml this is how it looks:
go to config.php
after this:
put this:
now go to engine/function/general.php
after this:
put this:
now create a new php file called spells.php and paste this:
and you are done
remember, you need set the location of your data folder at $data
Regards
go to config.php
after this:
PHP:
$config['vocations'] = array(
0 => 'No vocation',
1 => 'Sorcerer',
2 => 'Druid',
3 => 'Paladin',
4 => 'Knight',
5 => 'Master Sorcerer',
6 => 'Elder Druid',
7 => 'Royal Paladin',
8 => 'Elite Knight',
);
put this:
PHP:
$config['voc_str'] = array(
'5' => 'Master Sorcerers',
'6' => 'Elder Druids',
'7' => 'Royal Paladins',
'8' => 'Elite Knights',
'1;5' => 'Sorcerers',
'2;6' => 'Druids',
'3;7' => 'Paladins',
'4;8' => 'Knights',
);
now go to engine/function/general.php
after this:
PHP:
function vocation_id_to_name($id) {
$vocations = config('vocations');
return ($vocations[$id] >= 0 ) ? $vocations[$id] :false ;
}
put this:
PHP:
function voc_str($id)
{
$vocs = config('voc_str');
$id = strVal($id);
return ($vocs[$id] >= 0 ) ? $vocs[$id] :false ;
}
function array_concat($array, $val)
{
$ret = "";
$size = count($array) - 1;
for ($i = 0; $i <= $size; $i++)
{
$ret .= voc_str($array[$i]).''.($i < $size ? $val : '.');
}
return $ret;
}
now create a new php file called spells.php and paste this:
PHP:
<?php require_once 'engine/init.php'; include 'layout/overall/header.php'; ?>
<?php
echo '<h1>Instant Spells</h1> ';
$path = 'D:\Ocio & Programación\Server Tibia\SRCS\SERV\SRCS'; //HERE YOU MUST SET WHERE IS LOCATED YOUR DATA FOLDER
if (is_dir($path)) {
$xml1 = simplexml_load_file($path."\data\spells\spells.xml");
echo '<TABLE BORDER> <TR class="yellow"> <TD >Name</TD> <TD>Words</TD> <TD>Level</TD> <TD>Mana</TD> <TD>Soul</TD> <TD>Requires Premium?</TD> <TD>Vocations</TD></TR> ';
foreach($xml1->instant as $spell)
{
$soul = ($spell['soul'] ? $spell['soul'] : 0);
$vocs = array();
if($spell->vocation)
{ foreach($spell->vocation as $voc)
{
array_push($vocs, $voc['id']);
}
$vocs = array_concat($vocs, ', ');
}
else
$vocs = "All";
$prem = ($spell['prem'] == 1) ? "<font color=green><strong>YES</strong></font>" : "<font color=red><strong>NO</strong></font>";
echo '<TR class="special"> <TD>'.$spell['name'].'</TD> <TD>'.$spell['words'].'</TD> <TD>'.$spell['lvl'].'<TD>'.$spell['mana'].'</TD> <TD> '.$soul.'</TD> <TD>'.$prem.' </TD> <TD>'.$vocs.'</TR></TR>';
}
echo'</TABLE>';
echo'<h1>Conjure Spells</h1> ';
echo '<TABLE BORDER> <TR class="yellow"> <TD >Name</TD> <TD>Words</TD> <TD>Level</TD> <TD>Mana</TD> <TD>Soul</TD> <TD>Requires Premium?</TD> <TD>Vocations</TD></TR> ';
foreach($xml1->conjure as $spell)
{
$soul = ($spell['soul'] ? $spell['soul'] : 0);
$vocs = array();
if($spell->vocation)
{ foreach($spell->vocation as $voc)
{
array_push($vocs, $voc['id']);
}
$vocs = array_concat($vocs, ', ');
}
else
$vocs = "All";
$prem = ($spell['prem'] == 1) ? "<font color=green><strong>YES</strong></font>" : "<font color=red><strong>NO</strong></font>";
echo '<TR class="special"> <TD>'.$spell['name'].'</TD> <TD>'.$spell['words'].'</TD> <TD>'.$spell['lvl'].'<TD>'.$spell['mana'].'</TD> <TD> '.$soul.'</TD> <TD>'.$prem.' </TD> <TD>'.$vocs.'</TR> </TR>';
}
echo'</TABLE>';
}
else
{
echo '<br><b>Invalid path!</b>';
}
?>
<?php include 'layout/overall/footer.php'; ?>
remember, you need set the location of your data folder at $data
Regards