Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- save as inc/modules/dice.php
- paste the text below into it, all of it, and then call it using the email field of: #dice25d6
- that will roll 25 dice, each dice having six sides,
- it can be anything!
- #dice100d23 will roll 100 dice, each with 23 sides!
- paste below here into dice.php
- <?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 = 'dice';
- $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
- $result = 0;
- $count = 0;
- while ($dices != $count) {
- $value = mt_rand(1, $faces);
- $result = $result + $value;
- $count++;
- }
- $message = "<br><b style=\"border-style: solid; margin:0 3px; border-width: 2px; color: rgb(48, 115, 237); background: none repeat scroll 0% 0% rgb(0, 0, 0); padding: 0px;\"> Rolled $dices dice with $faces faces: $result </b></div><br>";
- $post['message'] .= '<span style="color: red; background-color: black;"> </span> ' . $message . '<br><br>' .
- $post['email'] = '';
- $post['email_save'] = false;
- return $post;
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment