コード例 #1
0
ファイル: hunger.inc.php プロジェクト: dani0010/uncovery_me
function umc_hunger_removeplayer($died = true)
{
    global $HUNGER, $UMC_USER;
    XMPP_ERROR_trace(__FUNCTION__, func_get_args());
    $uuid = $UMC_USER['uuid'];
    $username = $UMC_USER['username'];
    if (isset($HUNGER['current_game'])) {
        $game_id = $HUNGER['current_game']['id'];
        $status = $HUNGER['current_game']['status'];
    } else {
        return;
    }
    if (!$died) {
        $sql = "UPDATE minecraft_iconomy.`hunger_players` SET status='left', death=NOW()\r\n            WHERE game_id={$game_id} AND uuid='{$uuid}';";
    } else {
        $sql = "UPDATE minecraft_iconomy.`hunger_players` SET status='dead', death=NOW()\r\n            WHERE game_id={$game_id} AND uuid='{$uuid}';";
    }
    $rst = umc_mysql_query($sql);
    if (umc_mysql_affected_rows($rst, true) == 0) {
        return;
    }
    // read results from DB
    umc_hunger_find_players();
    umc_ws_cmd("pex user {$uuid} remove essentials.warps.hunger", 'asConsole');
    umc_ws_cmd("pex user {$uuid} remove modifyworld.* hunger", 'asConsole');
    XMPP_ERROR_send_msg("{$username} was removed from the hunger game");
    $winner = false;
    // Check for a win if the game is still on
    if ($status == 'started') {
        $winner = umc_hunger_check_winner();
        if (!$winner) {
            $admin_uuid = $HUNGER['current_game']['admin'];
            $admin = umc_user2uuid($admin_uuid);
            umc_echo("[Hunger] {green}You ({gold}{$username}{green}) were removed from Hunger Game {white}#{$game_id}.");
            if ($HUNGER['announce']) {
                umc_announce("[Hunger] The user {gold}{$username}{purple} just {cyan}left{gold} the hunger game!", $HUNGER['channel']);
            } else {
                umc_echo("[Hunger] The user {gold}{$username}{purple} just {cyan}left{gold} the hunger game!");
            }
            umc_ws_cmd("tell {$admin} The user {$username} just left the hunger game!", 'asConsole');
        }
    } else {
        if ($status == 'preparing') {
            // did we remove the last player of a game being prepared?
            $sql = "SELECT * FROM minecraft_iconomy.`hunger_players` WHERE status='preparing' AND game_id={$game_id};";
            $D3 = umc_mysql_fetch_all($sql);
            $num = count($D3);
            if ($num == 0) {
                // last player has quit, end the game
                umc_hunger_abort();
            }
        }
    }
}
コード例 #2
0
ファイル: timer.inc.php プロジェクト: dani0010/uncovery_me
function umc_timer_set($user, $type, $days = 0, $hours = 0, $minutes = 0)
{
    // check if the same timer type is already set
    $existing_timer = umc_timer_get($user, $type);
    $date_today = umc_datetime();
    $today = $date_today->format('Y-m-d H:i:s');
    $new_timer = false;
    if (!$existing_timer) {
        // no timer exits or is expired
        $existing_timer = $today;
        // new timer from today
        $new_timer = true;
    }
    $date_timeout = umc_datetime();
    // substract the current day
    $date_timeout->add(new DateInterval('P' . $days . 'DT' . $hours . 'H' . $minutes . 'M'));
    $timeout = $date_timeout->format('Y-m-d H:i:s');
    if ($new_timer) {
        $sql = "INSERT INTO minecraft_srvr.timers (`type`,`time_set`,`time_out`,`username`) VALUES ('{$type}', '{$today}' , '{$timeout}', '{$user}');";
        umc_log('timer', 'new', "{$type} timer from {$today} to {$timeout} for {$user}");
    } else {
        $sql = "UPDATE minecraft_srvr.timers SET time_out='{$timeout}', time_set='{$today}'  WHERE username='******' AND type='{$type}' LIMIT 1;";
        umc_log('timer', 'update', "{$type} timer from {$today} to {$timeout} for {$user}");
    }
    // umc_echo($sql);
    $rst = umc_mysql_query($sql);
    $count = umc_mysql_affected_rows(true);
    return $count;
}