First public release of MyAAC
BIN
tools/signature/fonts/arial.ttf
Normal file
BIN
tools/signature/fonts/arialbd.ttf
Normal file
339
tools/signature/gd.class.php
Normal file
@@ -0,0 +1,339 @@
|
||||
<?PHP
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
/**
|
||||
* @author Christopher Eklund
|
||||
* @copyright MadPHP.org 2009
|
||||
* @version 2.4.5
|
||||
**/
|
||||
class MadGD
|
||||
{
|
||||
public $textConfig = array( 'font' => 2, 'size' => 9, 'color' => 'FFFFFF', 'shadow' => true );
|
||||
public $textBold = array( 'font' => 3, 'size' => 9, 'color' => 'FFFFFF', 'shadow' => true );
|
||||
public $testMode = false;
|
||||
public $background = null;
|
||||
public $extension = null;
|
||||
public $instance = null;
|
||||
|
||||
public $equipment = array(
|
||||
'pos' => array(
|
||||
'x' => 339,
|
||||
'y' => 3
|
||||
),
|
||||
'x' => array( ),
|
||||
'y' => array( )
|
||||
);
|
||||
|
||||
public $x = 0;
|
||||
public $y = 0;
|
||||
public $l = 0;
|
||||
|
||||
|
||||
/**
|
||||
* @access public
|
||||
* @return null
|
||||
**/
|
||||
public function __construct( $path = null )
|
||||
{
|
||||
if ( $path != null )
|
||||
{
|
||||
$this->setBackground( $path );
|
||||
}
|
||||
$this->setEquipments( );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @access public
|
||||
* @return null
|
||||
**/
|
||||
private function setEquipments( )
|
||||
{
|
||||
$equipments = array(
|
||||
'amulet' => array( 1, 15 ),
|
||||
'helmet' => array( 38, 1 ),
|
||||
'backpack' => array( 76, 15 ),
|
||||
'lefthand' => array( 1, 52 ),
|
||||
'armor' => array( 38, 38 ),
|
||||
'righthand' => array( 75, 52 ),
|
||||
'ring' => array( 1, 89 ),
|
||||
'legs' => array( 38, 75 ),
|
||||
'ammunition' => array( 75, 89 ),
|
||||
'boots' => array( 38, 112 )
|
||||
);
|
||||
|
||||
foreach( $equipments as $eq => $positions )
|
||||
{
|
||||
$this->equipment['x'][$eq] = $this->equipment['pos']['x'] + $positions[0];
|
||||
$this->equipment['y'][$eq] = $this->equipment['pos']['y'] + $positions[1];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param string $path
|
||||
* @access public
|
||||
* @return instance
|
||||
**/
|
||||
public function setBackground( $path )
|
||||
{
|
||||
$this->background = $path;
|
||||
$this->extension = strtolower( pathinfo( $path, PATHINFO_EXTENSION ) );
|
||||
|
||||
switch( $this->extension )
|
||||
{
|
||||
case MADGD_PNG:
|
||||
$this->instance = imagecreatefrompng( $this->background );
|
||||
break;
|
||||
|
||||
case MADGD_GIF:
|
||||
$this->instance = imagecreatefromgif( $this->background );
|
||||
break;
|
||||
|
||||
case MADGD_JPG:
|
||||
case MADGD_JPEG:
|
||||
$this->instance = imagecreatefromjpeg( $this->background );
|
||||
break;
|
||||
}
|
||||
return $this->instance;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param string $image
|
||||
* @param integer $x
|
||||
* @param integer $y
|
||||
* @access public
|
||||
* @return null
|
||||
**/
|
||||
public function setEquipmentBackground( $image, $x = false, $y = false )
|
||||
{
|
||||
if ( $x )
|
||||
{
|
||||
$this->equipment['pos']['x'] = $x;
|
||||
}
|
||||
if ( $y )
|
||||
{
|
||||
$this->equipment['pos']['y'] = $y;
|
||||
}
|
||||
|
||||
$this->setEquipments( );
|
||||
return $this->addIcon( $image )->setPosition( $this->equipment['pos']['x'], $this->equipment['pos']['y'] );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param string/int $regular
|
||||
* @param string/int $bold
|
||||
* @param int $size
|
||||
* @param string $color
|
||||
* @param boolean $shadow
|
||||
* @access public
|
||||
* @return null
|
||||
**/
|
||||
public function setDefaultStyle( $regular = 2, $bold = 3, $size = 9, $color = 'FFFFFF', $shadow = true )
|
||||
{
|
||||
$this->textConfig = array( 'font' => $regular, 'size' => $size, 'color' => $color, 'shadow' => $shadow );
|
||||
$this->textBold = array( 'font' => $bold, 'size' => $size, 'color' => $color, 'shadow' => $shadow );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param string $text
|
||||
* @param array $style
|
||||
* @access public
|
||||
* @return instance
|
||||
**/
|
||||
public function addText( $text, $style = array( ) )
|
||||
{
|
||||
foreach( $this->textConfig as $key => $value )
|
||||
{
|
||||
if ( !array_key_exists( $key, $style ) )
|
||||
{
|
||||
$style[$key] = $value;
|
||||
}
|
||||
}
|
||||
return new MadGDText( $this, array( $text, $style ) );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param string $icon
|
||||
* @access public
|
||||
* @return instance
|
||||
**/
|
||||
public function addIcon( $icon, $width = null, $height = null )
|
||||
{
|
||||
return new MadGDIcon( $this, $icon, $width, $height );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param string $hex
|
||||
* @param boolean/int $index
|
||||
* @access public
|
||||
* @return array $hex
|
||||
**/
|
||||
public function HexRGB( $hex, $index = false )
|
||||
{
|
||||
if ( !is_array( $hex ) )
|
||||
{
|
||||
$hex = preg_replace( '/#/', null, $hex );
|
||||
if ( strlen( $hex ) == 6 )
|
||||
{
|
||||
$hex = array(
|
||||
hexdec( substr( $hex, 0, 2 ) ),
|
||||
hexdec( substr( $hex, 2, 2 ) ),
|
||||
hexdec( substr( $hex, 4, 2 ) )
|
||||
);
|
||||
}
|
||||
}
|
||||
return ( in_array( $index, array( 0, 1, 2 ) ) ? $hex[$index] : $hex );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param string $path
|
||||
* @access public
|
||||
* @return null
|
||||
**/
|
||||
public function display( $path = false )
|
||||
{
|
||||
if ( !$this->testMode )
|
||||
{
|
||||
if ( !$path )
|
||||
{
|
||||
header( 'Content-Type: image/png' );
|
||||
imagepng( $this->instance, '', 9 );
|
||||
}
|
||||
else
|
||||
{
|
||||
imagepng( $this->instance, $path, 9 );
|
||||
}
|
||||
imagedestroy( $this->instance );
|
||||
unset( $this );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class MadGDText
|
||||
{
|
||||
private $parent = null;
|
||||
private $text = null;
|
||||
private $style = array( );
|
||||
|
||||
/**
|
||||
* @param instance $parent
|
||||
* @param array $object
|
||||
* @access public
|
||||
* @return null
|
||||
**/
|
||||
public function __construct( $parent, $object )
|
||||
{
|
||||
$this->parent = $parent;
|
||||
$this->text = $object[0];
|
||||
$this->style = $object[1];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param int $x
|
||||
* @param int $y
|
||||
* @access public
|
||||
* @return null
|
||||
**/
|
||||
public function setPosition( $x = MADGD_STACK, $y = 5 )
|
||||
{
|
||||
$textSize = ( !is_int( $this->style['font'] ) ? imagettfbbox( $this->style['size'], 0, $this->style['font'], $this->text ) : null );
|
||||
|
||||
$this->parent->x = ( $x === MADGD_STACK ? $this->parent->x + $this->parent->l + $y : $x );
|
||||
$this->parent->y = ( $x === MADGD_STACK ? $this->parent->y : $y );
|
||||
$this->parent->l = ( is_int( $this->style['font'] ) ? imagefontwidth( $this->style['font'] ) * strlen( $this->text ) : $textSize[2] );
|
||||
|
||||
if ( is_int( $this->style['font'] ) )
|
||||
{
|
||||
if ( $this->style['shadow'] )
|
||||
{
|
||||
imagestring( $this->parent->instance, $this->style['font'], $this->parent->x + 1, $this->parent->y + 1, $this->text, imagecolorallocate( $this->parent->instance, 0, 0, 0 ) );
|
||||
}
|
||||
imagestring( $this->parent->instance, $this->style['font'], $this->parent->x, $this->parent->y, $this->text, imagecolorallocate( $this->parent->instance, $this->parent->HexRGB( $this->style['color'], 0 ), $this->parent->HexRGB( $this->style['color'], 1 ), $this->parent->HexRGB( $this->style['color'], 2 ) ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( $this->style['shadow'] )
|
||||
{
|
||||
imagettftext( $this->parent->instance, $this->style['size'], 0, $this->parent->x + 1, $this->parent->y + 11, imagecolorallocate( $this->parent->instance, 0, 0, 0 ), $this->style['font'], $this->text );
|
||||
}
|
||||
imagettftext( $this->parent->instance, $this->style['size'], 0, $this->parent->x, $this->parent->y + 10, imagecolorallocate( $this->parent->instance, $this->parent->HexRGB( $this->style['color'], 0 ), $this->parent->HexRGB( $this->style['color'], 1 ), $this->parent->HexRGB( $this->style['color'], 2 ) ), $this->style['font'], $this->text );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class MadGDIcon
|
||||
{
|
||||
public $extension = null;
|
||||
public $instance = null;
|
||||
public $parent = null;
|
||||
public $height = null;
|
||||
public $width = null;
|
||||
public $icon = null;
|
||||
|
||||
/**
|
||||
* @param instance $parent
|
||||
* @param string $icon
|
||||
* @param int $width
|
||||
* @param int $height
|
||||
* @access public
|
||||
* @return null
|
||||
**/
|
||||
public function __construct( $parent, $icon, $width, $height )
|
||||
{
|
||||
$this->parent = $parent;
|
||||
$this->height = $height;
|
||||
$this->width = $width;
|
||||
$this->icon = $icon;
|
||||
$this->extension = strtolower( pathinfo( $this->icon, PATHINFO_EXTENSION ) );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param int $x
|
||||
* @param int $y
|
||||
* @access public
|
||||
* @return null
|
||||
**/
|
||||
public function setPosition( $x = MADGD_STACK, $y = 5 )
|
||||
{
|
||||
$this->parent->x = ( $x === MADGD_STACK ? $this->parent->x + $this->parent->l + $y : $x );
|
||||
$this->parent->y = ( $x === MADGD_STACK ? $this->parent->y : $y );
|
||||
|
||||
list( $imageWidth, $imageHeight ) = getimagesize( $this->icon );
|
||||
$this->parent->l = $imageWidth;
|
||||
|
||||
switch( $this->extension )
|
||||
{
|
||||
case MADGD_PNG:
|
||||
$this->instance = imagecreatefrompng( $this->icon );
|
||||
break;
|
||||
|
||||
case MADGD_GIF:
|
||||
$this->instance = imagecreatefromgif( $this->icon );
|
||||
break;
|
||||
|
||||
case MADGD_JPG:
|
||||
case MADGD_JPEG:
|
||||
$this->instance = imagecreatefromjpeg( $this->icon );
|
||||
break;
|
||||
}
|
||||
return imagecopyresampled( $this->parent->instance, $this->instance, $this->parent->x, $this->parent->y, 0, 0, ( $this->width != null ? $this->width : $imageWidth ), ( $this->height != null ? $this->height : $imageHeight ), $imageWidth, $imageHeight );
|
||||
}
|
||||
}
|
||||
|
||||
define( 'MADGD_PNG', 'png' );
|
||||
define( 'MADGD_JPG', 'jpg' );
|
||||
define( 'MADGD_JPEG', 'jpeg' );
|
||||
define( 'MADGD_GIF', 'gif' );
|
||||
define( 'MADGD_STACK', 'stack' );
|
||||
define( 'X_SLOT', 'X_SLOT_' );
|
||||
define( 'Y_SLOT', 'Y_SLOT_' );
|
BIN
tools/signature/images/backgrounds/background.PSD
Normal file
BIN
tools/signature/images/backgrounds/default.png
Normal file
After Width: | Height: | Size: 155 KiB |
BIN
tools/signature/images/bg.png
Normal file
After Width: | Height: | Size: 2.8 KiB |
BIN
tools/signature/images/empty.png
Normal file
After Width: | Height: | Size: 1.6 KiB |
BIN
tools/signature/images/equipments.png
Normal file
After Width: | Height: | Size: 5.7 KiB |
BIN
tools/signature/images/exp.png
Normal file
After Width: | Height: | Size: 2.7 KiB |
BIN
tools/signature/images/health.png
Normal file
After Width: | Height: | Size: 2.7 KiB |
BIN
tools/signature/images/healthfull.png
Normal file
After Width: | Height: | Size: 1.5 KiB |
BIN
tools/signature/images/hpicon.png
Normal file
After Width: | Height: | Size: 585 B |
BIN
tools/signature/images/mana.png
Normal file
After Width: | Height: | Size: 2.7 KiB |
BIN
tools/signature/images/manafull.png
Normal file
After Width: | Height: | Size: 931 B |
BIN
tools/signature/images/manaicon.png
Normal file
After Width: | Height: | Size: 511 B |
BIN
tools/signature/images/nobackground.png
Normal file
After Width: | Height: | Size: 6.4 KiB |
BIN
tools/signature/images/nocharacter.png
Normal file
After Width: | Height: | Size: 7.2 KiB |
BIN
tools/signature/images/nogd.png
Normal file
After Width: | Height: | Size: 5.7 KiB |
BIN
tools/signature/images/noitem.png
Normal file
After Width: | Height: | Size: 2.9 KiB |
BIN
tools/signature/images/stats.png
Normal file
After Width: | Height: | Size: 24 KiB |
15
tools/signature/index.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
require('../../common.php');
|
||||
require(SYSTEM . 'functions.php');
|
||||
require(SYSTEM . 'init.php');
|
||||
|
||||
if(!$config['signature_enabled'])
|
||||
die('Signatures disabled.');
|
||||
|
||||
$file = strtolower($config['signature_type']) . '.php';
|
||||
if(!file_exists($file))
|
||||
die('ERROR: Wrong signature type in config.');
|
||||
|
||||
$cacheMinutes = 5;
|
||||
require($file);
|
||||
?>
|
215
tools/signature/mango.php
Normal file
@@ -0,0 +1,215 @@
|
||||
<?php
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
|
||||
/**
|
||||
ALTER TABLE `players` ADD `madphp_signature` TINYINT( 4 ) NOT NULL DEFAULT '1' COMMENT 'Absolute Mango <20> MadPHP.org', ADD `madphp_signature_bg` VARCHAR( 50 ) NOT NULL COMMENT 'Absolute Mango <20> MadPHP.org' AFTER `madphp_signature`, ADD `madphp_signature_eqs` TINYINT( 4 ) NOT NULL DEFAULT '0' COMMENT 'Absolute Mango <20> MadPHP.org' AFTER `madphp_signature_bg`, ADD `madphp_signature_bars` TINYINT( 4 ) NOT NULL DEFAULT '1' COMMENT 'Absolute Mango <20> MadPHP.org' AFTER `madphp_signature_eqs`, ADD `madphp_signature_cache` INT( 11 ) NOT NULL COMMENT 'Absolute Mango <20> MadPHP.org' AFTER `madphp_signature_bars`;
|
||||
**/
|
||||
|
||||
/** Load the MadGD class **/
|
||||
require( 'gd.class.php' );
|
||||
/** Default values **/
|
||||
list( $i, $eachRow, $percent ) = array( .5, 14, array( 'size' => 7 ) );
|
||||
/** Get experience points for a certain level **/
|
||||
function getExpToLevel( $level )
|
||||
{
|
||||
return ( 50 / 3 ) * pow( $level, 3 ) - ( 100 * pow( $level, 2 ) ) + ( ( 850 / 3 ) * $level ) - 200;
|
||||
}
|
||||
/** Definitions **/
|
||||
define( 'SIGNATURES', 'signatures/' );
|
||||
define( 'SIGNATURES_BACKGROUNDS', 'images/backgrounds/' );
|
||||
define( 'SIGNATURES_CACHE', BASE . 'tmp/signatures/' );
|
||||
define( 'SIGNATURES_DATA', SYSTEM . 'data/' );
|
||||
define( 'SIGNATURES_FONTS', 'fonts/' );
|
||||
define( 'SIGNATURES_IMAGES', 'images/' );
|
||||
define( 'SIGNATURES_ITEMS', BASE . 'images/items/' );
|
||||
|
||||
/** Sprite settings **/
|
||||
$spr_path = SIGNATURES_DATA.'Tibia.spr';
|
||||
$dat_path = SIGNATURES_DATA.'Tibia.dat';
|
||||
$otb_path = SIGNATURES_DATA.'items.otb';
|
||||
|
||||
$name = stripslashes( isset( $_GET['name'] ) ? $_GET['name'] : '-' );
|
||||
$player = $ots->createObject( 'Player' );
|
||||
$player->find( $name );
|
||||
|
||||
if ( function_exists( 'imagecreatefrompng' ) )
|
||||
{
|
||||
if ( $player->isLoaded( ) )
|
||||
{
|
||||
$enabled = $player->getCustomField( 'madphp_signature' );
|
||||
$bars = $player->getCustomField( 'madphp_signature_bars' );
|
||||
$equipments = $player->getCustomField( 'madphp_signature_eqs' );
|
||||
$background = ( $player->getCustomField( 'madphp_signature_bg' ) == '' ? 'default.png' : $player->getCustomField( 'madphp_signature_bg' ) );
|
||||
$file = SIGNATURES_CACHE.$player->getId().'.png';
|
||||
if ( $enabled == 1 )
|
||||
{
|
||||
if ( file_exists( $file ) and ( time( ) < ( filemtime($file) + ( 60 * $cacheMinutes ) ) ) )
|
||||
{
|
||||
header( 'Content-type: image/png' );
|
||||
readfile( SIGNATURES_CACHE.$player->getId().'.png' );
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( file_exists( SIGNATURES_BACKGROUNDS.$background ) )
|
||||
{
|
||||
$MadGD = new MadGD( SIGNATURES_BACKGROUNDS.$background );
|
||||
$MadGD->testMode = false;
|
||||
|
||||
$MadGD->setDefaultStyle( SIGNATURES_FONTS.'arial.ttf', SIGNATURES_FONTS.'arialbd.ttf', 8 );
|
||||
$MadGD->setEquipmentBackground( SIGNATURES_IMAGES.'equipments.png' );
|
||||
|
||||
/** NAME **/
|
||||
$MadGD->addText( 'Name:', $MadGD->textBold )->setPosition( 10, $i * $eachRow );
|
||||
$MadGD->addText( $player->getName(), ( $player->isOnline() ? array( 'color' => '5df82d' ) : array( ) ) )->setPosition( ); $i++;
|
||||
/** SEX **/
|
||||
$MadGD->addText( 'Sex:', $MadGD->textBold )->setPosition( 10, $i * $eachRow );
|
||||
$MadGD->addText( $player->getSex() == 1 ? 'male' : 'female' )->setPosition( ); $i++;
|
||||
/** PROFESSION **/
|
||||
$MadGD->addText( 'Profession:', $MadGD->textBold )->setPosition( 10, $i * $eachRow );
|
||||
$MadGD->addText( $vocation_name[$player->getWorldId()][$player->getPromotion()][$player->getVocation()] )->setPosition( ); $i++;
|
||||
/** LEVEL **/
|
||||
$MadGD->addText( 'Level:', $MadGD->textBold )->setPosition( 10, $i * $eachRow );
|
||||
$MadGD->addText( $player->getLevel() )->setPosition( ); $i++;
|
||||
/** WORLD **/
|
||||
$MadGD->addText( 'World:', $MadGD->textBold )->setPosition( 10, $i * $eachRow );
|
||||
$MadGD->addText( $config['worlds'][$player->getWorldId()] )->setPosition( ); $i++;
|
||||
|
||||
/** RESIDENCE **/
|
||||
$MadGD->addText( 'Residence:', $MadGD->textBold )->setPosition( 10, $i * $eachRow );
|
||||
$MadGD->addText( $towns_list[$player->getWorldId()][$player->getTownId()] )->setPosition( ); $i++;
|
||||
|
||||
/** HOUSE **/
|
||||
$house = $db->query( 'SELECT `houses`.`name`, `houses`.`town` FROM `houses` WHERE `houses`.`world_id` = '.$player->getWorldId().' AND `houses`.`owner` = '.$player->getId().';' )->fetchAll();
|
||||
if ( count( $house ) != 0 )
|
||||
{
|
||||
$MadGD->addText( 'House:', $MadGD->textBold )->setPosition( 10, $i * $eachRow );
|
||||
$MadGD->addText( $house[0]['name'].' ('.$towns_list[$player->getWorldId()][$house[0]['town']].')' )->setPosition( ); $i++;
|
||||
}
|
||||
/** GUILD **/
|
||||
if ( $player->getRank() != null )
|
||||
{
|
||||
$MadGD->addText( 'Guild membership:', $MadGD->textBold )->setPosition( 10, $i * $eachRow );
|
||||
$MadGD->addText( $player->getRank()->getName().' of the '.$player->getRank()->getGuild()->getName() )->setPosition( ); $i++;
|
||||
}
|
||||
/** LAST LOGIN **/
|
||||
$MadGD->addText( 'Last login:', $MadGD->textBold )->setPosition( 10, $i * $eachRow );
|
||||
$MadGD->addText( ( $player->getLastLogin() == 0 ? 'Never logged in' : date( 'M d Y, H:i:s T', $player->getLastLogin() ) ) )->setPosition( ); $i++;
|
||||
/** ACCOUNT STATUS **/
|
||||
$MadGD->addText( 'Account Status:', $MadGD->textBold )->setPosition( 10, $i * $eachRow );
|
||||
$MadGD->addText( ( $player->getAccount()->getPremDays() > 0 ? 'Premium Account' : 'Free Account' ) )->setPosition( ); $i++;
|
||||
|
||||
if ( $bars == 0 )
|
||||
{
|
||||
$MadGD->addIcon( SIGNATURES_IMAGES.'bg.png' )->setPosition( 200, 45 );
|
||||
$MadGD->addIcon( SIGNATURES_IMAGES.'bg.png' )->setPosition( 200, 54 );
|
||||
$MadGD->addIcon( SIGNATURES_IMAGES.'bg.png' )->setPosition( 200, 63 );
|
||||
|
||||
/** HEALTH BAR **/
|
||||
$MadGD->addText( 'HP:', $percent )->setPosition( 182, 40 );
|
||||
if ( ( $player->getHealth() > $player->getHealthMax() ) or ( $player->getHealth() > 0 and $player->getHealthMax() > 0 ) )
|
||||
{
|
||||
$MadGD->addIcon( SIGNATURES_IMAGES.'health.png', $player->getHealth() / $player->getHealthMax() * 100 )->setPosition( 201, 46 );
|
||||
$MadGD->addText( floor( $player->getHealth() / $player->getHealthMax() * 100 ).'%', $percent )->setPosition( 305, 40 );
|
||||
}
|
||||
else
|
||||
{
|
||||
$MadGD->addIcon( SIGNATURES_IMAGES.'health.png', 100 )->setPosition( 201, 46 );
|
||||
$MadGD->addText( '100%', $percent )->setPosition( 305, 40 );
|
||||
}
|
||||
/** MANA BAR **/
|
||||
$MadGD->addText( 'MP:', $percent )->setPosition( 180, 50 );
|
||||
if ( ( $player->getMana() > $player->getManaMax() ) or ( $player->getMana() > 0 and $player->getManaMax() > 0 ) )
|
||||
{
|
||||
$MadGD->addIcon( SIGNATURES_IMAGES.'mana.png', $player->getMana() / $player->getManaMax() * 100 )->setPosition( 201, 55 );
|
||||
$MadGD->addText( floor( $player->getMana() / $player->getManaMax() * 100 ).'%', $percent )->setPosition( 305, 50 );
|
||||
}
|
||||
else
|
||||
{
|
||||
$MadGD->addIcon( SIGNATURES_IMAGES.'mana.png', 100 )->setPosition( 201, 55 );
|
||||
$MadGD->addText( '100%', $percent )->setPosition( 305, 50 );
|
||||
}
|
||||
/** EXPERIENCE BAR **/
|
||||
$MadGD->addText( 'EXP:', $percent )->setPosition( 176, 60 );
|
||||
if ( $player->getExperience() > 0 and ( $player->getExperience() / getExpToLevel( $player->getLevel() + 1 ) * 100 ) <= 100 )
|
||||
{
|
||||
$MadGD->addIcon( SIGNATURES_IMAGES.'exp.png', $player->getExperience() / getExpToLevel( $player->getLevel() + 1 ) * 100 )->setPosition( 201, 64 );
|
||||
$MadGD->addText( floor( $player->getExperience() / getExpToLevel( $player->getLevel() + 1 ) * 100 ).'%', $percent )->setPosition( 305, 60 );
|
||||
}
|
||||
else
|
||||
{
|
||||
$MadGD->addIcon( SIGNATURES_IMAGES.'exp.png', 100 )->setPosition( 201, 64 );
|
||||
$MadGD->addText( '100%', $percent )->setPosition( 305, 60 );
|
||||
}
|
||||
}
|
||||
|
||||
if ( $equipments == 0 )
|
||||
{
|
||||
$slots = array(
|
||||
2 => array( $MadGD->equipment['x']['amulet'], $MadGD->equipment['y']['amulet'] ),
|
||||
1 => array( $MadGD->equipment['x']['helmet'], $MadGD->equipment['y']['helmet'] ),
|
||||
3 => array( $MadGD->equipment['x']['backpack'], $MadGD->equipment['y']['backpack'] ),
|
||||
6 => array( $MadGD->equipment['x']['lefthand'], $MadGD->equipment['y']['lefthand'] ),
|
||||
4 => array( $MadGD->equipment['x']['armor'], $MadGD->equipment['y']['armor'] ),
|
||||
5 => array( $MadGD->equipment['x']['righthand'], $MadGD->equipment['y']['righthand'] ),
|
||||
9 => array( $MadGD->equipment['x']['ring'], $MadGD->equipment['y']['ring'] ),
|
||||
7 => array( $MadGD->equipment['x']['legs'], $MadGD->equipment['y']['legs'] ),
|
||||
10 => array( $MadGD->equipment['x']['ammunition'], $MadGD->equipment['y']['ammunition'] ),
|
||||
8 => array( $MadGD->equipment['x']['boots'], $MadGD->equipment['y']['boots'] )
|
||||
);
|
||||
foreach ( $slots as $pid => $position )
|
||||
{
|
||||
$item = $db->query( 'SELECT `itemtype`, `attributes` FROM `player_items` WHERE `player_items`.`player_id` = '.$player->getId().' AND `player_items`.`pid` = '.$pid.';' )->fetch();
|
||||
if ( $item['itemtype'] != null )
|
||||
{
|
||||
$count = unpack( 'C*', $item['attributes'] );
|
||||
if ( isset( $count[2] ) )
|
||||
{
|
||||
$count = $count[2];
|
||||
}
|
||||
else
|
||||
{
|
||||
$count = 1;
|
||||
}
|
||||
|
||||
$imagePath = BASE . 'images/items/'.( $count > 1 ? $item['itemtype'].'/'.$count : $item['itemtype'] ).'.gif';
|
||||
if ( !file_exists( $imagePath ) )
|
||||
{
|
||||
require(SYSTEM . 'item.php');
|
||||
generateItem($item['itemtype'], $count);
|
||||
}
|
||||
if ( file_exists( $imagePath ) )
|
||||
{
|
||||
$MadGD->addIcon( $imagePath )->setPosition( $position[0], $position[1] );
|
||||
}
|
||||
else
|
||||
{
|
||||
$MadGD->addIcon( SIGNATURES_IMAGES.'noitem.png' )->setPosition( $position[0], $position[1] );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$MadGD->display( SIGNATURES_CACHE.$player->getId().'.png' );
|
||||
|
||||
header( 'Content-type: image/png' );
|
||||
readfile( SIGNATURES_CACHE.$player->getId().'.png' );
|
||||
}
|
||||
else
|
||||
{
|
||||
header( 'Content-type: image/png' );
|
||||
readfile( SIGNATURES_IMAGES.'nobackground.png' );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
header( 'Content-type: image/png' );
|
||||
readfile( SIGNATURES_IMAGES.'nocharacter.png' );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
header( 'Content-type: image/png' );
|
||||
readfile( SIGNATURES_IMAGES.'nogd.png' );
|
||||
}
|
112
tools/signature/tibian.php
Normal file
@@ -0,0 +1,112 @@
|
||||
<?php
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
putenv('GDFONTPATH=' . dirname(__FILE__) . '/fonts');
|
||||
|
||||
$font = "arialbd.ttf";
|
||||
$fontsize = 8;
|
||||
|
||||
$name = stripslashes(ucwords(strtolower(trim($_REQUEST['name']))));
|
||||
if(!check_name($name))
|
||||
return;
|
||||
|
||||
$player = $ots->createObject('Player');
|
||||
$player->find($name);
|
||||
|
||||
if(!$player->isLoaded())
|
||||
return;
|
||||
|
||||
$img = imagecreatefrompng('images/stats.png');
|
||||
$title = imagecolorallocate($img, 160, 160, 160);
|
||||
$text = imagecolorallocate($img, 180, 180, 180);
|
||||
$bar = imagecolorallocate($img, 0, 0, 0);
|
||||
$barfill = imagecolorallocate($img, 200, 0, 0);
|
||||
$hpfill = imagecolorallocate($img, 200, 0, 0);
|
||||
$manafill = imagecolorallocate($img, 0, 0, 200);
|
||||
|
||||
imagettftext($img, $fontsize, 0, 20, 11, $title, $font, $player->getName() . ' - ' . BASE_URL);
|
||||
|
||||
// experience
|
||||
$needexp = OTS_Toolbox::experienceForLevel($player->getLevel() + 1);
|
||||
$experience = $player->getExperience();
|
||||
if($experience > $needexp) $experience = $needexp;
|
||||
imagettftext($img, $fontsize, 0, 15, 30, $text, $font, 'Experience');
|
||||
imagettftext($img, $fontsize, 0, 100, 30, $text, $font, number_format($experience)." (".number_format($needexp).")");
|
||||
|
||||
// level
|
||||
imagettftext($img, $fontsize, 0, 15, 43, $text, $font, 'Level');
|
||||
imagettftext($img, $fontsize, 0, 100, 43, $text, $font, number_format($player->getLevel()));
|
||||
|
||||
// experience bar
|
||||
$exppercent = round($experience / $needexp * 100);
|
||||
imagerectangle($img, 14, 46, 166, 50, $bar);
|
||||
if($exppercent > 0)
|
||||
imagefilledrectangle($img, 15, 47, $exppercent * 1.5 + 15, 49, $barfill);
|
||||
|
||||
imagettftext($img, $fontsize, 0, 170, 51, $text, $font, $exppercent . '%');
|
||||
|
||||
// vocation
|
||||
imagettftext($img, $fontsize, 0, 15, 62, $text, $font, 'Vocation');
|
||||
imagettftext($img, $fontsize, 0, 100, 62, $text, $font, $config['vocations'][$player->getPromotion()][$player->getVocation()]);
|
||||
|
||||
// hit points, Mana, Soul Points, Capacity
|
||||
$health = $player->getHealth();
|
||||
if(health > $player->getHealthMax())
|
||||
$health = $player->getHealthMax();
|
||||
|
||||
$empty = imagecreatefrompng('images/empty.png');
|
||||
//imagerectangle($img, 39, 67, 141, 75, $bar);
|
||||
$fillhp = round($player->getHealth()/$player->getHealthMax() * 100);
|
||||
//imagefilledrectangle($img, 40, 68, 40+$fillhp, 74, $hpfill);
|
||||
$healthicon = imagecreatefrompng('images/hpicon.png');
|
||||
imagecopy($img, $healthicon, 15, 65, 0, 0, 12, 12);
|
||||
$healthfg = imagecreatefrompng('images/healthfull.png');
|
||||
imagecopy($img, $empty, 32, 65, 0, 0, 100, 12);
|
||||
imagecopy($img, $healthfg, 32, 65, 0, 0, $fillhp, 12);
|
||||
//imagettftext($img, $fontsize, 0, 15, 75, $text, $font, "Hit Points");
|
||||
imagettftext($img, $fontsize, 0, 140, 75, $text, $font, $player->getHealth());
|
||||
|
||||
//imagerectangle($img, 39, 80, 141, 88, $bar);
|
||||
$mana = $player->getMana();
|
||||
if(mana > $player->getManaMax())
|
||||
$mana = $player->getManaMax();
|
||||
|
||||
$fillmana = 0;
|
||||
if($player->getMana() > 0 && $player->getManaMax() > 0)
|
||||
$fillmana = round($player->getMana()/$player->getManaMax() * 100);
|
||||
|
||||
//imagefilledrectangle($img, 40, 81, 40+$fillmana, 87, $manafill);
|
||||
$manaicon = imagecreatefrompng('images/manaicon.png');
|
||||
imagecopy($img, $manaicon, 15, 79, 0, 0, 12, 10);
|
||||
$manafg = imagecreatefrompng('images/manafull.png');
|
||||
imagecopy($img, $empty, 32, 78, 0, 0, 100, 12);
|
||||
imagecopy($img, $manafg, 32, 78, 0, 0, $fillmana, 12);
|
||||
//imagettftext($img, $fontsize, 0, 15, 88, $text, $font, "Mana");
|
||||
imagettftext($img, $fontsize, 0, 140, 88, $text, $font, $player->getMana());
|
||||
|
||||
imagettftext($img, $fontsize, 0, 15, 101, $text, $font, 'Soul Points');
|
||||
imagettftext($img, $fontsize, 0, 100, 101, $text, $font, number_format($player->getSoul()));
|
||||
imagettftext($img, $fontsize, 0, 15, 114, $text, $font, 'Capacity');
|
||||
imagettftext($img, $fontsize, 0, 100, 114, $text, $font, number_format($player->getCap()));
|
||||
|
||||
// magic Level
|
||||
imagettftext($img, $fontsize, 0, 15, 127, $text, $font, 'Magic Level');
|
||||
imagettftext($img, $fontsize, 0, 100, 127, $text, $font, number_format($player->getMagLevel()));
|
||||
|
||||
// premium status
|
||||
$account = $player->getAccount();
|
||||
imagettftext($img, $fontsize, 0, 15, 140, $text, $font, $account->getCustomField('premdays') == 0 ? 'Free Account' : 'Premium Account');
|
||||
|
||||
imagefilledrectangle($img, 225, 40, 225, 130, $title); //seperator
|
||||
$posy = 50;
|
||||
foreach(
|
||||
$db->query('SELECT ' . $db->fieldName('skillid') . ', ' . $db->fieldName('value') . ' FROM ' . $db->tableName('player_skills') . ' WHERE ' . $db->fieldName('player_id') . ' = ' . $player->getId() . ' LIMIT 7')
|
||||
as $skill)
|
||||
{
|
||||
imagettftext($img, $fontsize, 0, 235, $posy, $text, $font, getSkillName($skill['skillid']));
|
||||
imagettftext($img, $fontsize, 0, 360, $posy, $text, $font, $skill['value']);
|
||||
$posy = $posy + 13;
|
||||
}
|
||||
|
||||
header('Content-type: image/png');
|
||||
imagepng($img);
|
||||
?>
|