vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 3.5 Add-ons (https://vborg.vbsupport.ru/forumdisplay.php?f=113)
-   -   Dice Roller Hack [BBCode] (https://vborg.vbsupport.ru/showthread.php?t=113972)

Campbell 06-25-2006 02:05 AM

Alright, I think I have part of the problem then.

You say above that you did not use RPG dice, but the cclaerhout dice were packaged with RPG Dice in post 117. I believe this is part of my confusion.

What exactly did you install and in what order? If it's working for you it should for me; but the frenetic nature of this thread is confusing.

I have since removed those test threads. But would welcome your input or testing if you wished.

Best,
A

Eq4bits 06-25-2006 02:17 AM

This is the xml file I use (attached) BUT before installing you'll have to uninstall the other AND open the xml file and change the ***_post and ***_thread in the 'Alter Table' parts at the beginning to have the *'s reflect the prefix all your vb tables have.
  • This one is set for up to 9 dice and up to 100 faces,
    it DOES work when starting a thread.
    You do have to actually type the
    Code:

    [dice=#]**[/dice]
    substituting number of dice for '#' and number of faces for '**'.
    Be sure when you import the xml file (after substituting the *'s for table prefixes) that you check the 'allow overwrite' radio button/checkbox

Have been using this on my forum since 4/24 and none of my members have had any problems with just typing the code in... of course I have them trained to be happy with what I give them ;p~

Campbell 06-25-2006 02:24 AM

Understood.

Thank you for your assistance. Any solution that makes my users type code is not a solution for my users. I was attracted to the system because of the interface and display, not just the function alone.

I appreciate your time and effort Eq. You've been kind. I will move my request to the paid forum and work with my existing contractor as well. When I have the solution that's best, I'll share it as open source with the community as I'd suppose the majority of our community owners with games could use this and have it both be functional and pretty.

Best,
A

Eq4bits 06-25-2006 02:29 AM

no problem
perhaps one of the others can help here that use the RPG one.
the RPG one didn't fit with what 'we' needed to do.. as we use multiple faces and *usually* only 1 die at a time. I'd love a nifty little button to use, but it's beyond my capabilities ;) and pocket book as the site is a free one. My members and I were just thrilled to have *any* dice hack that actually worked for 3.5.4 :D

Campbell 06-25-2006 02:36 AM

Totally with you Eq.

We're free at this time as well (hell we're not open yet) but if I'm ever going to go fee based I need the tools and need to spend the cash. I'll do what I can to get this done and share it off.

soravok 06-25-2006 06:05 AM

Quote:

Originally Posted by Eq4bits
no problem
perhaps one of the others can help here that use the RPG one.
the RPG one didn't fit with what 'we' needed to do.. as we use multiple faces and *usually* only 1 die at a time. I'd love a nifty little button to use, but it's beyond my capabilities ;) and pocket book as the site is a free one. My members and I were just thrilled to have *any* dice hack that actually worked for 3.5.4 :D


Same here Eq, much love to you for saving me from being lynched by my members. :banana: :banana: :banana:

Did you see what I posted about marking posts that are edited "fixed" and having the dice rolls from preview to preview be different everytime?

tuxz0r 06-28-2006 11:19 PM

This hack is very similar to something I had done in phpMyChat and wanted to implement on my vBulletin boards to help the Play-by-Post gaming forums. However, I didn't really have a need for displaying cute dice images or limiting myself on the number of rolls or faces. Plus, the dice roller I'm using in my chat uses the standard AdX+B notation where

A = the number of dice to roll (1 if not present)
X = the number of faces on the dice
B = represents a modifier, usually a + or - but also a divides or multiply.

I also need it to do certain things like, only show the sum/result of the roll or show all the die results and the sum of the roll. I also wanted the ability to do open rolls, e.g. if you roll 6, six sided die, you keep rerolling any dice that come up a 6.

So, basically, I have concocted three different bbcodes in one product:

[roll][/roll]
- for rolling and showing only the results or sum
[rollv][/rollv] - for rolling and seeing the result of each dice as well as the sum
[rollo][/rollo] - for open rolls

Each of these takes and optional label for the roll, to be included in the tag after the '=' sign, e.g. [roll=to hit]4d6[/roll] and so forth. It is, however, optional as the actual notation for the roll is displayed before the results in the final posting.

So, for example, you can enter rolls like the following:

[roll]4d6[/roll] to get the sum of 4 six sided die.
[roll]d%[/roll] for a percentage roll (same as 1d100)
[roll]4d6b3[/roll] to roll 4 six sided dice and only sum the "best" three results


I took the current XML file on this hack, made some big changes, adapted my Perl dice roller class to PHP and I've put together a product to allow dice rolling in this fashion. See the attachment.

If you want to see a better description and see some results you can view my forum thread about this enhancement. I don't want to hijack this thread either, so if I need to provide this product via a new thread, someone just let me know. It seemed related enough that I figured I'd add it here first.

There is an INSTALL file in the zip attachment which gives an explanation of the included files and how to install them. If anyone has any questions, just shoot me a PM or I'll check this thread for thoughts.

This is installed and working on vBulletin 3.5.4 on my forums.

Eq4bits 08-03-2006 09:05 PM

okay anyone upgraded to the now available vB 3.6 gold that just became available? will this work with 3.6?

Eikinskjaldi 08-04-2006 07:46 PM

I dont see why it shouldnt, vB3.6 isnt to far off from vB3.5, if anything they'd be simple bugs.

ocitalia 09-12-2006 10:40 AM

how can i add a button in postbid for ONLY [dice=2]6[/dice] ?

JD210 10-01-2006 03:39 PM

I am having the same problem as Campbell, the images are showing up for the user interface, the small dice icons, but when posting all you see is the [dice0][dice1] etc, no images of the dice at all. I have tried several times to get this to work with no luck. Any ideas?

Eq4bits 10-09-2006 06:22 PM

I would suggest pm'ing the person, can't remember who they are, that posted the 'interface' version. Only support I can offer help with is for the 'ORIGINAL' dice hack that is this actual thread...

Eq4bits 10-09-2006 06:23 PM

oh and I haven't had ANY problem with the install of this hack even after upgrading from 3.5.4 to 3.6.2

Olli460 10-13-2006 03:09 AM

Has the dice being rolled from the thread creator glitch been fixed yet?

Eq4bits 10-13-2006 11:35 AM

I can roll dice in the first post of a thread with the one I am using (NOT the fancy schmancy interface one... the one with up to 9 dice and 100 faces)

pewp 11-09-2006 05:16 PM

is there any way to get any of these to work in the shoutbox?

abramelin 12-19-2006 09:13 PM

is this working on 3.6.4?

Eq4bits 12-19-2006 09:35 PM

mine is working fine... not the fancy interface one that is in the middle of this thread somewhere but the original one :D

Renmiri 03-19-2007 01:46 AM

Couldn't get it to work :(

But the good news is that I got it to work as just a bbcode, with no database changes...

https://vborg.vbsupport.ru/showthread.php?t=142475

Of course it is much simpler than the Hack: It doesn't prevent users from editing their posts and changing the dice roll.

PS: Since it is a simple bbcode, it works on the shoutbox too :D

Blackhat 06-23-2007 04:03 PM

When importing the XML I get this error

Quote:

Database error in vBulletin 3.6.7:

Invalid SQL:
ALTER TABLE `thread` ADD `dice` MEDIUMTEXT NOT NULL;

MySQL Error : Table 'xxxx_site.thread' doesn't exist
Error Number : 1146
Date : Saturday, June 23rd 2007 @ 01:00:52 PM
Script : http://www.xxxx/forums/admincp/plugi...=productimport
Referrer : http://www.xxxx/forums/admincp/plugin.php?do=productadd
IP Address : 00.000.000.000
Username : Username
Classname : vb_database

Eq4bits 06-23-2007 09:05 PM

If you have access to your MySQL you can go in and add the 'dice' field to the 'thread' table with the properties of MediumText and Not Null

Blackhat 06-23-2007 10:44 PM

What about fixing the plug-in instead ?

Blackhat 06-24-2007 03:36 PM

Ok,


Im using the RPG dice roll, but when I choose a dice and replies I just get this

Quote:

[dice0]

cclaerhout 06-26-2007 03:27 PM

Well, i've tested my RPG hack on the newest vB version and it works... Try to do it on a new thread.

NolF 08-27-2007 08:29 AM

Awsome hack :O too bad it doesn't work on 3.6.x
I was wondering if anyone could bother to port this to 3.6 :( I had a look at the xml and lits not too long, I would say that the problem is with the instalation code but I don't know.

It would be greatly appreciated if someone could ^^ thx

Eq4bits 08-27-2007 01:40 PM

I installed this way back (not the fancy icon clicking one but the write the bbcode one) several upgrades ago. Running 3.6.7PL right now and having no problem with it. Which one are you trying to use? there are several different versions within this thread.

R1chardYoung 09-03-2007 07:53 AM

Im running 3.6.7 and have no issues - good hack.

vooood 06-02-2008 08:07 AM

I have installed this on vBulletin 3.7.1 and it works perfectly. I used the latest updated version and not the one with buttons and images. How about posting this in the 3.7 Mods forum?

Eq4bits 03-24-2009 03:08 AM

I have had this installed on my 3.8.1PL1 vB now and it still works perfectly (the one without the buttons, but there ARE dice images)

Najoh 09-08-2009 03:28 PM

I have modified the xml and its working on the last version 3.8.4 :

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><![CDATA[$vbulletin->db->query_write("ALTER TABLE `vbulletin_thread` ADD `dice` MEDIUMTEXT NOT NULL");
$vbulletin->db->query_write("ALTER TABLE `vbulletin_post` ADD `dice` mediumtext not null");]]></installcode>
                        <uninstallcode><![CDATA[$vbulletin->db->query_write("ALTER TABLE `thread` DROP COLUMN `dice`");
$vbulletin->db->query_write("ALTER TABLE `vbulletin_post` DROP COLUMN `dice` ");]]></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="63" height="62" />]]></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 dices 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-5])\]([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] <= 30)
                                {
                                        $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>


Najoh 09-13-2009 11:30 AM

How to sort the results after a dice roll in a topic ?

DL_Ashe 02-02-2010 08:55 AM

Has anyone managed to (or would be able to) get tuxz0r's diceroller working on vb4.0.1? My only dilemma ever since I upgraded... is I can't finding a working diceroller anymore for my forums. :erm:

tuxz0r's just bombs out when I try to import it, stating that the vbulletin_thread table no longer exists. I'm guessing it's an issue with differentiating tables b/w vb3 and vb4.. maybe?

Eq4bits 02-02-2010 03:11 PM

I was hoping this would be updated to work with vB4 as well. I miss my dice!
You could *try* going into phpMyAdmin and creating the table yourself, but I doubt the product would work anyway since vB code and phrases and such has changed so much from 3.x versions. :((

Schmidtrock 04-15-2010 04:12 PM

Working in 3.8.5 thanks !

mahz 06-16-2010 07:28 AM

Quote:

Originally Posted by DL_Ashe (Post 1972887)
Has anyone managed to (or would be able to) get tuxz0r's diceroller working on vb4.0.1? My only dilemma ever since I upgraded... is I can't finding a working diceroller anymore for my forums. :erm:

tuxz0r's just bombs out when I try to import it, stating that the vbulletin_thread table no longer exists. I'm guessing it's an issue with differentiating tables b/w vb3 and vb4.. maybe?

Just installed Tuxz0r's lovely hack and works like a charm on vB 3.8.5 EXCEPT for the first post of the thread. Looking at a post on the other page of this thread, it appears some other people have the same problem.

Can anyone resolve this?

mahz 06-16-2010 07:53 PM

Here's a demo of Tuxz0r's BBCode dice: http://roleplayerguild.com/f3/new-dice-system-52860/. I wanted to contact him but his website isn't online anymore.

I chose it because the AdX+B notation is more useful for play-by-post roleplaying. I also like the minimalism of just text output.

To make the dice rolls stand out though, I added some left padding to the roll so I could stick a dice image in there as a background.

Screenshot:
https://vborg.vbsupport.ru/external/2010/06/52.jpg

Simple line of CSS:
HTML Code:

.diceroll {
padding-left: 20px;
background: url('http://IMAGE-URL.gif') no-repeat;
}

I just took a dice image off Google, shrunk it, and changed the background. Here's the image on a white bg:
https://vborg.vbsupport.ru/external/2010/06/8.gif

You'll need to shrink it more to fully display inline with the text of the dice roll unless you add
HTML Code:

display: block;
height: 23px;

to the CSS i provided above.

The BBCode still doesn't work in the initial post of a thread, unfortunately. My understanding of vBulletin coding is very limited but I'll try to fix it. I know the guys working on the original hack in this thread fixed theirs, so I'll see if I can cross compare the hacks and see what I can change.

Thanks for everyone's contributions to this thread. I enjoyed reading yall's collaboration. :)

Here's a link to Tuxz0r's hack: https://vborg.vbsupport.ru/showpost....&postcount=167

Freeze1992 02-10-2011 04:41 PM

I installed the rpg dice mod and put the dice folder on the ftp in de image folder
but i get this error i guese im just stupid but what to do
Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: dice_menu in [path]/includes/functions.php on line 4055

ravenscape 02-03-2013 07:56 PM

The product didn't install any bbcodes. I tried the original and TuxZor's version. What's the replacement text supposed to be?

AramisErak 04-12-2013 06:05 AM

Quote:

Originally Posted by tuxz0r (Post 1017963)
This hack is very similar to something I had done in phpMyChat and wanted to implement on my vBulletin boards to help the Play-by-Post gaming forums. However, I didn't really have a need for displaying cute dice images or limiting myself on the number of rolls or faces. Plus, the dice roller I'm using in my chat uses the standard AdX+B notation where

This is installed and working on vBulletin 3.5.4 on my forums.

Installed on 3.8.4, works fine, except for when quoted...

The interesting effect of quotes is to that the quoted roll# markers show the rolls associated with the rest of the post, not the rolls of the original nor simple placeholders.


All times are GMT. The time now is 01:05 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01586 seconds
  • Memory Usage 1,864KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_code_printable
  • (2)bbcode_html_printable
  • (5)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (39)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.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
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete