function umc_money_give()
{
    global $UMC_USER;
    XMPP_ERROR_trace(__FUNCTION__, func_get_args());
    $player = $UMC_USER['username'];
    $args = $UMC_USER['args'];
    if (!isset($args[2])) {
        umc_error('You need to enter the user to give money to!');
    } else {
        if (strtolower($args[2]) == strtolower($player)) {
            umc_error('You cannot give money to yourself!');
        }
    }
    if (!isset($args[3])) {
        umc_error('You need to enter amount of money!');
    } else {
        if ($args[3] <= 0) {
            umc_error('You will need to give more than that!');
        }
    }
    $target = umc_sanitize_input($args[2], 'player');
    $sum = umc_sanitize_input($args[3], 'price');
    $check = umc_money($player, $target, $sum);
    if ($check) {
        umc_error('The transaction failed! Make sure that the target user exists');
    } else {
        umc_echo("You successfully transferred {$sum} Uncs to {$target}");
    }
    // get UUID or target player
    $target_uuid = umc_user2uuid($target);
    // check if the user is online
    if (isset($UMC_USER['player_data'][$target_uuid])) {
        umc_msg_user($target, "You just received {$sum} Uncs from {$player}!");
        umc_echo("The recipient is online, the server sent a notification message.");
    } else {
        // otherwise, send an email
        $title = "You received {$sum} Uncs from {$player}!";
        $message = "Dear {$target},\nyou just received {$sum} Uncs from {$player}.\n" . "The amount in in your account now.\n" . "Use /money check to see your account balance.\n";
        umc_mail_quick_send($title, $message, $target_uuid, false);
        umc_echo("The recipient is currently offline, the server sent a notification email.");
    }
    umc_log('money', 'give', "{$player} gave {$target} {$sum} Uncs");
    umc_money_status();
}
function umc_skyblock_abandon()
{
    global $UMC_USER;
    $player = $UMC_USER['username'];
    $args = $UMC_USER['args'];
    if (!isset($args[2])) {
        umc_show_help($args);
        die;
    } else {
        $lot = umc_sanitize_input($args[2], 'lot');
        $check = umc_check_lot_exists('skyblock', $lot);
        if (!$check) {
            umc_error("The lot you entered does not exist!");
        }
        if ($lot == 'block_k11') {
            umc_error('You cannot warp to that lot!');
        }
    }
    //check if the user abandoned already
    $abandon_id = umc_get_worldguard_id('user', '_abandoned_');
    $abandon_sql = "SELECT * FROM minecraft_worldguard.region_players WHERE region_id = '{$lot}' AND Owner=1 AND user_id={$abandon_id};";
    $D3 = umc_mysql_fetch_all($abandon_sql);
    $num = count($D3);
    if ($num > 0) {
        umc_error("You abandoned the entry {$lot} already!");
    }
    // make sure the user actually owns this enrty
    $user_id = umc_get_worldguard_id('user', strtolower($player));
    // find out if the user can have additional contest entries in this contest
    $sql = "SELECT * FROM minecraft_worldguard.world LEFT JOIN minecraft_worldguard.region ON world.id=region.world_id\r\n        LEFT JOIN minecraft_worldguard.region_cuboid ON region.id=region_cuboid.region_id\r\n        LEFT JOIN minecraft_worldguard.region_players ON region_cuboid.region_id=region_players.region_id\r\n        LEFT JOIN minecraft_worldguard.user ON region_players.user_id=user.id\r\n        WHERE region.id LIKE '{$lot}' AND Owner=1 AND user.id={$user_id}";
    $D = umc_mysql_fetch_all($sql);
    if (count($D) != 1) {
        umc_error("You do not own the lot {$lot} in skyblock!");
    } else {
        $row = $D[0];
    }
    $world_id = $row['world_id'];
    $ins_user_sql = "INSERT INTO minecraft_worldguard.region_players (region_id, world_id, user_id, Owner)\r\n        VALUES ('{$lot}', {$world_id}, {$abandon_id}, 1);";
    umc_mysql_query($ins_user_sql, true);
    umc_ws_cmd('region load -w skyblock', 'asConsole');
    umc_echo("You have succcessfully abandoned the lot {$lot}! It will be reset with the next reboot. You can then register a new one!");
}
示例#3
0
function umc_hunger_trophy()
{
    global $UMC_USER, $HUNGER;
    XMPP_ERROR_trace(__FUNCTION__, func_get_args());
    $args = $UMC_USER['args'];
    $player = $UMC_USER['username'];
    $uuid = $UMC_USER['uuid'];
    $game_id = isset($args[2]) ? $args[2] + 0 : null;
    if (!$game_id) {
        umc_error("[Hunger] {red}You must specify a [game-id] for which you were the winner.");
    }
    $victim = strtolower(umc_sanitize_input($args[3], 'player'));
    $victim_uuid = umc_user2uuid($victim);
    $sql_games = "SELECT *, timediff(NOW(),end) as age FROM minecraft_iconomy.hunger_games WHERE id = {$game_id}";
    $rst_games = umc_mysql_query($sql_games);
    if (mysql_num_rows($rst_games) > 0) {
        $game = umc_mysql_fetch_array($rst_games);
    }
    if (!$game) {
        umc_error("[Hunger] {red}No such game with game-id {yellow}{$game_id}");
    }
    if ($game['winner'] != $uuid) {
        umc_error("[Hunger] {red}You were not the winner of game-id {yellow}{$game_id}{red}.");
    }
    if ($game['trophy_claimed'] == 'y') {
        umc_error("[Hunger] {red}You already claimed a trophy for game-id {yellow}{$game_id}{red}.");
    }
    if ($game['age'] > '24:00:00') {
        // umc_error("{red}That game ended more than 24 hours ago, the corpses are too rotten.");
    }
    if ($victim_uuid == $uuid) {
        umc_error("[Hunger] {red}You can't claim your own head. Weirdo.");
    }
    umc_echo("finding players of game {$game_id}...");
    $HUNGER = umc_hunger_find_players($game_id);
    $players = $HUNGER['old_game'][$game_id]['players'];
    if (!in_array($victim, $players)) {
        umc_error("[Hunger] {red}{gold}{$victim}{red} was not vanquished in that game.");
    }
    umc_echo("checking your account balance....");
    $balance = umc_money_check($player);
    if ($balance < $HUNGER['trophy_cost']) {
        umc_error("[Hunger] {red}You can't afford a trophy, they cost {green}{$HUNGER['trophy_cost']} Uncs");
    }
    umc_echo("Account is fine...");
    $item_slot = $UMC_USER['current_item'];
    if ($item_slot != 0 || isset($UMC_USER['inv'][$item_slot])) {
        umc_error("[Hunger] {red}You have to pick first hotbar slot, and it has to be empty.");
    }
    umc_echo("[Hunger] all good, taking trophy...");
    #-- All good, do the work!
    $sql = "UPDATE minecraft_iconomy.hunger_games SET trophy_claimed = 'y' WHERE id = {$game_id}";
    umc_mysql_query($sql, true);
    umc_echo("[Hunger] charging {$HUNGER['trophy_cost']}...");
    umc_money($player, false, $HUNGER['trophy_cost']);
    umc_echo("[Hunger] {yellow}[\$]{gray} You have been charged {yellow}{$HUNGER['trophy_cost']}{gray} uncs.");
    umc_echo("[Hunger] getting head...");
    // umc_ws_cmd("give $player 397:3 1","asConsole");
    umc_ws_cmd("ph spawn {$victim} {$player}", "asConsole");
    umc_echo("[Hunger] {purple}Enjoy this small memento of your victory!");
    umc_log('hunger', 'trophy', "{$player} got the head of {$victim}");
}
/**
 * this returns the karma of a target or the current player, if no target set
 * returns either as value or as websend message, depening on the scenario
 *
 * @global type $UMC_USER
 * @global type $UMC_ENV
 * @param type $target
 * @param type $return
 * @return string
 */
function umc_getkarma($target = false, $return = false)
{
    XMPP_ERROR_trace(__FUNCTION__, func_get_args());
    global $UMC_USER, $UMC_ENV;
    if ($UMC_ENV == 'websend') {
        $user = $UMC_USER['username'];
        $user_uuid = $UMC_USER['uuid'];
        $args = $UMC_USER['args'];
    } else {
        $user = NULL;
        $args = NULL;
    }
    // do we have a target set? If no, assume current user
    if ($target) {
        $receiver_uuid = $target;
        $receiver = umc_user2uuid($target);
    } else {
        if (!isset($args[2])) {
            // get user's own karma
            $receiver = $user;
            $receiver_uuid = $user_uuid;
        } else {
            // get argument from command
            $receiver = umc_sanitize_input($args[2], 'player');
            $receiver_uuid = umc_user2uuid($receiver);
        }
    }
    if ($receiver == 'uncovery') {
        if ($return) {
            return "n/a";
        } else {
            if ($UMC_ENV == 'websend') {
                umc_error("Thou shalt not judge the maker of all things!");
            } else {
                return;
            }
        }
    }
    $banned = umc_user_is_banned($receiver_uuid);
    if ($banned) {
        if ($return) {
            return "(banned)";
        }
        umc_echo("User {$receiver} is banned");
        exit;
    }
    # Get the user's + and - karma entries
    $pos_sql = "SELECT SUM(karma) AS sum_karma\r\n\tFROM minecraft_srvr.karma\r\n        LEFT JOIN minecraft_srvr.UUID AS senders ON sender_uuid=uuid\r\n        WHERE receiver_uuid='{$receiver_uuid}' AND karma > 0\r\n\t  AND senders.lot_count > 0\r\n        GROUP BY receiver_uuid";
    $neg_sql = "SELECT SUM(karma) AS sum_karma\r\n\tFROM minecraft_srvr.karma\r\n        LEFT JOIN minecraft_srvr.UUID AS senders ON sender_uuid=uuid\r\n        WHERE receiver_uuid='{$receiver_uuid}' AND karma < 0\r\n\t  AND senders.lot_count > 0\r\n        GROUP BY receiver_uuid";
    $pos_data = umc_mysql_fetch_all($pos_sql);
    $neg_data = umc_mysql_fetch_all($neg_sql);
    # If the user has no karma entries, use 0
    if (count($pos_data) > 0) {
        $pos_karma = $pos_data[0]['sum_karma'];
    } else {
        $pos_karma = 0;
    }
    if (count($neg_data) > 0) {
        $neg_karma = $neg_data[0]['sum_karma'];
    } else {
        $neg_karma = 0;
    }
    $karma = $pos_karma + $neg_karma;
    if ($pos_karma == NULL && $neg_karma == NULL) {
        if ($return) {
            return 'n/a';
        }
        umc_echo("User {$receiver} has no karma record");
    } else {
        if ($pos_karma == NULL) {
            $pos_karma = 0;
        }
        if ($neg_karma == NULL) {
            $neg_karma = 0;
        }
        if ($return) {
            return "{$pos_karma}/{$neg_karma}";
        }
        umc_echo("User {$receiver} has {$karma} karma ({$pos_karma}/{$neg_karma}).");
    }
}
function umc_lot_warp()
{
    global $UMC_USER;
    $player = $UMC_USER['username'];
    $userlevel = $UMC_USER['userlevel'];
    $world = $UMC_USER['world'];
    $args = $UMC_USER['args'];
    $allowed_ranks = array('Owner', 'Guest');
    if (!in_array($userlevel, $allowed_ranks)) {
        umc_error("Sorry, this command is only for Guests!");
    }
    $allowed_worlds = array('empire', 'flatlands');
    if (!in_array($world, $allowed_worlds)) {
        umc_error('Sorry, you need to be in the Empire or Flatlands to warp!');
    } else {
        $lot = strtolower(umc_sanitize_input($args[2], 'lot'));
        // the above one fails already if the lot is not a proper lot
        $target_world = umc_get_lot_world($lot);
        if (!in_array($target_world, $allowed_worlds)) {
            umc_error('Sorry, you need to be in the Empire or Flatlands to warp!');
        }
        if ($target_world != $world) {
            umc_error("Sorry, you need to be in {$target_world} to warp to {$lot}!");
        }
    }
    $sql = "SELECT * FROM minecraft_worldguard.world LEFT JOIN minecraft_worldguard.region ON world.id=region.world_id\r\n        LEFT JOIN minecraft_worldguard.region_cuboid ON region.id=region_cuboid.region_id\r\n        WHERE world.name='{$target_world}' AND region.id = '{$lot}' ";
    $D = umc_mysql_fetch_all($sql);
    if (count($D) != 1) {
        umc_error("There was an error teleporting you to your lot, the admin was notified, please wait for it to be fixed!");
    }
    $lots = $D[0];
    $c_x = $lots['min_x'] + 64;
    $c_z = $lots['min_z'] + 64;
    $c_y = 256;
    $cmd = "tppos {$player} {$c_x} {$c_y} {$c_z} 0";
    umc_ws_cmd($cmd, 'asConsole');
    umc_pretty_bar("darkblue", "-", "{darkcyan} Warping to lot {$lot}");
    umc_echo("You are now in the center of lot {$lot}!");
    umc_footer();
}
示例#6
0
function umc_do_deposit_internal($all = false)
{
    global $UMC_USER, $UMC_SETTING, $UMC_DATA;
    $player = $UMC_USER['username'];
    $uuid = $UMC_USER['uuid'];
    $args = $UMC_USER['args'];
    // make sure user holds item
    $all_inv = $UMC_USER['inv'];
    if (!$all) {
        $item_slot = $UMC_USER['current_item'];
        if (!isset($all_inv[$item_slot])) {
            umc_error("{red}You need to hold the item you want to deposit! (current slot: {$item_slot});");
        }
        $all_inv = array($item_slot => $all_inv[$item_slot]);
    }
    $sent_out_of_space_msg = 0;
    $seen = array();
    foreach ($all_inv as $slot) {
        $item_id = $slot['item_name'];
        if (!isset($UMC_DATA[$item_id])) {
            XMPP_ERROR_trigger("Invalid item deposit cancelled!");
            umc_error("Sorry, the item in your inventory is bugged, uncovery was notfied and this should be fixed soon. IF you want to speed it up, please send a ticket with as much detail as possible.");
        }
        $data = $slot['data'];
        if ($slot['meta']) {
            $meta = serialize($slot['meta']);
        } else {
            $meta = false;
        }
        // don't assign the same twice
        $item = umc_goods_get_text($slot['item_name'], $slot['data'], $slot['meta']);
        if (isset($seen[$item['full']])) {
            continue;
        }
        $inv = umc_check_inventory($slot['item_name'], $slot['data'], $slot['meta']);
        if ($inv == 0) {
            XMPP_ERROR_trigger("Item held could not be found in inventory: {$slot['item_name']}, {$slot['data']}, " . var_export($slot['meta'], true));
            umc_error("There was a system error. The admin has been notified. Deposit aborted.");
        }
        if (isset($args[2]) && $args[2] != 'lot_reset') {
            $recipient = umc_sanitize_input($args[2], 'player');
            $recipient_uuid = umc_user2uuid($recipient);
        } else {
            if (isset($args[2]) && $args[2] == 'lot_reset') {
                $recipient_uuid = 'reset000-lot0-0000-0000-000000000000';
                $recipient = $args[2];
            } else {
                $recipient = $player;
                $recipient_uuid = $uuid;
                if (!$all) {
                    umc_echo("{yellow}[!]{gray} No recipient given. Depositing for {gold}{$player}");
                }
            }
        }
        if (!$all && isset($args[3])) {
            $amount = umc_sanitize_input($args[3], 'amount');
            $amount_str = $amount;
            if ($amount > $inv) {
                umc_echo("{yellow}[!]{gray} You do not have {yellow}{$amount} {green}{$item['full']}{gray}. Depositing {yellow}{$inv}{gray}.");
                $amount = $inv;
                $amount_str = $inv;
            }
        } else {
            $amount = $inv;
            $amount_str = $inv;
        }
        umc_echo("{yellow}[!]{gray} You have {yellow}{$inv}{gray} items in your inventory, depositing {yellow}{$amount}");
        // check if recipient has space
        $userlevel = umc_get_uuid_level($recipient_uuid);
        $allowed = $UMC_SETTING['depositbox_limit'][$userlevel];
        $remaining = umc_depositbox_checkspace($recipient_uuid, $userlevel);
        $count = $allowed - $remaining;
        // umc_echo("Group: $userlevel Allowed: $allowed Remaining $remaining");
        $sql = "SELECT * FROM minecraft_iconomy.deposit\r\n            WHERE item_name='{$item['item_name']}' AND recipient_uuid='{$recipient_uuid}'\r\n            AND damage='{$data}' AND meta='{$meta}' AND sender_uuid='{$uuid}';";
        $D = umc_mysql_fetch_all($sql);
        // create the seen entry so we do not do this again
        $seen[$item['full']] = 1;
        // check first if item already is being sold
        if (count($D) > 0) {
            $row = $D[0];
            umc_echo("{green}[+]{gray} You already have {$item['full']}{gray} in the deposit for {gold}{$recipient}{gray}, adding {yellow}{$amount}{gray}.");
            $sql = "UPDATE minecraft_iconomy.`deposit` SET `amount`=amount+'{$amount}' WHERE `id`={$row['id']} LIMIT 1;";
        } else {
            //check if recipient has space
            if ($count >= $allowed && $player != 'uncovery' && $recipient != 'lot_reset') {
                if (!$sent_out_of_space_msg) {
                    umc_echo("{red}[!] {gold}{$recipient}{gray} does not have any more deposit spaces left " . "(Used {white}{$count} of {$allowed}{gray} available for group {white}{$userlevel}{gray})!");
                    $sent_out_of_space_msg = 1;
                }
                continue;
            }
            // check if recipient is an active user
            $target_active = umc_user_countlots($recipient);
            if ($target_active == 0 && $recipient != 'lot_reset') {
                umc_error("{red}[!] {gold}{$recipient}{gray} is not an active user, so you cannot deposit items for them!");
            }
            // create a new deposit box
            if (strlen($item['item_name']) < 3) {
                XMPP_ERROR_trigger("Error depositing, item name too short!");
                umc_error("There was an error with the deposit. Please send a ticket to the admin so this can be fixed.");
            }
            $text = "{green}[+]{gray} Depositing {yellow}{$amount_str} {$item['full']}{gray} for {gold}{$recipient}";
            umc_echo($text);
            $sql = "INSERT INTO minecraft_iconomy.`deposit` (`damage` ,`sender_uuid` ,`item_name` ,`recipient_uuid` ,`amount` ,`meta`)\r\n                    VALUES ('{$data}', '{$uuid}', '{$item['item_name']}', '{$recipient_uuid}', '{$amount}', '{$meta}');";
            $count++;
            umc_log("Deposit", "do_deposit", $text);
        }
        umc_mysql_query($sql, true);
        umc_clear_inv($item['item_name'], $data, $amount, $meta);
    }
    if ($recipient == 'lot_reset') {
        $allowed = 'unlimited';
    }
    umc_echo("{green}[+]{gray} You have now used {white}{$count} of {$allowed}{gray} deposit boxes");
}
/**
 * Create a request
 *
 * @global type $UMC_USER
 * @return type
 */
function umc_do_request()
{
    global $UMC_USER;
    $player = $UMC_USER['username'];
    $uuid = $UMC_USER['uuid'];
    $args = $UMC_USER['args'];
    // this returns a item_array already
    $item_check = umc_sanitize_input($args[2], 'item');
    if (!$item_check) {
        umc_error("{red}Unknown item ({yellow}{$args['2']}{red}). Try using {yellow}/search{red} to find names.");
    } else {
        XMPP_ERROR_trace("item_check", $item_check);
        $item = umc_goods_get_text($item_check['item_name'], $item_check['type']);
    }
    $item_name = $item['item_name'];
    $type = $item['type'];
    $meta = '';
    $meta_txt = '';
    $do_check = false;
    $pos = array_search('check', $args);
    if ($pos) {
        $do_check = true;
        array_splice($args, $pos, 1);
    }
    // TODO: This should be checking for the item type instead of assuming 0
    //if ($UMC_ITEMS[$type][0]['avail'] == false) {
    //    umc_error("{red}Sorry, this item (ID $type) is unavailable in the game!",true);
    //}
    $sql = "SELECT * FROM minecraft_iconomy.request\r\n        WHERE item_name='{$item_name}' AND damage='{$type}' AND meta='{$meta}' AND uuid='{$uuid}';";
    $sql_data = umc_mysql_fetch_all($sql);
    if (count($sql_data) == 0) {
        $row = false;
    } else {
        $row = $sql_data[0];
    }
    // buy item at same price, check if exists
    if (!isset($args[3])) {
        if ($row) {
            $price = $row['price'];
        } else {
            umc_error("{red}Since you do not have the same item already in the shop you need to specify a price.;");
        }
    } else {
        $price = umc_sanitize_input($args[3], 'price');
    }
    // check if an argument was given for amount.
    $amount = umc_sanitize_input($args[4], 'amount');
    if ($amount == NULL) {
        // buying 0 amount available is not possible
        umc_error("{red}You need to specify an amount, too!;");
    }
    $cost = $price * $amount;
    // if there is an existing row, recalculate price accordingly
    if ($row) {
        // give money back from the original request
        $refund = $row['amount'] * $row['price'];
        // calculate how much this one + the old item amount would cost
        $new_cost = ($amount + $row['amount']) * $price;
        // do the sum for the balance, can be negative
        $cost = $new_cost - $refund;
    }
    $balance = umc_money_check($uuid);
    if ($balance < $cost) {
        umc_error("{red}[!]{gray} Insufficient funds ({white}{$cost}{gray} needed). " . "{purple}[?]{white} Why don't you vote for the server and try again?");
    }
    if ($do_check) {
        if ($row) {
            $sum = $amount + $row['amount'];
            umc_echo("{white}[?]{gray} This would update your existing request to " . "{yellow}{$sum} {$item['full']}{darkgray} @ {cyan}{$price}{gray} each.");
        } else {
            umc_echo("{white}[?]{gray} This would create a new request for " . "{yellow}{$amount} {$item['full']}{darkgray} @ {cyan}{$price}{gray} each.");
        }
        if ($cost > 0) {
            umc_echo("{white}[?]{white} Your account would be charged {cyan}{$cost}{gray} Uncs.");
        } else {
            umc_echo("{white}[?]{white} Your account would be credited {cyan}" . $cost * -1 . "{gray} Uncs.");
        }
        return;
    }
    $sum = 0;
    $posted_id = 0;
    if ($row) {
        // Update existing listing
        $sum = $amount + $row['amount'];
        umc_echo("{green}[+]{gray} You already requested {yellow}" . "{$row['amount']} {$item['full']}{gray}. Adding another {yellow}{$amount}{gray}.");
        $sql = "UPDATE minecraft_iconomy.`request` SET `amount` = amount + '{$amount}', price='{$price}' WHERE id={$row['id']};";
        $rst = umc_mysql_query($sql);
        $posted_id = $row['id'];
    } else {
        // Create a new listing.
        $sum = $amount;
        umc_echo("{green}[+]{gray} You are now requesting {yellow}" . "{$sum} {$item['full']}{gray} in the shop.");
        $sql = "INSERT INTO minecraft_iconomy.`request` (`id` ,`damage` ,`uuid` ,`item_name` ,`price` ,`amount` ,`meta`)\r\n                VALUES (NULL , '{$type}', '{$uuid}', '{$item['item_name']}', '{$price}', '{$amount}', '{$meta}');";
        //XMPP_ERROR_trigger($sql);
        $rst = umc_mysql_query($sql);
        $posted_id = umc_mysql_insert_id();
    }
    if ($cost > 0) {
        umc_echo("{yellow}[\$]{white} Your account has been charged {cyan}{$cost}{gray} Uncs.");
    } else {
        umc_echo("{green}[\$]{white} Your account has been credited {cyan}" . $cost * -1 . "{gray} Uncs.");
    }
    umc_money($player, false, $cost);
    umc_announce("{gold}{$player}{gray} is {red}requesting to buy {yellow}{$sum}{$meta_txt}{green} " . "{$item['full']}{darkgray} @ {cyan}{$price}{gray} each{darkgray}, shop-id {gray}{$posted_id}");
}