Go Back   vb.org Archive > Community Discussions > Modification Requests/Questions (Unpaid)
  #1  
Old 04-08-2006, 06:48 AM
OrangeFlea OrangeFlea is offline
 
Join Date: Aug 2004
Posts: 208
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Still waiting: DICE HACK

There have been requests made for this one, but no brave coder has taken up the call.

There is a dice hack available for 3.5 but it is far too limited. I, along with some other people, were hoping for a dice hack that could roll up to (perhaps beyond) a 20-sided die.

For example:

[DICE]2d20[/DICE] ------> Two 20-sided dice (e.g. first die = 16; second die = 12)

[DICE]4d6[/DICE] -------> Four 6-sided dice (e.g., first die = 2; second die = 1; third die = 6; fourth die = 4)

This would be an excellent tool for games and for contests (random drawings, etc.)

If conditions need to be made, I'm willing to hear them out (PM me). Come on, let's get this thing going --- there's a demand for it.



************************************************** *******



Here's the dice code portion of the functions_bbcodeparse file that was originally in my Vbulletin 3.0.3, now no longer working for 3.5.4. Someone should be able to convert this into 3.5.4 format


Code:
	// [DICE]
	$bbcodes['custom']['find']['[dice]'] = '#\[dice\](<br>|<br />|\r\n|\n|\r)??(.*)(<br>|<br />|\r\n|\n|\r)??\[/dice\]#esiU';
	$bbcodes['custom']['replace']['[dice]'] = "handle_bbcode_dice('\\2')";
	$bbcodes['custom']['recurse']['dice'][0] = array('handler' => 'handle_bbcode_dice');

// fastjack
function handle_bbcode_dice($msg){
global $_SERVER;

	$d = explode(" ",$msg);
	foreach($d as $e){
		$r .= "<b>Request</b>: $e<br>";
		$r .= "<b>Result</b>: ";
		$e = strtolower($e);
		$e = trim($e);
		$e = str_replace("(","",$e);
		$e = str_replace(")","",$e);
		$e = str_replace("[","",$e);
		$e = str_replace("]","",$e);
		$e = str_replace("/","",$e);
		$e = str_replace("*","",$e);
		$e = explode("d",$e);
		unset($add);
		if(strpos($e[1],'+') !== false ){
			list($e[1], $e[2]) = explode("+",$e[1]);
			$add = 1;
		}
		if(strpos($e[1],'-') !== false ){
			list($e[1], $e[2]) = explode("-",$e[1]);
			$add = 2;
		}
		$f = 0;
		unset($error);
		if($e[1] != 2 && $e[1] != 3 && $e[1] != 4 && $e[1] != 6 && $e[1] != 8 && $e[1] != 10 && $e[1] != 12 && $e[1] != 20 && $e[1] != 100 && $e[1] != 1000  ){
			$r .= "You may only roll a 2, 4, 6, 8, 10, 12, 20, 100, or 1000-sided die. Please roll again";
			$e[1] = 100;
			$error = 1;
		}
		if(($e[0] > 100 || strlen($e[0]) > 3) && $error != 1){
			$r .= "We just support 100 dices each time. ";
			$e[0] = 1;
			$error =1;
		}
		if($add && (!is_numeric($e[2]) || $e[2] > 1000)){
			$r .= "You can just add or subtract numbers smaller than 1000.";
			$e[2] = 1;
			$error =1;
		}
		unset($g);
		if($error !=1){
		while($f != $e[0]){
			$g[] = rand(1,$e[1]);
			$r .= $g[$f].". ";
			$f++;
		}
		$r .= "<b>Total</b>: ".array_sum($g);
		if($add == 1){
			$t = (array_sum($g) + $e[2]);
			$r .= "+ ".$e[2]." = $t";
		}
		if($add == 2){
			$t = array_sum($g) - $e[2];
			$r .= "- ".$e[2]." = $t";
		}

		}
		$r .="<br>";
		
	}

//	$msg = $m[0].strstr($msg,'[/dice]');
//	$msg = str_replace('[/dice]','',$msg);

	$result[] = $msg;
	$result[] = $r;
	if($_SERVER['SCRIPT_NAME'] == "/forum/newreply.php")
		$r = "You cant have dice Preview";
	if($_SERVER['SCRIPT_NAME'] == "/forum/newthread.php")
		$r = "You cant have dice preview";
	$return = '<br><div class="smallfont" style="margin-bottom:2px"><img src=dice.gif> Diceroll:</div>
<table cellpadding="2" cellspacing="0" border="0">
<tr>
<td class="alt2" style="border:1px inset">
<div style="font-style:italic">'.$r.'</div>
</td>
</tr>
</table><br>';
	return $return;
Reply With Quote
  #2  
Old 04-24-2006, 05:45 PM
Rukbat Rukbat is offline
 
Join Date: Feb 2006
Location: Mississippi Gulf Coast
Posts: 47
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

*shameless bump*
I'd love to have a dice roller, tho my board uses 100 sided dice... right now we're having to roll in an AIM chat with at least 2 in the chat and then copy and paste it into a post. ugh. specially since not too many of my members have AIM or refuse to use it cause of all the 'nasties' it has.

well actually we use different # of sides per situation... could be anywhere from 2 to 100. tho for the higher numbers we *could* use more than one die, but that only works if it's an even number we're using... wouldn't work for say 37 , would have to be a single die with 37 sides....
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 12:08 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.07461 seconds
  • Memory Usage 2,166KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)bbcode_code
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (2)post_thanks_box
  • (2)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (2)post_thanks_postbit_info
  • (2)postbit
  • (2)postbit_onlinestatus
  • (2)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete