Aqui postarei diversas funções para seu website de OpenTibia e quem sabe Fan Tibia Site.
Grande parte dos códigos postados aqui, você pode encontrar em
TWANão autorizo o post de nenhum script descrito aqui em outros fóruns/sites.
Categorias
[/color] - Códigos de uso apenas para OTServers em XML.
[color="#0000FF"][sql][/color] - Códigos de uso apenas para OTServers em SQL.
[color="#008000"][Geral][/color] - Códigos de uso em sites de OTServers XML ou SQL.
[color="#2F4F4F"][Fan Tibia][/color] - Códigos para fans sites de Tibia.
[b]Funções desenvolvidas por Nostradamus(+) e Arkilus(*)[/b]
[color="#FF0000"][b][xml]Vendo dinheiro total do char(+)[/b][/color]
[code]function CharMoney($player){
$datadir = 'C:/otserv/data/'; // diretorio da pasta data
$gold = '2148'; // id da gold coin
$plat = '2152'; // id da platinum coin
$crys = '2160'; // id da crystal coin
$arquivo = $datadir.'players/'.$player.'.xml';
if(!file_exists($arquivo))
return 0;
else{
$string = file_get_contents($arquivo);
$pattern='/<item id="([0-9]{1,5})"\s[^\r\n<>]*?count="([0-9]{1,3})"/';
preg_match_all($pattern,$string,$out,PREG_PATTERN_ORDER);
$i = 0;
$money = 0;
while (isset($out[1][$i])){
if($out[1][$i] == $gold)
$money += $out[2][$i];
elseif($out[1][$i] == $plat)
$money += $out[2][$i]*100;
elseif($out[1][$i] == $crys)
$money+=$out[2][$i]*10000;
$i++;
}
return $money;
}
}[/code]
Uso:
[b][color=#0000FF]
[code]function CharMoney($player)
{
$moeda1 = 2148; // GP Coin
$moeda2 = 2152; // Platinum Coin
$moeda3 = 2160; // Crystal Coin
$sql = mysql_query("SELECT id FROM players WHERE name = '$player' LIMIT 0, 1");
if (mysql_num_rows($sql) > 0)
{
$row = mysql_fetch_assoc($sql);
$sql = mysql_query("SELECT itemtype, count FROM player_items WHERE player_id = '{$row['id']}' AND itemtype = '$moeda1' OR player_id = '{$row['id']}' AND itemtype = '$moeda2' OR player_id = '{$row['id']}' AND itemtype = '$moeda3'");
if (mysql_num_rows($sql) > 0)
{
$g[$moeda1] = 0;
$g[$moeda2] = 0;
$g[$moeda3] = 0;
while ($row = mysql_fetch_assoc($sql))
{
$g[$row['itemtype']] += $row['count'];
}
return $g[$moeda1] + ($g[$moeda2] * 100) + ($g[$moeda3] * 10000);
} else {
return 0;
}
} else {
return "Jogador não encontrado.";
}
}[/code]
Uso:
[color=#2F4F4F][b][Fan Tibia]Calculando a experiência de um determinado level(+)[/b][/color]
$exp = (50/3) * pow($level,3) - (100 * pow($level,2)) + ((850/3) * $level) - 200;
}[/code]
Uso:
[b][color=#FF0000]
[code]function UltimoChar($dir){
if (is_dir($dir)) {
if ($dh = opendir($dir)) {
while (($file = readdir($dh)) !== false) {
$arquivo = $dir . $file;
$ledata = filemtime($arquivo);
$data = strftime("%y%m%d%H%M", $ledata);
if(is_file($arquivo)){
if($ultimaData < $data){
$ultimaData = $data;
$ultimoDir = $arquivo;
$ultimoArq = $file;
$resultado = substr($ultimoArq, 0, -4);
}
}
}
closedir($dh);
}
echo "<br> Último char registrado: " . $resultado;
}
return $ultimoArq;
}[/code]
Uso:
[color=#008000][b][Geral]Mostrando última screenshot de uma pasta(+)[/color][/b]
function UltimaSS($dir, $largura, $altura){
if (is_dir($dir)) {
if ($dh = opendir($dir)) {
while (($file = readdir($dh)) !== false) {
$arquivo = $dir . $file;
$ledata = filemtime($arquivo);
$data = strftime("%y%m%d%H%M", $ledata);
if(is_file($arquivo)){
if($ultimaData < $data){
$ultimaData = $data;
$ultimoDir = $arquivo;
$ultimoArq = $file;
// $resultado = substr($ultimoArq, 0, -4);
}
}
}
if ($ultimoArq == "Thumbs.db") {
unlink ("ss/Thumbs.db");
}
closedir($dh);
}
echo '<a href="'. $dir . $ultimoArq . '"><img src="' . $dir . $ultimoArq . '" height="' . $altura . '" width="' . $largura . '"></a>';
}
return $ultimoArq;
}
?>[/code]
Uso:
[color=#008000][b][Geral]Lag atual do servidor(+)[/b][/color]
ini_set("max_execution_time",0);
$ping = microtime(true);
$info = chr(6).chr(0).chr(255).chr(255).'info';
$sock = @fsockopen($ip, $port, $errno, $errstr, 1);
if ($sock) {
fwrite($sock, $info);
$data='';
while (!feof($sock)) {
$data .= fgets($sock, 1024);
}
$resultado = microtime(true) - $ping;
fclose($sock);
}
if (isset($resultado)){
echo "Lag: " . $resultado;
}
else {
echo "Server Offline";
}
}[/code]
Uso:
[color=#008000][b][Geral]Criar miniatura de imagem(*)[/b][/color]
list($owdt,$ohgt,$otype)=@getimagesize($file);
switch($otype) {
case 1: $newimg=imagecreatefromgif($file); break;
case 2: $newimg=imagecreatefromjpeg($file); break;
case 3: $newimg=imagecreatefrompng($file); break;
default: return "Unkown filetype (file $file, type $otype)";
}
if($newimg) {
if($owdt>1500 || $ohgt>1200)
list($owdt, $ohgt) = Resample($newimg, $owdt, $ohgt, 1024,768,0);
Resample($newimg, $owdt, $ohgt, $maxwdt, $maxhgt);
if(!$dest) return $newimg;
if(!is_dir(dirname($dest)))
mkdir(dirname($dest));
switch($otype) {
case 1: imagegif($newimg,$dest); break;
case 2: imagejpeg($newimg,$dest,90); break;
case 3: imagepng($newimg,$dest); break;
}
imagedestroy($newimg);
return 1;
}
}
function Resample(&$img, $owdt, $ohgt, $maxwdt, $maxhgt, $quality=1) {
if(!$maxwdt) $divwdt=0;
else $divwdt=Max(1,$owdt/$maxwdt);
if(!$maxhgt) $divhgt=0;
else $divhgt=Max(1,$ohgt/$maxhgt);
if($divwdt>=$divhgt) {
$newwdt=$maxwdt;
$newhgt=round($ohgt/$divwdt);
} else {
$newhgt=$maxhgt;
$newwdt=round($owdt/$divhgt);
}
$tn=imagecreatetruecolor($newwdt,$newhgt);
if($quality)
imagecopyresampled($tn,$img,0,0,0,0,$newwdt,$newhgt,$owdt,$ohgt);
else
imagecopyresized($tn,$img,0,0,0,0,$newwdt,$newhgt,$owdt,$ohgt);
imagedestroy($img);
$img = $tn;
return array($newwdt, $newhgt);
}[/code]
Uso:
[color=#FF0000][b]
[code]function PlayersFile($nick, $account) {
$datadir = "C:/OTServ/data/";
$xmlfile = $datadir. 'players/players.xml';
$arquivo = fopen($xmlfile, 'r+');
fseek($arquivo,-10,SEEK_END);
fwrite($arquivo,
'<player name="' . $nick . '" guid="' . $account . '"/></players>');
fclose($arquivo);
}[/code]
Uso:
[u]OBS:[/u] Para funcionar deve existir pelo menos uma tag já existente no players.xml
[color=#2F4F4F][b][Fan Tibia]Tibia Players Online(+)[/b][/color]
{
$file = "http://www.tibia.com/community/?subtopic=whoisonline&world=$world";
$text = file_get_contents($file) or die("Mundo inexistente.");
preg_match_all('/\&name=[^">]*">([^<]+)</i', $text, $matches);
$count = count($matches[1]);
if($count > 0)
{
echo "$count players online em $world<br><br>";
for ($label = 0; $label < $count; $label++ )
{
echo $matches[1][$label] . "<BR>\n";
}
}
else
{
echo "Mundo não existente.";
}
}[/code]
Uso:
[color=#2F4F4F][b][Fan Tibia]Tibia Char Speed(+)[/b][/color]
$level = 220 + (2 * $level - 2);
echo $level;
}[/code]
Uso:
[color=#008000][b][Geral]Pegando dados do config.lua(+)[/b][/color]
switch($stg) {
case 'ip':
$stg = 'ip';
break;
case 'world':
$stg = 'worldtype';
break;
// Forgotten Serv Config.lua
case 'forgotten_rate_exp':
$stg = 'rateExp';
break;
case 'forgotten_rate_skill':
$stg = 'rateSkill';
break;
case 'forgotten_rate_magic':
$stg = 'rateMagic';
break;
case 'forgotten_rate_loot':
$stg = 'rateLoot';
break;
// Evolution Serv Config.lua
case 'evolutions_rate_exp':
$stg = 'expmul';
break;
case 'evolutions_rate_skill':
$stg = 'skillmul';
break;
case 'evolutions_rate_magic':
$stg = 'magicmul';
break;
case 'evolutions_rate_loot':
$stg = 'lootmul';
break;
}
$otdir = "C:/OTserv"; // OT Dir
$configlua = file_get_contents($otdir."/config.lua");
$dados = stristr($configlua, $stg . ' = ');
$parser = explode('"', $dados);
$config = $parser[1];
echo $config;
}[/code]
Uso:
[size=4][color=#000000][b]Pedidos de scripts[/b][/color][/size]
-Peça agora mesmo um script que desejas e eu tentarei lhe atender!