Ejemplo n.º 1
0
$db = mysql_connect(PHPRPG_DB_HOST, PHPRPG_DB_USER, PHPRPG_DB_PASS) or die(mysql_error());
mysql_select_db(PHPRPG_DB_NAME) or die(mysql_error());
function jump_random_query(&$query)
{
    $all = @mysql_num_rows($query);
    if ($all > 0) {
        $r = mt_rand(0, $all - 1);
        mysql_data_seek($query, $r);
    }
    return 0;
}
for ($i = 0; $i < 3; $i++) {
    //раскидаем по земле разные бутылечки
    $maze = myquery("SELECT * FROM game_maps WHERE maze=1");
    jump_random_query($maze);
    $maze = mysql_fetch_assoc($maze);
    echo $maze['name'];
    list($dim_x) = mysql_fetch_array(myquery("SELECT xpos FROM game_maze WHERE map_name=" . $maze['id'] . " ORDER BY xpos DESC LIMIT 1"));
    list($dim_y) = mysql_fetch_array(myquery("SELECT ypos FROM game_maze WHERE map_name=" . $maze['id'] . " ORDER BY ypos DESC LIMIT 1"));
    $str_query = "SELECT xpos,ypos FROM game_maze WHERE (move_up+move_down+move_left+move_right)<=1 AND map_name=" . $maze['id'] . " AND (xpos<>0 AND ypos<>0) AND (xpos<>{$dim_x} AND ypos<>{$dim_y})";
    $sel = myquery($str_query);
    echo $str_query . '<br>' . mysql_num_rows($sel);
    jump_random_query($sel);
    $maplab = mysql_fetch_assoc($sel);
    $map_xpos = $maplab['xpos'];
    $map_ypos = $maplab['ypos'];
    $already = mysql_result(myquery("SELECT COUNT(*) FROM game_items WHERE user_id=0 AND map_name='" . $maze['id'] . "' AND ident='Зелье зарядки артефактов'"), 0, 0);
    if ($already < 8) {
        $up = myquery("INSERT INTO game_items (ident,user_id,weight,img,map_name,map_xpos,map_ypos,type) VALUES ('Зелье зарядки артефактов','0','0','other/phial','" . $maze['id'] . "','{$map_xpos}','{$map_ypos}','Прочее')");
    }
}
Ejemplo n.º 2
0
<?php

//Крон для запуска каждые 4 часа
include "config.inc.php";
move_teleport(240);
myquery("DELETE FROM game_cron_log WHERE cron='every_4hour' AND step='final'");
myquery("INSERT INTO game_cron_log (cron,step,timecron) VALUES ('every_4hour','Начало'," . time() . ")");
$idcronlog = mysql_insert_id();
myquery("UPDATE game_cron_log SET step='Создание обелиска', timecron=" . time() . " WHERE id={$idcronlog}");
$new = myquery("SELECT type FROM game_obelisk WHERE time_begin=0 AND type NOT IN (SELECT harka FROM game_obelisk_users WHERE type=0 AND time_end>" . time() . ")");
if (mysql_num_rows($new) > 0) {
    jump_random_query($new);
    $ob = mysql_fetch_assoc($new);
    $harka = $ob['type'];
    $hour = mt_rand(-210 * 60, +210 * 60);
    $time_begin = time() + 5 * 60 * 60 + $hour;
    $time_end = $time_begin + 24 * 60 * 60;
    $map = mt_rand(0, 1);
    if ($map == 0) {
        $map_name = 5;
    } else {
        $map_name = 18;
    }
    list($max_xpos, $max_ypos) = mysql_fetch_array(myquery("SELECT xpos,ypos FROM game_map WHERE name={$map_name} ORDER BY xpos DESC, ypos DESC LIMIT 1"));
    $map_xpos = mt_rand(1, $max_xpos - 1);
    $map_ypos = mt_rand(1, $max_ypos - 1);
    myquery("UPDATE game_obelisk SET time_begin={$time_begin}, time_end={$time_end}, map_xpos={$map_xpos}, map_ypos={$map_ypos}, map_name={$map_name}, user_id=0 WHERE type='{$harka}'");
}
myquery("UPDATE game_cron_log SET step='final', timecron=" . time() . " WHERE id={$idcronlog}");
Ejemplo n.º 3
0
        myquery("UPDATE game_npc SET npc_quest_guild=0,npc_quest_id=0,npc_quest_end_time=0 WHERE npc_quest_id='{$i}'");
        echo '<br>Создаем квест №' . $i . '';
        if ($i >= 5) {
            $map = 18;
        } else {
            $map = 5;
        }
        $selitem = myquery("SELECT id FROM game_items_factsheet WHERE type=98");
        jump_random_query($selitem);
        $r = mysql_fetch_assoc($selitem);
        while (1 == 1) {
            $sel = myquery("SELECT Distinct game_gorod.town, game_gorod.rustown FROM game_gorod \n\t\t\t\t\t\t\tJoin game_map On game_gorod.town=game_map.town \n\t\t\t\t\t\t\tJoin game_gorod_set_option On game_gorod.town=game_gorod_set_option.gorod_id\n\t\t\t\t\t\t\tWHERE rustown<>'' and game_map.name={$map} and game_gorod_set_option.option_id=13 and game_map.to_map_name=0 ");
            jump_random_query($sel);
            $guild = mysql_fetch_assoc($sel);
            $guild_id = $guild['town'];
            $rustown = $guild['rustown'];
            $check_npc = mysql_result(myquery("SELECT COUNT(*) FROM game_npc WHERE npc_quest_guild='{$guild_id}'"), 0, 0);
            if ($check_npc == 0) {
                echo '<br>guild_id=' . $guild_id . ' - ' . $rustown;
                echo '<br>npc_map_name=' . $map . '';
                $npc_select = myquery("SELECT game_npc.id FROM game_npc \n\t\t\t\t\t\t\t\t\t   Join game_npc_template On game_npc_template.npc_id=game_npc.npc_id\n                                       WHERE game_npc_template.npc_level>=5 and game_npc_template.npc_level<=50 and game_npc.prizrak='0' AND map_name='" . $map . "' AND npc_quest_id=0");
                jump_random_query($npc_select);
                $npc = mysql_fetch_assoc($npc_select);
                $npc_id = $npc['id'];
                myquery("UPDATE game_npc SET npc_quest_guild='{$guild_id}',npc_quest_end_time='" . (time() + 45 * 60) . "',npc_quest_item=" . $r['id'] . ",npc_quest_id='{$i}' WHERE id='{$npc_id}'");
                break;
            }
        }
    }
}
myquery("UPDATE game_cron_log SET step='final', timecron=" . time() . " WHERE id={$idcronlog}");