Файл: lib/func.php
Строк: 127
<?php
$my_patt=my_patt();
$my_matt=my_matt();
$my_pdef=my_pdef();
$my_mdef=my_mdef();
function win_exp($win_exp){
global $uid;
$user=mysql_fetch_assoc(mysql_query("SELECT * FROM `l2_user` WHERE `id`='$uid'"));
if($user['vp']>='201'){
$wexp=$win_exp*3;
}
if($user['vp']>='101' and $user['vp']<='200'){
$wexp=$win_exp*2;
}
if($user['vp']<='100'){
$wexp=$win_exp;
}
return $wexp;
}
function win_sp($win_sp){
global $uid;
$user=mysql_fetch_assoc(mysql_query("SELECT * FROM `l2_user` WHERE `id`='$uid'"));
if($user['vp']>='201'){
$wsp=$win_sp*3;
}
if($user['vp']>='101' and $user['vp']<='200'){
$wsp=$win_sp*2;
}
if($user['vp']<='100'){
$wsp=$win_sp;
}
return $wsp;
}
function win_aden($win_aden){
global $uid;
$user=mysql_fetch_assoc(mysql_query("SELECT * FROM `l2_user` WHERE `id`='$uid'"));
$shans=mt_rand(0,100) === 1;
if($shans <= $user['shans_drop_aden']){
return $win_aden;
}
}
function cena($price){
global $cena;
if($price<='9999'){$cena="<font color='silver'>".number_format($price)."</font>";}
if($price>='10000' and $price<='99999'){$cena="<font color='#00FFFF'>".number_format($price)."</font>";}
if($price>='100000' and $price<='999999'){$cena="<font color='#FF66FF'>".number_format($price)."</font>";}
if($price>='1000000' and $price<='9999999'){$cena="<font color='#FFFF00'>".number_format($price)."</font>";}
if($price>='10000000' and $price<='99999999'){$cena="<font color='#66FF33'>".number_format($price)."</font>";}
if($price>='100000000'){$cena="<font color='#FFA200'>".number_format($price)."</font>";}
return $cena;
}
function my_mdef(){
global $uid;
$user=mysql_fetch_assoc(mysql_query("SELECT * FROM `l2_user` WHERE `id`='$uid'"));
$ml = ($user['mdef']/100)*$user['men'];
$pr=($user['mdef']/100)*5;
$def1 = round($user['mdef']+$ml+$pr);
$def = mt_rand($user['mdef'], $def1);
return $def;
}
function my_pdef(){
global $uid;
$user=mysql_fetch_assoc(mysql_query("SELECT * FROM `l2_user` WHERE `id`='$uid'"));
$ml=($user['pdef']/100)*5;
$def1 = round($user['pdef']+$ml);
$def = mt_rand($user['pdef'], $def1);
return $def;
}
function my_matt(){
global $uid;
$user=mysql_fetch_assoc(mysql_query("SELECT * FROM `l2_user` WHERE `id`='$uid'"));
$ml = ($user['matt']/100)*$user['int'];
$pr = ($user['matt']/100)*5;
$uron1 = round($user['matt']+$ml+$pr);
$uron = mt_rand($user['matt'], $uron1);
return $uron;
}
function my_patt(){
global $uid;
$user=mysql_fetch_assoc(mysql_query("SELECT * FROM `l2_user` WHERE `id`='$uid'"));
$ml = ($user['patt']/100)*$user['str'];
$pr = ($user['patt']/100)*5;
$uron1 = round($user['patt']+$ml+$pr);
$uron = mt_rand($user['patt'],$uron1);
return $uron;
}
function numb($data) {
return (int)mysql_real_escape_string(htmlspecialchars(strip_tags($data)));
}
$q = mysql_query("SELECT * FROM `l2_all_mobs` WHERE `hp`<='0'");
While($w = mysql_fetch_assoc($q)){
if($w['time']<=time() and $w['hp']<='0' and $w['user']<'1'){
mysql_query("UPDATE `l2_all_mobs` SET `hp`='$w[hpall]',`time`='0',`user`='0' WHERE `id`='$w[id]'");
}
if($w['last']<=time() and $w['user']!=='0'){
mysql_query("UPDATE `l2_all_mobs` SET `hp`=`hpall`,`user`='0' WHERE `id`='$w[id]'");
}
}
function time_left($tl){
$d=3600*24;
$day=floor($tl/$d);
$tl=$tl-($d*$day);
$hour=floor($tl/3600);
$tl=$tl-(3600*$hour);
$minute=floor($tl/60);
$tl=$tl-(60*$minute);
$second=floor($tl);
$dayt="".($day>0?"$day д. ":null)."";
$hourt="".($hour>0?"$hour ч. ":null)."";
$minutet="".($minute>0?"$minute м. ":null)."";
$secondt="".($second>0?"$second с. ":null)."";
if($day>0){
$minutet=NULL;
$secondt=NULL;
}
if($hour>0 && $day==0){
$secondt=NULL;
$dayt=NULL;
}
return "$dayt$hourt$minutet$secondt";
}