function umc_vanity_set() { global $UMC_USER; $player = $UMC_USER['username']; $args = $UMC_USER['args']; $userlevel = umc_get_userlevel($player); // umc_echo("$userlevel"); if (!isset($args[2]) || !is_numeric($args[2]) || $args[2] < 1) { umc_error("{red}You need to specify a number of days"); } else { if (!isset($args[3])) { umc_error("{red}You need to specify the title you want to have. See {yellow}/helpme vanity"); } } $days = $args[2]; $vanity_raw = ''; // concatenate all into a string for ($i = 3; $i < count($args); $i++) { $vanity_raw .= " " . $args[$i]; } $vanity = trim($vanity_raw); $donator_str = ''; if (strstr($userlevel, 'DonatorPlus')) { $donator_str = '&6++&f'; } else { if (strstr($userlevel, 'Donator')) { $donator_str = '&6+&f'; } else { if ($userlevel == 'Owner') { $donator_str = '&6++&f'; } } } $final_title = ' [' . $vanity . '&f]'; // check for invalid chars umc_vanity_sanitize($vanity); $quote_array = umc_vanity_quote_title($vanity); $total_cost = $quote_array['cost'] * $days; $balance = umc_money_check($player); if ($quote_array['length'] > 20) { umc_error("Your title is too long ({$quote_array['length']} vs. 20 max!"); } if ($total_cost > $balance) { umc_error("You do not have enough money to pay for this title for {$days} days. You need {$total_cost} but have only {$balance}!"); } // check if there is a title already set $check = umc_vanity_get_title(); if ($final_title == $check . $donator_str) { umc_header("Vanity Title"); umc_echo("The same title is already set and will be extended by {$days} days!"); } else { if ($check && $final_title != $check . $donator_str) { umc_error("You have a different title already set. You need to cancel that one first or set the same one to extend it!"); } else { // no title set yet $uuid = umc_user2uuid($player); umc_header("Vanity Title"); umc_echo("No title yet set, setting new one..."); umc_exec_command("pex user {$uuid} suffix \"{$final_title}{$donator_str}\"", 'asConsole'); } } // set timer umc_money($player, false, $total_cost); umc_timer_set($player, 'custom_title', $days); $date_out = umc_timer_get($player, 'custom_title'); $time_out = $date_out->format('Y-m-d H:i:s'); $date_today = umc_datetime(); $interval = $date_today->diff($date_out); $days_interval = $interval->days; $hours_interval = $interval->h; umc_echo("Your title [{$vanity}{white}] will expire on {$time_out} (in {$days_interval} days and {$hours_interval} hours)!"); umc_echo("Your account has been debited {$total_cost}!"); umc_log('vanity', 'set', "{$player} paid {$total_cost} for {$vanity} for {$days} days"); umc_footer(true); }
function umc_timer_cancel($user, $type) { $existing_timer = umc_timer_get($user, $type); if ($existing_timer) { $sql = "DELETE FROM minecraft_srvr.timers WHERE username='******' AND type='{$type}';"; umc_mysql_query($sql, true); umc_log('timer', 'cancel', "{$type} timer for {$user}"); return $existing_timer; } else { return false; } }