Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function dice_init() {
- global $hooks;
- $hooks['posting'][] = 'dice';
- }
- function dice_authorized($board) {
- return true;
- }
- function dice_info() {
- $info = array();
- $info['type']['board-specific'] = false;
- return $info;
- }
- function dice_settings() {
- $settings = array();
- }
- function dice_help() {
- $output = '#dice8d5: roles 8,5 sided dice';
- return $output;
- }
- function dice_process_posting($post) {
- $magicWord = '#';
- $activationFieldText = $post['email'];
- $trigger = '/^#' . $magicWord . '([0-9]+)d([0-9]+)##$/';
- preg_match_all($trigger, $activationFieldText, $regs);
- if ($regs[0] == null) {
- return $post;
- }
- $faces = $regs[2][0]; // Number of faces of the dice
- $dices = $regs[1][0]; // Number of dices
- $d = 'd';
- $result = 0;
- $count = 0;
- while ($dices != $count) {
- $value = mt_rand(1, $faces);
- $result = $result + $value;
- $count++;
- }
- $message = "<br><b>$dices$d$faces Результат: $result </b></div><br>";
- $post['message'] .= '<span class="dice">' . $message . '</span>' .
- $post['email'] = '';
- $post['email_save'] = false;
- return $post;
- }
- ?>
Add Comment
Please, Sign In to add comment