コード例 #1
0
ファイル: every_2hour.php プロジェクト: themiddleearth/RPG.SU
<?php

//Крон для запуска каждые 2 часа
include "config.inc.php";
move_teleport(120);
myquery("DELETE FROM game_cron_log WHERE cron='every_2hour' AND step='final'");
myquery("INSERT INTO game_cron_log (cron,step,timecron) VALUES ('every_2hour','Начало'," . time() . ")");
$idcronlog = mysql_insert_id();
myquery("UPDATE game_cron_log SET step='1. Очистка комплектов', timecron=" . time() . " WHERE id={$idcronlog}");
myquery("DELETE FROM game_users_complects, game_users_complects_prepare USING game_users_complects, game_users_complects_prepare\n\t\t WHERE game_users_complects.id=game_users_complects_prepare.complect_id \n\t\t AND game_users_complects.status=0 AND game_users_complects.finish_time<'" . time() . "'");
myquery("UPDATE game_cron_log SET step='final', timecron=" . time() . " WHERE id={$idcronlog}");
コード例 #2
0
<?php

//Крон для запуска каждые 3 минуты
include "config.inc.php";
move_teleport(3);
$j = 0;
myquery("DELETE FROM game_cron_log WHERE cron='every_3minute' AND step='final'");
myquery("INSERT INTO game_cron_log (cron,step,timecron) VALUES ('every_3minute','Начало'," . time() . ")");
$idcronlog = mysql_insert_id();
$j++;
myquery("UPDATE game_cron_log SET step='" . $j . ". Доставка магических посылок в инвентари получателей', timecron=" . time() . " WHERE id={$idcronlog}");
$sel_post = myquery("SELECT * FROM game_items WHERE post_to>0 AND post_var=1 AND priznak=3");
while ($post = mysql_fetch_array($sel_post)) {
    list($ident, $weight) = mysql_fetch_array(myquery("SELECT name,weight FROM game_items_factsheet WHERE id=" . $post['item_id'] . ""));
    $post_sel = myquery("SELECT * FROM game_users WHERE user_id=" . $post['post_to'] . "");
    if (!mysql_num_rows($post_sel)) {
        $post_sel = myquery("SELECT * FROM game_users_archive WHERE user_id=" . $post['post_to'] . "");
    }
    $post_user = mysql_fetch_array($post_sel);
    $char_sel = myquery("SELECT * FROM game_users WHERE user_id=" . $post['user_id'] . "");
    if (!mysql_num_rows($char_sel)) {
        $char_sel = myquery("SELECT * FROM game_users_archive WHERE user_id=" . $post['user_id'] . "");
    }
    $char = mysql_fetch_array($char_sel);
    $prov = mysql_result(myquery("select count(*) from game_wm where user_id=" . $post['post_to'] . " AND type=1"), 0, 0);
    if ($post_user['CW'] + $weight <= $post_user['CC'] or $prov > 0) {
        myquery("INSERT INTO game_pm (komu, otkogo, theme, post, view, time) VALUES (" . $post_user['user_id'] . ", '0', 'Тебе пришла магическая посылка', 'В твой инвентарь службой магических посылок доставлена посылка <" . $ident . ">. Отправитель - " . $char['name'] . "', '0'," . time() . ")") or die(mysql_error());
        $str_query = "INSERT INTO game_pm (komu, otkogo, theme, post, view, time) VALUES (" . $char['user_id'] . ", '0', 'Уведомление о доставке посылки', 'Твоя посылка <" . $ident . "> успешно доставлена адресату - " . $post_user['name'] . "', '0'," . time() . ")";
        //echo $str_query;
        myquery($str_query) or die(mysql_error());
        myquery("UPDATE game_items SET user_id=" . $post_user['user_id'] . ",priznak=0,ref_id=0,post_to=0,post_var=0,sell_time=0,town=0,map_name=0,map_xpos=0,map_ypos=0,used=0 WHERE id=" . $post['id'] . "");
コード例 #3
0
ファイル: every_4hour.php プロジェクト: themiddleearth/RPG.SU
<?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}");
コード例 #4
0
<?php

//Крон для запуска каждые 12 часов
if (defined("TEST_MODE") and TEST_MODE) {
    die;
}
include "config.inc.php";
move_teleport(720);
mysql_query("set wait_timeout = 1800");
function DbConnectStat()
{
    $db_stat = mysql_connect('localhost', 'rpgsu_stats', 'EuTh4fsFjdvMMuSY') or die(mysql_error());
    mysql_select_db('rpgsu_stats', $db_stat) or die(mysql_error());
}
DbConnect();
//Делаем слепок со статистики:
myquery("DELETE FROM game_cron_log WHERE cron='every_12hour' AND step='final'");
myquery("INSERT INTO game_cron_log (cron,step,timecron) VALUES ('every_12hour','Начало'," . time() . ")");
$idcronlog = mysql_insert_id();
myquery("UPDATE game_cron_log SET step='1Обновление статистики', timecron=" . time() . " WHERE id={$idcronlog}");
DbConnectStat();
myquery("TRUNCATE TABLE game_stat_view") or die;
//myquery("DELETE FROM game_stat_view WHERE stat_id=5 AND npc_id<>0");
$game = myquery("SELECT game_stat.npc_id, COUNT( * ) AS npc_kill , game_stat.npc_id AS npc_id\nFROM game_stat\nLEFT JOIN gamerpgsu.game_npc ON gamerpgsu.game_npc.id = game_stat.npc_id\nWHERE gamerpgsu.game_npc.view=1 AND game_stat.stat_id = '5' AND gamerpgsu.game_npc.map_name IN (5,18)\nGROUP BY game_stat.npc_id ORDER BY npc_kill DESC limit 5");
while ($elf = mysql_fetch_array($game)) {
    myquery("INSERT INTO game_stat_view (stat_id,substat_id,npc_id,npc_kill) VALUES (5,1,'" . $elf['npc_id'] . "','" . $elf['npc_kill'] . "')");
}
myquery("UPDATE game_cron_log SET step='2Обновление статистики', timecron=" . time() . " WHERE id={$idcronlog}");
$game = myquery("SELECT game_stat.npc_id, COUNT( * ) AS npc_kill , game_stat.npc_id AS npc_id\nFROM game_stat\nLEFT JOIN gamerpgsu.game_npc ON gamerpgsu.game_npc.id = game_stat.npc_id\nWHERE gamerpgsu.game_npc.view=1 AND game_stat.stat_id = '2' AND gamerpgsu.game_npc.map_name IN (5,18)\nGROUP BY game_stat.npc_id ORDER BY npc_kill DESC limit 5");
while ($elf = mysql_fetch_array($game)) {
    myquery("INSERT INTO game_stat_view (stat_id,substat_id,npc_id,npc_kill) VALUES (2,1,'" . $elf['npc_id'] . "','" . $elf['npc_kill'] . "')");
コード例 #5
0
ファイル: every_6hour.php プロジェクト: themiddleearth/RPG.SU
<?php

//Крон для запуска каждые 6 часов
include "config.inc.php";
move_teleport(360);
myquery("DELETE FROM game_cron_log WHERE cron='every_6hour' AND step='final'");
myquery("INSERT INTO game_cron_log (cron,step,timecron) VALUES ('every_6hour','Начало'," . time() . ")");
$idcronlog = mysql_insert_id();
myquery("UPDATE game_cron_log SET step='Очистка чатов городов', timecron=" . time() . " WHERE id={$idcronlog}");
//очистим чаты городов
$time1 = time() - 24 * 60 * 60;
myquery("DELETE FROM game_log WHERE date<{$time1} AND town<>0");
/*
myquery("UPDATE game_cron_log SET step='Раскидываем сундуки с золотом', timecron=".time()." WHERE id=$idcronlog");
//раскидаем по картам сундуки с золотом
$rand_map = mt_rand(1,20);

if ($rand_map<=6)
{
    $map_name = @mysql_result(@myquery("SELECT id FROM game_maps WHERE name='Средиземье'"),0,0);
    $map_xpos = mt_rand(0,53);
    $map_ypos = mt_rand(0,49);
}
elseif ($rand_map<=15)
{
    $map_name = @mysql_result(@myquery("SELECT id FROM game_maps WHERE name='Белерианд'"),0,0);
    $map_xpos = mt_rand(0,45);
    $map_ypos = mt_rand(0,39);
}
else
{
コード例 #6
0
ファイル: every_hour.php プロジェクト: themiddleearth/RPG.SU
<?php

//Крон для запуска каждый час
include "config.inc.php";
move_teleport(60);
myquery("DELETE FROM game_cron_log WHERE cron='every_hour' AND step='final'");
myquery("INSERT INTO game_cron_log (cron,step,timecron) VALUES ('every_hour','Начало'," . time() . ")");
$idcronlog = mysql_insert_id();
myquery("UPDATE game_cron_log SET step='Оптимизация таблиц', timecron=" . time() . " WHERE id={$idcronlog}");
$result = myquery("OPTIMIZE TABLE game_chat");
$result = myquery("OPTIMIZE TABLE game_battles");
$result = myquery("OPTIMIZE TABLE game_log");
/*
myquery("UPDATE game_cron_log SET step='Корректировка опыта за бота', timecron=".time()." WHERE id=$idcronlog");
$sel = myquery("SELECT game_npc.id,game_npc.EXP,game_npc_template.npc_exp_max,game_npc.kill_last_hour FROM game_npc,game_npc_template WHERE game_npc.prizrak=0 AND game_npc_template.npc_exp_max>200 AND game_npc.npc_id=game_npc_template.npc_id");
while ($npc = mysql_fetch_array($sel))
{
	$npc_exp = $npc['EXP'];
	if ($npc['kill_last_hour']<=3) $npc_exp = $npc_exp*1.1;
	elseif ($npc['kill_last_hour']<=7) $npc_exp = $npc_exp*1;
	elseif ($npc['kill_last_hour']<=10) $npc_exp = $npc_exp*0.95;
	elseif ($npc['kill_last_hour']<=13) $npc_exp = $npc_exp*0.90;
	elseif ($npc['kill_last_hour']<=18) $npc_exp = $npc_exp*0.85;
	elseif ($npc['kill_last_hour']<=23) $npc_exp = $npc_exp*0.80;
	elseif ($npc['kill_last_hour']<=28) $npc_exp = $npc_exp*0.75;
	elseif ($npc['kill_last_hour']<=33) $npc_exp = $npc_exp*0.70;
	elseif ($npc['kill_last_hour']<=38) $npc_exp = $npc_exp*0.65;
	elseif ($npc['kill_last_hour']<=43) $npc_exp = $npc_exp*0.60;
	elseif ($npc['kill_last_hour']<=48) $npc_exp = $npc_exp*0.55;
	else $npc_exp = $npc_exp*0.50;
	$npc_exp = min($npc_exp,$npc['npc_exp_max']);
コード例 #7
0
<?php

//Крон для запуска каждую минуту
include "config.inc.php";
//ID карты Туманные Горы
define('id_map_tuman', 0);
$maze_id = "(691,692,804," . id_map_tuman . ")";
echo 'Обновление энергии<br>';
$event_cycles = 1;
$result_stamina_up = myquery("UPDATE game_users,game_users_map,game_users_func,game_users_active\nSET game_users.STM = LEAST (game_users.STM+CEILING(7*game_users.DEX/3)*{$event_cycles}, game_users.STM_MAX)\nWHERE game_users.STM < game_users.STM_MAX\nAND game_users.user_id=game_users_func.user_id\nAND game_users_func.func_id!='1'\nAND game_users.user_id=game_users_map.user_id\nAND game_users_map.map_name NOT IN " . $maze_id . "\nAND game_users_map.map_name<838\nAND game_users_active.user_id=game_users.user_id\nAND game_users_active.last_active>=(UNIX_TIMESTAMP()-300)\n");
echo 'Обновление праны<br>';
$event_cycles = 1;
$result_stamina_up = myquery("UPDATE game_users,game_users_map,game_users_func,game_users_active\nSET game_users.PR = LEAST (game_users.PR+CEILING(7*game_users.DEX/3)*{$event_cycles}, game_users.PR_MAX)\nWHERE game_users.PR < game_users.PR_MAX\nAND game_users.user_id=game_users_func.user_id\nAND game_users_func.func_id!='1'\nAND game_users.user_id=game_users_map.user_id\nAND game_users_map.map_name NOT IN " . $maze_id . "\nAND game_users_map.map_name<838\nAND game_users_active.user_id=game_users.user_id\nAND game_users_active.last_active>=(UNIX_TIMESTAMP()-300)\n");
echo 'Обновление жизни<br>';
$event_cycles = 1;
$result_health_up = myquery("UPDATE game_users,game_users_map,game_users_active\nSET game_users.HP = LEAST(game_users.HP+ROUND(game_users.HP_MAX/10)*{$event_cycles}, game_users.HP_MAX)\nWHERE game_users.DEX>=0\nAND game_users.HP < game_users.HP_MAX\nAND game_users.user_id=game_users_map.user_id\nAND game_users_map.map_name NOT IN " . $maze_id . "\nAND game_users_active.user_id=game_users.user_id\nAND game_users_map.map_name<838\nAND game_users_active.last_active>=(UNIX_TIMESTAMP()-300)\n");
echo 'Обновление маны<br>';
$event_cycles = 0.5;
$result_mana_up = myquery("UPDATE game_users,game_users_map,game_users_active\nSET game_users.MP = LEAST(game_users.MP+ROUND(game_users.MP_MAX/20)*{$event_cycles}, game_users.MP_MAX)\nWHERE game_users.NTL>=0\nAND game_users.MP < game_users.MP_MAX\nAND game_users.user_id=game_users_map.user_id\nAND game_users_map.map_name NOT IN " . $maze_id . "\nAND game_users_active.user_id=game_users.user_id\nAND game_users_active.last_active>=(UNIX_TIMESTAMP()-300)\nAND game_users_map.map_name<838\n");
move_teleport(1);
コード例 #8
0
<?php

//Крон для запуска каждые 10 минут
include "config.inc.php";
require_once "/home/vhosts/rpg.su/web/class/class_item.php";
move_teleport(10);
myquery("DELETE FROM game_cron_log WHERE cron='every_10minute' AND step='final'");
myquery("INSERT INTO game_cron_log (cron,step,timecron) VALUES ('every_10minute','Начало'," . time() . ")");
$idcronlog = mysql_insert_id();
myquery("UPDATE game_cron_log SET step='1. Проверка игроков по обелискам', timecron=" . time() . " WHERE id={$idcronlog}");
//проверка по обелискам
//type = 0 - обелиски взятые на карте
//type = 1 - зелье глубин, среднее зелье глубин
//type = 2 - сваренные зелья повышающие харки
//type = 3 - зелье бодрости
//type = 4 - зелье зоркости
//type = 5 - зелье невидимости
$sel = myquery("SELECT * FROM game_obelisk_users WHERE user_id>0 AND time_end<" . time() . "");
while ($ob = mysql_fetch_array($sel)) {
    if ($ob['type'] == 0 or $ob['type'] == 2) {
        if ($ob['value'] == 0) {
            myquery("UPDATE game_users SET " . $ob['harka'] . "=" . $ob['harka'] . "_MAX WHERE user_id = " . $ob['user_id'] . "");
            myquery("UPDATE game_users_archive SET " . $ob['harka'] . "=" . $ob['harka'] . "_MAX WHERE user_id = " . $ob['user_id'] . "");
        } else {
            myquery("UPDATE game_users SET " . $ob['harka'] . "=" . $ob['harka'] . "-" . $ob['value'] . " WHERE user_id = " . $ob['user_id'] . "");
            myquery("UPDATE game_users_archive SET " . $ob['harka'] . "=" . $ob['harka'] . "-" . $ob['value'] . " WHERE user_id = " . $ob['user_id'] . "");
        }
    } elseif ($ob['type'] == 1) {
        //перекачка HP_MAX, возвращаем его к HP_MAXX
        myquery("UPDATE game_users SET HP_MAX=HP_MAXX WHERE user_id = " . $ob['user_id'] . "");
        myquery("UPDATE game_users_archive SET HP_MAX=HP_MAXX WHERE user_id = " . $ob['user_id'] . "");
コード例 #9
0
ファイル: every_3hour.php プロジェクト: themiddleearth/RPG.SU
<?php

//Крон для запуска каждые 3 часа
include "config.inc.php";
move_teleport(180);
myquery("DELETE FROM game_cron_log WHERE cron='every_3hour' AND step='final'");
myquery("INSERT INTO game_cron_log (cron,step,timecron) VALUES ('every_3hour','Начало'," . time() . ")");
$idcronlog = mysql_insert_id();
myquery("UPDATE game_cron_log SET step='Раскидываем бутылки', timecron=" . time() . " WHERE id={$idcronlog}");
//раскидаем по земле разные бутылечки
$rand_map = mt_rand(1, 20);
if ($rand_map <= 5) {
    $map_name = @mysql_result(@myquery("SELECT id FROM game_maps WHERE name='Средиземье'"), 0, 0);
    $map_xpos = mt_rand(0, 53);
    $map_ypos = mt_rand(0, 49);
} elseif ($rand_map <= 15) {
    $map_name = @mysql_result(@myquery("SELECT id FROM game_maps WHERE name='Белерианд'"), 0, 0);
    $map_xpos = mt_rand(0, 45);
    $map_ypos = mt_rand(0, 39);
} else {
    $map_name = @mysql_result(@myquery("SELECT id FROM game_maps WHERE name='Гильдия новичков'"), 0, 0);
    $map_xpos = mt_rand(0, 10);
    $map_ypos = mt_rand(0, 5);
}
$r = mt_rand(1, 11);
if ($r == 1) {
    list($item_id) = mysql_fetch_array(myquery("SELECT id FROM game_items_factsheet WHERE name='Кадка воды'"));
} elseif ($r == 2) {
    list($item_id) = mysql_fetch_array(myquery("SELECT id FROM game_items_factsheet WHERE name='Кусок мяса'"));
} elseif ($r == 3) {
    list($item_id) = mysql_fetch_array(myquery("SELECT id FROM game_items_factsheet WHERE name='Магический эликсир'"));