Go Back   vb.org Archive > vBulletin Modifications > Archive > vB.org Archives > vBulletin 3.5 > vBulletin 3.5 Add-ons
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools
Dice Roller Hack [BBCode] Details »»
Dice Roller Hack [BBCode]
Version: 1.00, by Eikinskjaldi Eikinskjaldi is offline
Developer Last Online: Jul 2023 Show Printable Version Email this Page

Version: 3.5.4 Rating:
Released: 04-24-2006 Last Update: 05-29-2006 Installs: 51
DB Changes Uses Plugins Template Edits
Additional Files  
No support by the author.

Dice Roller Hack [BBCode]
RPG Dice is currently a updated version
Another updated version

Note: Updated package includes only the correct XML.

This hack is a port of: Dice Roll for vB3 and permissions was given to port by the following statement.

Quote:
Info for hackers:
You may modify, improve, upgrade, redistribute this hack, include it
in another hack or yours or translate it provided you do it free of
charge and you distribute it in www.vbulletin.org at least, there is no
need to pm me asking for permission.
This hack rolls a Graphic based dice roll in your post and features multiple dice rolls per post. The images are fully editable by those who know how and I must agree that I very much think they need an overhaul, so go for it.

The basic bbcode format is:
[dice=X]Y[/dice]

X - The number of dice to roll, This cannot be larger then 5 currently, this may change later with demand.
Y - The number of sides on the dice.

so [dice=1]6[/dice] Roll's 1, 6 sided dice.

The only limit that I have noticed so far is that dice will not apear correctly when rolled from the create thread editor. I am unsure as to why this is still and am working on this issue. However aside from this it is working as need be. This hack is mainly useful to Game websites that require dice rollers for gambling or roleplaying games. It can add an element of fun to a forum and is adapatable to most dice require situations.

If enough demand is displayed I will work on removing the 5 roll limit or making it larger. The current maximum sides one can roll is 30.

If you enjoy this hack or have it installed, then please click the install button so that you can remain informed when updates occur.

As the original author said, You do not need to ask permission to update or do anything to this hack and can redistribute it if you feel you have made a great contribution to it.

If someone does make new dice images and wishes to have them as part of the package then either post here or PM me and I will get them in there with full rights going to the sender for the images.

Updates:
  • 04/29/06
    • Added new dice images which where provided by Rukbat.

This hack was requested from: https://vborg.vbsupport.ru/showthread.php?t=97775

-Eikinskjaldi-

Original Screenshots:
https://vborg.vbsupport.ru/attachmen...3&d=1078098688
https://vborg.vbsupport.ru/attachmen...4&d=1078098702

Show Your Support

  • This modification may not be copied, reproduced or published elsewhere without author's permission.

Comments
  #52  
Old 05-26-2006, 01:03 PM
Eq4bits Eq4bits is offline
 
Join Date: May 2006
Posts: 468
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Zowners
I'm still wrestling with the database.

how was ZIKI's problem solved? I don't know where to alter the database and alter it with what.
Do you actually have access to the database? Via something like phpMyAdmin? Where you can 'see' the database and alllll the tables that make it up?

As previously stated on the FIRST page the changes are not being made to the database when you install/import this product. You'll have to ALTER the
***_thread & ***_post yourself. Do the following:
  • ALTER the ****_thread table by ADDING a field named 'dice' the field should be MEDIUM TEXT and set at NOT NULL;
  • ALTER the ****_post table by ADDING a field named 'dice', athe field should be MEDIUMTEXT and set at NOT NULL;
Since I don't know what you named your database table prefixes I inserted asterisks prior to the _thread & _post table names. The attached images are screenshots showing the ****_post table of a database and indicatingwith the 'dice' field already added (image1a.png) , and an image (image1.png) is showing the properties of the dice field... which can be edited, dropped altogether or whatever. If you need help adding a field to the database I suggest reading over the help file for phpmyAdmin.
Reply With Quote
  #53  
Old 05-26-2006, 01:18 PM
Eq4bits Eq4bits is offline
 
Join Date: May 2006
Posts: 468
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

also, as Eiikenskjaldi stated above he ported this product from it's original (written by someone else) that was for ver 3.0 so that it could be used for ver. 3.5.x the xml file
to add a button as Emma2 suggested would require more than this simple xml file/product. There is a hack somewhere for adding additional bbcode buttons to the editor. This is just a simple and easy way to be able to roll dice by typing the bbcode for it, just like adding an img tag or url tag when typing a post, it's NOT really that hard to type [dice=1]100[/dice] is it? Having 20 buttons for different dice rolls on the WYSIWYG editor could get a bit crowded anyway, don't you think? IF you were ONLY using, for your board a SINGLE predetermined number of die with a predetermined number of faces (i.e. only able to roll x number of die that have z number of faces) yes a button would be the thing to go with, but that wasn't the purpose of this hack.. You can always put a request for someone to write a hack that does this in the request forum, or pay someone to do it. I don't have all the know how to.
Reply With Quote
  #54  
Old 05-26-2006, 01:49 PM
Eq4bits Eq4bits is offline
 
Join Date: May 2006
Posts: 468
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Zowners
Where was the database with this code? I assume it's not one of the dice hack databases because I couldn't find them. Found the other two but not the above code
Zowner,
That is in the actual xml file and has to be changed prior to importing.

wherever you saved the xml file on your computer, open it using notepad or wordpad.. some type of equivalent editor. Then use 'Find' to seach and located the code, then change it
EDIT: hit submit too soon :eeps:
Then save the file and reimport, be sure to check 'Yes' to overwrite for the import process.
EDIT: :eeps: i must need more coffee i totally read and replied wrong, have fixed my reply now tho
ignore the attached image it has nothing to do with the section of code Zowner was asking about.
Edit: I definiately need more coffee or another brain... the image attached DOES have everything to do with this
all that code change in the xml file was change the 'wording' above the pics of the dice in the post
'dices' was not correct you would use either 'die' or 'dice' and it bugged me seeing 'dices' made me want to grab a knife and an onion...
Reply With Quote
  #55  
Old 05-26-2006, 03:08 PM
Eq4bits Eq4bits is offline
 
Join Date: May 2006
Posts: 468
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by soravok
How long do you think it will be before there is a solid/stable version of this dice roller I like it a lot just a few too many minor bugs with it for the time being.
I'm putting in a 'code' section below a copy of the XML file I use on my board (please note '***' that is in front of '_thread' and '_post' should be the PREFIX all the tables in your database have)... except for making the alterations to the table this hack works FINE.

The changes I (as Rukbat at the time) made were for customizing it for MY board/forum (using up to 9 dice with up to 100 faces), and also changing the 'Dice roll with x dices of ** faces: *** points' phrase to 'Dice roll with x dice of ** faces: *** points' because 'dices' is not the plural and it bugged me.

So now....
################### INSTALL INSTRUCTIONS ################
1. Access the database you use for your forum
  • open the ***_thread table
    • ADD a field - make the field name 'dice' set it's properties to: 'mediumtext' and 'not null'
  • open the ***_post table
    • ADD a field - make the field name 'dice' set it's properties to: 'mediumtext' and 'not null'
2. Upload the images to ./images/dice in your main forum directory, you will need to create the dice folder. (the ZIP file attached below is Blue Dice 1-100.. you will have to download the zip file, extract it and upload all the images in it to the dice folder you created)

4. Copy and paste the below code into notepad (or other xml editor), change the '***' prefix for the tables to the prefix YOUR database has for all it's tables, then SAVE it as: Eikin-DiceRoller-1_0.xml (in notepad 'save' box be sure to have the file type set to 'all files' NOT as TEXT/TXT and the encoding as ANSI):
Code:
<?xml version="1.0" encoding="ISO-8859-1"?>
<product productid="dice" active="1">
 <title>Dice Roller</title>
 <description>Rolls dice in postbit</description>
 <version>1.0</version>
 <codes>
  <code version="1.0">
   <installcode>ALTER TABLE `***_thread` ADD `dice` MEDIUMTEXT NOT NULL ;
ALTER TABLE '***_post' ADD 'dice' MEDIUMTEXT NOT NULL ;</installcode>
   <uninstallcode />
  </code>
 </codes>
 <templates>
  <template name="dice" templatetype="template" date="1145915902" username="admin" version="3.5.4"><![CDATA[<img src="images/dice/$point.gif" width="76" height="80" />]]></template>
  <template name="postbit_dice" templatetype="template" date="1145915990" username="admin" version="3.5.4"><![CDATA[<table border="0" align="center" width="90%" cellpadding="3" cellspacing="1">
<tr>
  <td><smallfont><b>Dice roll with $dicesno dice of $dicesfaces faces: $dicepoints points</b></smallfont></td>
</tr>
<tr>
  <td style="BORDER: #000000 1px solid; FONT-SIZE: 11px; COLOR: #000000; BACKGROUND-COLOR: #D7D7D7;">
$dicedata
</td>
</tr>
</table><br/>]]></template>
 </templates>
 <plugins>
  <plugin active="1">
   <title>dice_process_data</title>
   <hookname>newpost_process</hookname>
   <phpcode><![CDATA[// Hack
                if (@eregi("\[dice",$post['message']))
                {
                        $diceresult = array();
                        preg_match_all("/\[dice=([1-9])\]([0-9]?[0-9]?[0-9])\[\/dice\]/",$post['message'],$diceresult);
 
                        $dices = $diceresult[1];
                        $faces = $diceresult[2];
                        $dicedetail = array();
                        $rollcount = count($dices);
 
                        $validdice = 0;
                        for ($i = 0; $i < $rollcount; $i++)
                        {
                                if ($faces[$i] >= 2 && $faces[$i] <= 100)
                                {
                                        $diceresult[0][$i] = str_replace("[","\[",$diceresult[0][$i]);
                                        $diceresult[0][$i] = str_replace("]","\]",$diceresult[0][$i]);
                                        $diceresult[0][$i] = str_replace("/","\/",$diceresult[0][$i]);                                                
                                        $post['message'] = preg_replace("/".$diceresult[0][$i]."/","[dice".($validdice)."]",$post['message'],1);
 
                                        $dicedetail[$validdice]['dices'] = $dices[$i];
                                        $dicedetail[$validdice]['faces'] = $faces[$i];
                                        $dicedetail[$validdice]['data'] = array();
                                        for ($j = 0; $j < $dices[$i]; $j++)
                                        {
                                                $dicedetail[$validdice]['data'][] = rand(1,$faces[$i]);         
                                        }
                                        $validdice++;
                                }
                        }
 
                        if (!empty($dicedetail))
                        {
                                   $dataman->set('dice',serialize($dicedetail));
                        }
                }
                // End Hack]]></phpcode>
  </plugin>
  <plugin active="1">
   <title>dice_postbit_convert</title>
   <hookname>postbit_display_complete</hookname>
   <phpcode><![CDATA[// Hack: dice
 if ($post['dice'])
        {
         $dicearray = unserialize($post['dice']);
  $totalroll = count($dicearray);
 
  for ($i = 0; $i < $totalroll; $i++)
                {
   $dicedata = "";                
                 $dicepoints = 0;
                 $dicesno = $dicearray[$i]['dices'];
                 $dicesfaces = $dicearray[$i]['faces'];
 
                 foreach ($dicearray[$i]['data'] as $point)
                 {
                         eval('$dicedata .= "' . fetch_template("dice") . '";');
                         $dicepoints += $point;                  
                 }
                 eval('$dice = "' . fetch_template("postbit_dice") . '";');
                 $post['message'] = preg_replace("/\[dice$i\]/i","$dice",$post['message']);
                }
        }]]></phpcode>
  </plugin>
  <plugin active="1">
   <title>dice_set_valid_fields</title>
   <hookname>postdata_start</hookname>
   <phpcode><![CDATA[$this->validfields['dice'] = array(TYPE_STR, REQ_NO);]]></phpcode>
  </plugin>
  <plugin active="1">
   <title>dice_set_valid_fields_new_thread</title>
   <hookname>threadfpdata_start</hookname>
   <phpcode><![CDATA[$this->validfields['dice'] = array(TYPE_STR, REQ_NO);]]></phpcode>
  </plugin>
 </plugins>
 <phrases>
 </phrases>
 <options>
 </options>
</product>
3. Go into ACP and upload the XML through the product manager. BE SURE TO CHECK-OFF 'YES' for OVERWRITE.

4. Go to a forum and test the formatting (described below).

################# FORMATTING INFORMATION ################
To roll a dice use the following tag,
[dice=X]Y[/dice]
X - The number of dice to roll (This cannot be larger than 9 currently, I'm not a coding whiz and not sure how to fix this but I AM looking into it.)
Y - The number of sides on the dice (This cannot be larger than 100 currently, mainly because I don't feel like making more dice, but if YOU do feel free, just find in the xml file (again using notepadchange the ) the following
Code:
if ($faces[$i] >= 2 && $faces[$i] <= 100)
and change the '100' to however many you need it/want it to be, provided you have dice images up to and including that number.

so [dice=1]6[/dice] Roll's 1, 6 sided dice.

NOTE: Currently you CANNOT make a dice roll in the first post of a new thread, only in reply posts. I'm not a coding-whiz so I don't know how to fix it, but I'll try looking into it in the next couple of days and post another reply here.

The hack isn't buggy except for the table altering, as long as you go in and make those changes to the 2 tables yourself via phpMyAdmin (or whatever) it works fine.
Reply With Quote
  #56  
Old 05-26-2006, 03:15 PM
Eq4bits Eq4bits is offline
 
Join Date: May 2006
Posts: 468
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Emmy2
nice hack!

Is is possible to create a bbcode within a bbcode? Example, if I want to create a bb code called "roll" (and an accompanying button for it), and I want it to automatically roll 5 dice with 1-6 options, how can I do that? Theoretically this is what I want:

my member would type (or hit the roll button and get this): [roll][/roll]

but the code would execute as: [roll][dice=5]6[/dice][/roll]


Anyway to do that? The reason is...my members are low tech and having them input all the variables is too complex. Just want a simple roll button that they can click and it's all set up for them. Can do?
I'll look into this when I have time, but I'm not guaranteeing anything, so you essentially want a button for the WYSISYG editor that has the word 'Roll' on it (that's an image thing) that will ALWAYS roll the same number of die with the same number of faces, correct?
Reply With Quote
  #57  
Old 05-26-2006, 03:16 PM
cclaerhout's Avatar
cclaerhout cclaerhout is offline
 
Join Date: Aug 2004
Location: Paris (France)
Posts: 448
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I think the sql problem shoud be fixed with this new product file.

I'm still thinking the idea suggested above would be great. If each time you want to play dice you have to type the code, members are going to be upset. I'm going to look if i can do it. Anyway we can ask Michelle, the hacker of e-steki Smilie Maker 1.7 to help us


Edit : file removed because update on next page.
Reply With Quote
  #58  
Old 05-26-2006, 03:18 PM
cclaerhout's Avatar
cclaerhout cclaerhout is offline
 
Join Date: Aug 2004
Location: Paris (France)
Posts: 448
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Eq4bits
I'll look into this when I have time, but I'm not guaranteeing anything, so you essentially want a button for the WYSISYG editor that has the word 'Roll' on it (that's an image thing) that will ALWAYS roll the same number of die with the same number of faces, correct?
My idea would be to create a collaspe menu with several choice of dice. Each time you click on of the icon, the bbcode will be insert in the message.
Reply With Quote
  #59  
Old 05-26-2006, 03:38 PM
BeaLzeBuB's Avatar
BeaLzeBuB BeaLzeBuB is offline
 
Join Date: Mar 2006
Location: Turkey
Posts: 112
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

it doesn't show the dices.I imported it and it doesn't show the dices there is only [dice=1]6[/dice]
Reply With Quote
  #60  
Old 05-26-2006, 03:58 PM
Eq4bits Eq4bits is offline
 
Join Date: May 2006
Posts: 468
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by cclaerhout
My idea would be to create a collaspe menu with several choice of dice. Each time you click on of the icon, the bbcode will be insert in the message.
That's a bit more complicated than my limited knowledge allows for, perhaps one of the 'whizzy' coders here could assist... if any are reading this thread....
Reply With Quote
  #61  
Old 05-26-2006, 04:18 PM
Eq4bits Eq4bits is offline
 
Join Date: May 2006
Posts: 468
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by cclaerhout
I think the sql problem shoud be fixed with this new product file.

I'm still thinking the idea suggested above would be great. If each time you want to play dice you have to type the code, members are going to be upset. I'm going to look if i can do it. Anyway we can ask Michelle, the hacker of e-steki Smilie Maker 1.7 to help us
I haven't had any problems with my users getting upset, they are just thrilled that they can roll dice and haven't had a problem rolling them... i posted instruction on how to do the bbcode and so far no problems... i made a thread for them to 'practice' on, lol

That would be great if Michelle could help, bribe her maybe???? lol

Looking at the xml version you attached it 'looks' like the code for altering the two tables should work (I was just looking at that part of the code and fixing to try to fix it... thanks for saving me the trouble), anyone try it yet?
A note tho... the 'dices' word is still there instead of 'die' or 'dice' so that would need to be changed if anyone else is as anal about that as I am
Another note your's is only for up to 5 dices of 30 faces each.

So anyone needing up to 9 dice would need to change
Code:
preg_match_all("/\[dice=([1-5])\]([0-9]?[0-9])\[\/dice\]/",$post['message'],$diceresult);
TO
Code:
preg_match_all("/\[dice=([1-9])\]([0-9]?[0-9]?[0-9])\[\/dice\]/",$post['message'],$diceresult);
and anyone wanting/needing more than 30 faces would need to change the '30' in
Code:
if ($faces[$i] >= 2 && $faces[$i] <= 30)
to the number of faces they choose (as long as they have images of dice up to and including the number they choose)
Reply With Quote
Reply


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 02:00 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.06041 seconds
  • Memory Usage 2,344KB
  • Queries Executed 25 (?)
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
  • (5)bbcode_code
  • (8)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_post
  • (1)navbar
  • (6)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (4)pagenav_pagelink
  • (1)pagenav_pagelinkrel
  • (11)post_thanks_box
  • (11)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (11)post_thanks_postbit_info
  • (10)postbit
  • (11)postbit_onlinestatus
  • (11)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
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete