[Обсуждение] Создание/Редактирование Ботов

linpc

Гуру форума
Регистрация
6 Апр 2012
Сообщения
178
Реакции
55
PHP:
<HTML>
<HEAD>
<LINK href="../../../css/game.css" rel=STYLESHEET type=text/css>
<script src="../../../js/v1_tooltip.js"></SCRIPT>
<META Http-Equiv=Content-Type Content="text/html; charset=windows-1251">
<META Http-Equiv=Cache-Control Content=No-Cache>
<META Http-Equiv=Pragma Content=No-Cache>
<META Http-Equiv=Expires Content=0>
</HEAD>
<BODY bgcolor=#FFFFFF topmargin=0 bottommargin=0 marginwidth=0 marginheight=0 leftmargin=0 rightmargin=0>
<table width="60%" border="0" cellspacing="0" cellpadding="0" align=center>
  <tr>
<div id="tooltip"></div>
    <td><input type="button" class="lbut" onClick="location='?useaction=admin-action&addid=bots&add=1'" value="Создание Бота" /></td>
    <td><input type="button" class="lbut" onClick="location='?useaction=admin-action&addid=bots&edits=1'" value="Редактор" /></td>
    <td><input type="button" class="lbut" onClick="location='?useaction=admin-action&addid=bots&look=2'" value="Просмотр игроков" /></td>
  </tr>
</table>
<?php
if (@$_GET["add"])
    {
        echo '<form action=?useaction=admin-action&addid=bots&added=1 method=post><center><table class=but2 border=0 width=60%>
                <tr>
                <td class=timef>Ник</td><td width=50%><input type=text class=login name=login></td></tr><tr>
        <td class=timef>Образ бота</td><td width=50%><input type=text class=login name=obraz></td>
        </tr>
        <tr>
        <td class=timef>Уровень бота</td><td width=50%><input type=text class=login name=level></td>
        </tr>
                <tr><td class=timef>Тотем</td><td width=50%>
        <select name="thotem" >
      <option value="t0" selected="selected">Час Дракона</option>
      <option value="t1">Час Волка</option>
      <option value="t2">Час Скорпиона</option>
      <option value="t3">Час Ворона</option>
      <option value="t4">Час Тигра</option>
      <option value="t5">Час Сокола</option>
      <option value="t6">Час Акулы</option>
      <option value="t7">Час Единорога</option>
      <option value="t8">Час Змеи</option>
      <option value="t9">Час Филина</option>
      <option value="t10">Час Рысы</option>
      <option value="t11">Час Кобана</option>
    </select></td>
    </tr>
    <tr>
        <td class=timef>Сила</td><td width=50%><input type=text class=login name=sila></td>
        </tr>
                <tr>
        <td class=timef>Ловкость</td><td width=50%><input type=text class=login name=lovk></td>
        </tr>
                <tr>
        <td class=timef>Удача</td><td width=50%><input type=text class=login name=uda4a></td>
        </tr>
                <tr>
        <td class=timef>Здоровье</td><td width=50%><input type=text class=login name=zdorov></td>
        </tr>
                <tr>
        <td class=timef>Знание</td><td width=50%><input type=text class=login name=znan></td>
        </tr>
                <tr>
        <td class=timef>Жизни</td><td width=50%><input type=text class=login name=hp>/<input type=text class=login name=hp_all></td>
        </tr>
                <tr>
        <td class=timef>Мана</td><td width=50%><input type=text class=login name=mp>/<input type=text class=login name=mp_all></td>
        </tr><tr><td class=timef>';
        for($i=0;$i<=71;$i++){
switch($i)
{
case 0: $fr="";break;
case 1: $fr="Удар (пример 20-30):";break;
case 2: $fr="";break;
case 3: $fr="";break;
case 4: $fr="";break;
case 5: $fr="Уловка:";break;
case 6: $fr="Точность:";break;
case 7: $fr="Сокрушение:";break;
case 8: $fr="Стойкость:";break;
case 9: $fr="Класс брони:";break;
case 10: $fr="Пробой брони:";break;
case 11: $fr="";break;
case 12: $fr="";break;
case 13: $fr="";break;
case 14: $fr="";break;
case 15: $fr="";break;
case 16: $fr="";break;
case 17: $fr="";break;
case 18: $fr="";break;
case 19: $fr="";break;
case 20: $fr="";break;
case 21: $fr="";break;
case 22: $fr="";break;
case 23: $fr="";break;
case 24: $fr="";break;
case 25: $fr="";break;
case 26: $fr="";break;
case 27: $fr="НР:";break;
case 28: $fr="";break;
case 29: $fr="Мана:";break;
case 30: $fr="Cила:";break;
case 31: $fr="Ловкость:";break;
case 32: $fr="Удача:";break;
case 33: $fr="Здоровье:";break;
case 34: $fr="Знания:";break;
case 35: $fr="";break;
case 36: $fr="";break;
case 37: $fr="";break;
case 38: $fr="";break;
case 39: $fr="";break;
case 40: $fr="";break;
case 41: $fr="";break;
case 42: $fr="";break;
case 43: $fr="";break;
case 44: $fr="";break;
case 45: $fr="";break;
case 46: $fr="";break;
case 47: $fr="";break;
case 48: $fr="";break;
case 49: $fr="";break;
case 50: $fr="";break;
case 51: $fr="";break;
case 52: $fr="";break;
case 53: $fr="";break;
case 54: $fr="";break;
case 55: $fr="";break;
case 56: $fr="";break;
case 57: $fr="";break;
case 58: $fr="";break;
case 59: $fr="";break;
case 60: $fr="";break;
case 61: $fr="";break;
case 62: $fr="";break;
case 63: $fr="";break;
case 64: $fr="";break;
case 65: $fr="";break;
case 66: $fr="";break;
case 67: $fr="";break;
case 68: $fr="";break;
case 69: $fr="";break;
case 70: $fr="";break;
case 71: $fr="Коэффициент(бота):";break;
}
if($fr!="")echo "$fr<input name=pr[$i] type=text value=\"\"/><br>\n";
}
            echo'</td></tr>';
                echo'<tr><td colspan=4><input name="smb1" type="submit" class="lbut" value="Добавить" /></td></tr>';
        echo '</table></center></form>';
    }
        if($smb1){
for($i=0;$i<=71;$i++){
 
if($pr[$i]!="|"){$par.="$pr[$i]|";}}
$par=substr_replace($par, '', -1);
mysql_query("INSERT INTO `user` (login,obraz,level,thotem,sila,lovk,uda4a,zdorov,znan,hp,hp_all,mp,mp_all,st,
type) VALUES ('".$_POST['login']."','".$_POST['obraz']."','".$_POST['level']."','".$_POST['thotem']."','".$_POST['sila']."','".$_POST['uda4a']."','".$_POST['lovk']."','".$_POST['zdorov']."','".$_POST['znan']."','".$_POST['hp']."','".$_POST['hp_all']."','".$_POST['mp']."','".$_POST['mp_all']."','".$par."','3')");
echo "<br><span class=prchattime>Бот создан.</span></div>";
        }
        if (@$_GET["edits"])
    {
        echo '<form action=?useaction=admin-action&addid=bots&edit=1 method=post><center><table class=but2 border=0 width=60%>
                <select name="idit" >
  <option value=0'; if($idit==""){echo " selected=selected";}echo'>Выберите тип</option>';
  $it=mysql_query("SELECT `user`.`id`, `user`.`name`, `user`.`level` FROM user WHERE `type`='3' ORDER BY `name`,`level`;");
      while ($row = mysql_fetch_assoc($it)) {
      echo "<option value=$row[id]";if($idit==$row[id]){echo " selected=selected";}echo">$row[name] [ $row[level] ]</option>";
      }
          echo'</select> <input name="edit" type="submit" class="lbut" value="Загрузить" />
</form>';
                }
if($edit){
  $it=mysql_fetch_assoc(mysql_query("SELECT * FROM `user` WHERE `id`='$idit';"));
  echo'<form name="edititem" method="post" action="?useaction=admin-action&addid=bots&edit=1&idit='.$idit.'"><center><table class=but2 border=0 width=60%>
                  <tr>
                <td class=timef>Ник</td><td width=50%><input type=text name=login value="'.$it['login'].'"></td></tr><tr>
        <td class=timef>Образ бота</td><td width=50%><input type=text name=obraz value="'.$it['obraz'].'"></td>
        </tr>
        <tr>
        <td class=timef>Уровень бота</td><td width=50%><input type=text name=level value="'.$it['level'].'"></td>
        </tr>
                <tr><td class=timef>Тотем</td><td width=50%>';
        unset($w);
    switch($it[thotem])
{
case t0: $w[0]=" selected=selected";break;
case t1: $w[1]=" selected=selected";break;
case t2: $w[2]=" selected=selected";break;
case t3: $w[3]=" selected=selected";break;
case t4: $w[4]=" selected=selected";break;
case t5: $w[5]=" selected=selected";break;
case t6: $w[6]=" selected=selected";break;
    case t7: $w[7]=" selected=selected";break;
        case t8: $w[8]=" selected=selected";break;
            case t9: $w[9]=" selected=selected";break;
                case t10: $w[10]=" selected=selected";break;
                    case t11: $w[11]=" selected=selected";break;
    }
                echo'<select name="thotem" >
      <option value="t0'.$w[0].'" selected="selected">Час Дракона</option>
      <option value="t1'.$w[1].'">Час Волка</option>
      <option value="t2'.$w[2].'">Час Скорпиона</option>
      <option value="t3'.$w[3].'">Час Ворона</option>
      <option value="t4'.$w[4].'">Час Тигра</option>
      <option value="t5'.$w[5].'">Час Сокола</option>
      <option value="t6'.$w[6].'">Час Акулы</option>
      <option value="t7'.$w[7].'">Час Единорога</option>
      <option value="t8'.$w[8].'">Час Змеи</option>
      <option value="t9'.$w[9].'">Час Филина</option>
      <option value="t10'.$w[10].'">Час Рысы</option>
      <option value="t11'.$w[11].'">Час Кобана</option>
    </select></td>
    </tr>
    <tr>
        <td class=timef>Сила</td><td width=50%><input type=text name=sila value="'.$it['sila'].'"></td>
        </tr>
                <tr>
        <td class=timef>Ловкость</td><td width=50%><input type=text name=lovk value="'.$it['lovk'].'"></td>
        </tr>
                <tr>
        <td class=timef>Удача</td><td width=50%><input type=text name=uda4a value="'.$it['uda4a'].'"></td>
        </tr>
                <tr>
        <td class=timef>Здоровье</td><td width=50%><input type=text name=zdorov value="'.$it['zdorov'].'"></td>
        </tr>
                <tr>
        <td class=timef>Знание</td><td width=50%><input type=text name=znan value="'.$it['znan'].'"></td>
        </tr>
                <tr>
        <td class=timef>Жизни</td><td width=50%><input type=text name=hp value="'.$it['hp'].'">/<input type=text name=hp_all value="'.$it['hp_all'].'"></td>
        </tr>
                <tr>
        <td class=timef>Мана</td><td width=50%><input type=text name=mp value="'.$it['mp'].'">/<input type=text name=mp_all value="'.$it['mp_all'].'"></td>
        </tr><tr><td class=timef>';
$param=explode("|",$it['st']);
foreach ($param as $value) {
$stat=$value;
$par[$stat[0]]=$stat[1];}       
    for($i=0;$i<=71;$i++){
          switch($i)
{
case 0: $fr="";break;   
case 1: $fr="Удар (пример 20-30):";break;
case 2: $fr="";break;
case 3: $fr="";break;
case 4: $fr="";break;
case 5: $fr="Уловка:";break;
case 6: $fr="Точность:";break;
case 7: $fr="Сокрушение:";break;
case 8: $fr="Стойкость:";break;
case 9: $fr="Класс брони:";break;
case 10: $fr="";break;
case 11: $fr="";break;
case 12: $fr="";break;
case 13: $fr="";break;
case 14: $fr="";break;
case 15: $fr="";break;
case 16: $fr="";break;
case 17: $fr="";break;
case 18: $fr="";break;
case 19: $fr="";break;
case 20: $fr="";break;
case 21: $fr="";break;
case 22: $fr="";break;
case 23: $fr="";break;
case 24: $fr="";break;
case 25: $fr="";break;
case 26: $fr="";break;
case 27: $fr="НР:";break;
case 28: $fr="";break;
case 29: $fr="Мана:";break;
case 30: $fr="Cила:";break;
case 31: $fr="Ловкость:";break;
case 32: $fr="Удача:";break;
case 33: $fr="Здоровье:";break;
case 34: $fr="Знания:";break;
case 35: $fr="";break;
case 36: $fr="";break;
case 37: $fr="";break;
case 38: $fr="";break;
case 39: $fr="";break;
case 40: $fr="";break;
case 41: $fr="";break;
case 42: $fr="";break;
case 43: $fr="";break;
case 44: $fr="";break;
case 45: $fr="";break;
case 46: $fr="";break;
case 47: $fr="";break;
case 48: $fr="";break;
case 49: $fr="";break;
case 50: $fr="";break;
case 51: $fr="";break;
case 52: $fr="";break;
case 53: $fr="";break;
case 54: $fr="";break;
case 55: $fr="";break;
case 56: $fr="";break;
case 57: $fr="";break;
case 58: $fr="";break;
case 59: $fr="";break;
case 60: $fr="";break;
case 61: $fr="";break;
case 62: $fr="";break;
case 63: $fr="";break;
case 64: $fr="";break;
case 65: $fr="";break;
case 66: $fr="";break;
case 67: $fr="";break;
case 68: $fr="";break;
case 69: $fr="";break;
case 70: $fr="";break;
case 71: $fr="Коэффициент(бота):";break;
}
if($fr!="")echo "$fr<input name=pr[$i] type=text value=\"$par[$i]\"/><br>\n";
}
                echo'</td></tr>';
                echo'<tr><td colspan=4><input name="smb1" type="submit" class="lbut" value="Сохранить" /></td></tr>';
        echo '</table></center></form>';
}
?>

Возник вопрос когда идет чтение параметров в таблице user поле st
PHP:
$param=explode("|",$it['st']);
foreach ($param as $value) {
$stat=$value;
$par[$stat[0]]=$stat[1];}

Формат поле st такой: |20-25|||||50||||55|50|||500||510||||||||||||
Тоесть происходит не правильно чтение параметров. Что не так??
 
Назад
Сверху