settings['default_rpoints']; if (preg_match('/^\d+,[\d,]*\d+$/', $system)) { // set new custom points as array of ints $points = array_map('intval', explode(',', $system)); $rtn = $aseco->client->query('SetRoundCustomPoints', $points, false); // log console message if (!$rtn) { $aseco->console('Invalid rounds points: {1} Error: {2}', $system, $aseco->client->getErrorMessage()); } else { $aseco->console('Initialize default rounds points: {1}', $system); } } elseif (array_key_exists($system, $rounds_points)) { // set new custom points $rtn = $aseco->client->query('SetRoundCustomPoints', $rounds_points[$system][1], false); // log console message if (!$rtn) { $aseco->console('Invalid rounds points: {1} Error: {2}', $system, $aseco->client->getErrorMessage()); } else { $aseco->console('Initialize default rounds points: {1} - {2}', $rounds_points[$system][0], implode(',', $rounds_points[$system][1])); } } elseif ($system == '') { // disable custom points $rtn = $aseco->client->query('SetRoundCustomPoints', array(), false); } else { $aseco->console('Unknown rounds points: {1}', $system); } } // init_rpoints function admin_rpoints($aseco, $admin, $logtitle, $chattitle, $command) { global $rounds_points; $login = $admin->login; $command = explode(' ', preg_replace('/ +/', ' ', $command)); $system = strtolower($command[0]); if ($command[0] == 'help') { $header = '{#black}/admin rpoints$g sets custom Rounds points:'; $help = array(); $help[] = array('...', '{#black}help', 'Displays this help information'); $help[] = array('...', '{#black}list', 'Displays available points systems'); $help[] = array('...', '{#black}show', 'Shows current points system'); $help[] = array('...', '{#black}xxx', 'Sets custom points system labelled xxx'); $help[] = array('...', '{#black}X,Y,...,Z', 'Sets custom points system with specified values;'); $help[] = array('', '', 'X,Y,...,Z must be decreasing integers and there'); $help[] = array('', '', 'must be at least two values with no spaces'); $help[] = array('...', '{#black}off', 'Disables custom points system'); // display ManiaLink message display_manialink($login, $header, array('Icons64x64_1', 'TrackInfo', -0.01), $help, array(1.05, 0.05, 0.2, 0.8), 'OK'); } elseif ($command[0] == 'list') { $head = 'Currently available Rounds points systems:'; $list = array(); $list[] = array('Label', '{#black}System', '{#black}Distribution'); $lines = 0; $admin->msgs = array(); $admin->msgs[0] = array(1, $head, array(1.3, 0.2, 0.4, 0.7), array('Icons128x32_1', 'RT_Rounds')); foreach ($rounds_points as $tag => $points) { $list[] = array('{#black}' . $tag, $points[0], implode(',', $points[1]) . ',...'); if (++$lines > 14) { $admin->msgs[] = $list; $lines = 0; $list = array(); $list[] = array('Label', '{#black}System', '{#black}Distribution'); } } if (!empty($list)) { $admin->msgs[] = $list; } // display ManiaLink message display_manialink_multi($admin); } elseif ($command[0] == 'show') { // get custom points $aseco->client->query('GetRoundCustomPoints'); $points = $aseco->client->getResponse(); // search for known points system $system = false; foreach ($rounds_points as $rpoints) { if ($points == $rpoints[1]) { $system = $rpoints[0]; break; } } // check for results if (empty($points)) { $message = formatText($aseco->getChatMessage('NO_RPOINTS'), '{#admin}'); } else { if ($system) $message = formatText($aseco->getChatMessage('RPOINTS_NAMED'), '{#admin}', $system, '{#admin}', implode(',', $points)); else $message = formatText($aseco->getChatMessage('RPOINTS_NAMELESS'), '{#admin}', implode(',', $points)); } $aseco->client->query('ChatSendServerMessageToLogin', $aseco->formatColors($message), $login); } elseif ($command[0] == 'off') { // disable custom points $rtn = $aseco->client->query('SetRoundCustomPoints', array(), false); // log console message $aseco->console('{1} [{2}] disabled custom points', $logtitle, $login); // show chat message $message = formatText('{#server}>> {#admin}{1}$z$s {#highlite}{2}$z$s{#admin} disables custom rounds points', $chattitle, $admin->nickname); $aseco->client->query('ChatSendServerMessage', $aseco->formatColors($message)); } elseif (preg_match('/^\d+,[\d,]*\d+$/', $command[0])) { // set new custom points as array of ints $points = array_map('intval', explode(',', $command[0])); $rtn = $aseco->client->query('SetRoundCustomPoints', $points, false); if (!$rtn) { $message = '{#server}> {#error}Invalid point distribution! Error: {#highlite}$i ' . $aseco->client->getErrorMessage(); $aseco->client->query('ChatSendServerMessageToLogin', $aseco->formatColors($message), $login); } else { // log console message $aseco->console('{1} [{2}] set new custom points: {3}', $logtitle, $login, $command[0]); // show chat message $message = formatText('{#server}>> {#admin}{1}$z$s {#highlite}{2}$z$s{#admin} sets custom rounds points: {#highlite}{3},...', $chattitle, $admin->nickname, $command[0]); $aseco->client->query('ChatSendServerMessage', $aseco->formatColors($message)); } } elseif (array_key_exists($system, $rounds_points)) { // set new custom points $rtn = $aseco->client->query('SetRoundCustomPoints', $rounds_points[$system][1], false); if (!$rtn) { trigger_error('[' . $aseco->client->getErrorCode() . '] SetRoundCustomPoints - ' . $aseco->client->getErrorMessage(), E_USER_WARNING); } else { // log console message $aseco->console('{1} [{2}] set new custom points [{3}]', $logtitle, $login, strtoupper($command[0])); // show chat message $message = formatText('{#server}>> {#admin}{1}$z$s {#highlite}{2}$z$s{#admin} sets rounds points to {#highlite}{3}{#admin}: {#highlite}{4},...', $chattitle, $admin->nickname, $rounds_points[$system][0], implode(',', $rounds_points[$system][1])); $aseco->client->query('ChatSendServerMessage', $aseco->formatColors($message)); } } else { $message = '{#server}> {#error}Unknown points system {#highlite}$i ' . strtoupper($command[0]) . '$z$s {#error}!'; $aseco->client->query('ChatSendServerMessageToLogin', $aseco->formatColors($message), $login); } } // admin_rpoints function chat_rpoints($aseco, $command) { global $rounds_points; $login = $command['author']->login; if ($aseco->server->getGame() == 'TMF') { // get custom points $aseco->client->query('GetRoundCustomPoints'); $points = $aseco->client->getResponse(); // search for known points system $system = false; foreach ($rounds_points as $rpoints) { if ($points == $rpoints[1]) { $system = $rpoints[0]; break; } } // check for results if (empty($points)) { $message = formatText($aseco->getChatMessage('NO_RPOINTS'), ''); } else { if ($system) $message = formatText($aseco->getChatMessage('RPOINTS_NAMED'), '', $system, '', implode(',', $points)); else $message = formatText($aseco->getChatMessage('RPOINTS_NAMELESS'), '', implode(',', $points)); } $aseco->client->query('ChatSendServerMessageToLogin', $aseco->formatColors($message), $login); } else { $message = $aseco->getChatMessage('FOREVER_ONLY'); $aseco->client->query('ChatSendServerMessageToLogin', $aseco->formatColors($message), $login); } } // chat_rpoints ?>