Ejemplo n.º 1
0
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}';";
    }
    $row_count = umc_mysql_execute_query($sql);
    if ($row_count == 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();
            }
        }
    }
}
Ejemplo n.º 2
0
function umc_lot_rem_player($player, $lot, $owner)
{
    XMPP_ERROR_trace(__FUNCTION__, func_get_args());
    // get user_id
    $user_id = umc_get_worldguard_id('user', $player, false);
    if (!$user_id) {
        XMPP_ERROR_trigger("Tried to remove {$player} from {$lot} but user_id not found (umc_lot_rem_player)");
        die('umc_lot_rem_player');
    }
    $world = umc_get_lot_world($lot);
    $world_id = umc_get_worldguard_id('world', $world);
    if (!$world) {
        XMPP_ERROR_trigger("World {$world} could not be found for lot_name {$lot} to remove member {$player} (umc_lot_rem_player)");
        die('umc_lot_rem_player');
    }
    $sql = "DELETE FROM minecraft_worldguard.region_players\n        WHERE region_id='{$lot}' AND world_id='{$world_id}' AND user_id={$user_id} AND owner={$owner};";
    $count = umc_mysql_execute_query($sql);
    umc_log('lot_manager', 'remove player', "{$player} was removed from lot {$lot}; Owner: {$owner}");
    if ($count > 0) {
        return true;
    } else {
        XMPP_ERROR_trigger("Could not remove {$player} from {$lot} in {$world} (id {$world_id}), entry not found (umc_lot_rem_player)");
        return false;
    }
}
Ejemplo n.º 3
0
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);
    $count = umc_mysql_execute_query($sql);
    return $count;
}