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)

Eikinskjaldi 04-24-2006 10:00 PM

Dice Roller Hack [BBCode]
 
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

Ahsin1 04-24-2006 11:51 PM

Click Install

Hell? 04-25-2006 12:50 AM

When I test:
Code:

Fatal error: Field dice is not defined in $validfields in class vb_datamanager_post in /includes/class_dm.php on line 485

Eikinskjaldi 04-25-2006 01:03 AM

Are all four plugins installed and turned on? You need to ensure that the valid fields for threads and posts is there and activated or the DM will go crazy.

Eikinskjaldi 04-25-2006 01:22 AM

Ah, I found the issue, I had in my rush placed two plugins in the wrong product. I have reuploaded the product with the correct plugins.

Hell? 04-25-2006 02:50 AM

thanks, I'll remove the old and reimport the new product and test, thanks again for the hack

Hell? 04-25-2006 03:27 AM

new problem, this time is database related

Code:

Database error in vBulletin 3.5.4:

Invalid SQL:
INSERT INTO post
        (showsignature, allowsmilie, username, userid, title, pagetext, iconid, visible, parentid, threadid, dice, dateline, ipaddress, attach)
VALUES
        (1, 1, 'Hell?', 1, 'Re: Extras Rol', 'new test dice roller\r\n\r\n[dice0]', 0, 1, 939, 100, 'a:1:{i:0;a:3:{s:5:\"dices\";s:1:\"2\";s:5:\"faces\";s:2:\"20\";s:4:\"data\";a:2:{i:0;i:20;i:1;i:3;}}}', 1145939053, 'xxx.xxx.xxx.xx', 0);

MySQL Error  : Unknown column 'dice' in 'field list'
Error Number : 1054
Date        : Tuesday, April 25th 2006 @ 12:24:13 AM
Script      : http://www.mysite.net/foros/newreply.php
Referrer    : http://www.mysite.net/foros/showthread.php?p=7444
IP Address  : xxx.xxx.xxx.xx
Username    : Hell?
Classname    : vb_database


username12 04-25-2006 03:42 AM

Same as above.

Rukbat 04-25-2006 04:19 AM

I just downloaded and imported via Product Manager. However a parse error flashes on the screen and then is replaced by the 'installed products' screen. error flashes so fast I can't write it down or remember the whole thing.
I checked the plug-ins, there were 4 installed on the product import/upload/install, and yes all 4 are checked as 'active'.

When I test in a post (and it's a reply NOT a first post) I get the following:
Code:

Database error in vBulletin 3.5.4:

Invalid SQL:
INSERT INTO dswfor_post
        (showsignature, allowsmilie, username, userid, title, pagetext, iconid, visible, parentid, threadid, dice, dateline, ipaddress, attach)
VALUES
        (1, 1, 'Admin', 5, 'Re: Admin\'s dice testing thread', '[dice0]', 0, 1, 11356, 1558, 'a:1:{i:0;a:3:{s:5:\"dices\";s:1:\"1\";s:5:\"faces\";s:1:\"6\";s:4:\"data\";a:1:{i:0;i:4;}}}', 1145942170, '**.***.*.***', 0);

MySQL Error  : Unknown column 'dice' in 'field list'
Error Number : 1054
Date        : Tuesday, April 25th 2006 @ 12:16:11 AM
Script      : http://www.*****.***/forums/newreply.php
Referrer    : http://www.*****.***/forums/showthread.php?t=1558
IP Address  : **.***.*.***
Username    : Admin
Classname    : vb_database


Snake 04-25-2006 12:15 PM

Sick! Thanks for the hack! :)

Rukbat 04-25-2006 12:40 PM

Now that I'm not so tired I thought of another question regarding my error message above. What MySQL d/b changes were made? Which table needs new fields and what would the names be to look for to be sure they are there?

EDIT 9:07 CDT

Okay, I went into phpMyAdmin and checked my forum tables '******_thread' and '******_post' and neither table has a 'dice' field.
so do I edit the xml file and change
Code:

<codes>
                <code version="1.0">
                        <installcode>ALTER TABLE `thread` ADD `dice` MEDIUMTEXT NOT NULL ;
ALTER TABLE '******_' ADD 'dice' MEDIUMTEXT NOT NULL ;</installcode>
                        <uninstallcode />
                </code>
        </codes>

to
Code:

        <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>

with the asterisks being the prefix for all tables in the d/b?

EDIT: 9:46am CDT
That didn't work, BUT, once i went in to phpMyAdmin and added the fields to the two tables it works GREAT! :D
so I guess there's something in the code in the xml file that didn't actually ALTER my tables.... or was there something else in the xml file that i didn't find where I should have typed in the name of the d/b? I assumed since it was imported/installed using the vB AdminCP that it would 'know' that was the d/b to alter the tables in......

Rukbat 04-25-2006 03:14 PM

I'm working on making some new images for the die, playing with colors
examples below

Ziki 04-25-2006 06:08 PM

I got this error


Quote:

Database error in vBulletin 3.5.4:

Invalid SQL:
INSERT INTO forumziki_thread
(postusername, postuserid, title, iconid, visible, forumid, threadprefix, dice, dateline, open, attach, lastpost, lastposter, replycount, hiddencount)
VALUES
('Ziki', 1, 'Dices', 1, 1, 9, 'Site related', 'a:1:{i:0;a:3:{s:5:\"dices\";s:1:\"1\";s:5:\"faces \";s:1:\"6\";s:4:\"data\";a:1:{i:0;i:4;}}}', 1145991674, 1, 0, 1145991674, 'Ziki', 0, 0);

MySQL Error : Unknown column 'dice' in 'field list'
Error Number : 1054
Date : Tuesday, April 25th 2006 @ 03:01:14 PM
Script : http://www.xxxxx.com/forums/newthread.php
Referrer : http://www.xxxxx.com/forums/newthrea...=newthread&f=9
IP Address : XXXXXXXX
Username : XXX
Classname : vb_database

Rukbat 04-25-2006 07:19 PM

Ziki-set,
I was having the same problem. For some reason the installer isn't altering your forum database tables (_thread & _post). You need to go into your database and physically add the 'dice' field (mediumtext not null) to those two tables.
That fixed the problem for me.

Also, before installing I corrected some wording in the xml file to correct 'dices' to 'die' because it 'bugged' me:
FIND
Code:

<td><smallfont><b>Dice roll with $dicesno dices of $dicesfaces faces: $dicepoints points</b></smallfont></td>
CHANGE TO
Code:

<td><smallfont><b>Dice roll with $dicesno die of $dicesfaces faces: $dicepoints points</b></smallfont></td>
Also increased the number of 'faces' for dice to 100 since that is what my members needed.
FIND
Code:

if ($faces[$i] >= 2 && $faces[$i] <= 30)
CHANGED TO
Code:

if ($faces[$i] >= 2 && $faces[$i] <= 100)
Of course I had to 'make' die images for 31-100, and upload them to the ../images/dice folder but that didn't take too long.

Hope this helps :D

EDIT: 3:30pm CDT
hmmmm, that works up to '99' faces but can't get it to work for '100'..... *wanders off to ponder a bit*

EDIT: 3:47pm CDT
got it to work
FIND:
Code:

preg_match_all("/\[dice=([1-5])\]([0-9]?[0-9])\[\/dice\]/",$post['message'],$diceresult);
CHANGE TO:
Code:

preg_match_all("/\[dice=([1-5])\]([0-9]?[0-9]?[0-9])\[\/dice\]/",$post['message'],$diceresult);
see attached screenshot

Eikinskjaldi 04-25-2006 10:34 PM

Ya, the install code seems to be errored, I'll work on it and upload the right installer, Thanks rukbat for posting the little mods for others. I might have messed that part up as well.

EDIT:
Upload XML fixed with the correct queries. Sorry about that.

Ziki 04-26-2006 11:33 AM

Now it doesn't show the dices.I imported it and it doesn't show the dices but only the [dice=2]5[/dice]

Rukbat 04-26-2006 11:40 AM

Did you FTP the dice images into a 'dice' folder in images at your site?
Also, go into your PlugIn Manager in your vB admincp, look to be sure all the plug-ins for 'Dice Roller' are checked as 'active'.
Did you 'unistall' via product manager before installing again?

Rukbat 04-26-2006 11:51 AM

oops also, you can't create a thread with a post that includes a dice roll
only replies can include the dice roll
easy solution:
create a new thread i.e.
title: dice roller test
text in post: this thread is to test the dice roller
submit the new thread
then post a reply/quick reply to it, including the dice roll bbcode

Eikinskjaldi 04-26-2006 06:24 PM

Yes, I need to find the right place to inser the code for the first post, I looked in my quick porting of the hack but didn't find it. It's as simple a fix as inserting the code before the first post is output.

username12 04-27-2006 02:50 AM

Don't know how high you would be able to go, but here's one vote for more than 5 dice.

Eikinskjaldi 04-27-2006 03:26 AM

Well we can go up to as many as you want, but it will mean changing the dbase field to hold more data because its currently med.

Ziki 04-27-2006 12:30 PM

You are missing the .thread table :)

username12 04-27-2006 08:52 PM

One of my members mentioned 20. Whether that's a good idea or not from a coding standpoint I don't know. Also, Rukbat, would you be willing to post your dice up to a higher number?

Rukbat 04-27-2006 09:19 PM

sure
what color? pentagonal or 'square'? and up to what number?

Rukbat 04-27-2006 09:30 PM

this might be a better way to compare

Eikinskjaldi 04-28-2006 04:58 AM

Those pentagonal ones are pretty kick arse. If you decide to make a public release i'll add them to the package with credits to you, because if you ask me the ones it comes with are yuck...

Rukbat 04-28-2006 03:43 PM

I've made 2 sets (a white set & a blue set) of the pentagonal dice (in gif format) both sets up to 30; as well as a 'blank' white and a 'blank' blue in both gif and png formats so if anyone wants/needs higher face values they can make them (or they can pm me and I will when I have time). I used Tolkein font for the numbers in black.

Both sets are in the attached 'dice.zip' file (at least I hope I zipped it and attached it correctly... I don't do much zipping.. mainly unzipping...heh)

Rukbat 04-28-2006 05:07 PM

i'll work on higher numbers for both those sets later today, and also make a few more colors. will zip and attach when done. guess I'll go up to 100?
maybe put a txt file with the original hack download that they only have to upload the dice set they want to use as well as only uploading the individual gifs for the number of 'faces' they will be using.

a thought...
to increase the max number of die rolled from 5 to say 9 would the 'mediumtext' attribute still be okay? would the below be coding to change?
FROM
Code:

preg_match_all("/\[dice=([1-5])\]([0-9]?[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);
without having to change anything else?
*note above from my moded xml file so '100' will display

Ziki 04-28-2006 06:50 PM

Does this work for someone?Doesn't for me

Eikinskjaldi 04-28-2006 07:11 PM

You may need to ensure the database fields are all there and that all the plugins and bnoth templates where added. I have uninstalled and reinstalled it a few times on my test board with no issues. Rukbat made some good suggestions on the previous page.

I'll go add the extra zip into the other and make note of it, anything specific you want to go with your username in the readme file? If not i'll just use your vb.org username.

As for making it accept more chars, yes, that should work, I havn't looked into it in detail, It shouldn't be very hard since the code is quite strait forward.

Rukbat 04-28-2006 11:30 PM

Quote:

Originally Posted by ZIKI-SET
Does this work for someone?Doesn't for me

what problem are you having Ziki-set?
First thing to do is check your database and be sure the 'dice' field was added to both the 'thread' and 'post' tables. When you test it you can't start a thread with a post that includes a dice roll, unless Eikinskjaldi figured out how to fix that problem, the hack had that problem even when it was for 3.0.7 before it was ported here.

EDIT: 10:32pm CDT
Be sure the path to the dice image files is correct in the xml file before importing it. the default is /images/dice. Check and be sure you uploaded/ftp'd the gif files to dice folder in images folder. That's all I can think of for now.

username12 04-29-2006 02:34 AM

The pentagonal ones are a definite improvement. I think I'll use the blue ones.

Rukbat 04-29-2006 02:36 AM

I'm working on 31-100 right now in the blue ones.

Rukbat 04-29-2006 03:45 AM

okay, here it is blue pentagonal dice numbered 1-100

Rukbat 04-29-2006 03:47 AM

just a note changing the 1-5 to 1-9 doesn't work for increasing the number of die to roll...

Eikinskjaldi 04-29-2006 07:54 AM

I'll look into it later, its 5 AM here and my experience is that working this late, well early, isnt generally good for your coding prospects.

username12 04-29-2006 06:10 PM

Thanks for the new dice.

The 1-9 change works for me to get it up to 9.

Rukbat 04-29-2006 09:53 PM

dang it! what did you do to get it to roll 9 die at once?
I've gotten it to roll 10 separate times in a single post but only up to 5 die....
EDIT: n/m, i got it to work up to 9 die, now going to go for 10

Ziki 05-04-2006 05:52 PM

So you have still prob with the Db table adding?

Rukbat 05-04-2006 06:11 PM

who me?
I just went into PHPmyAdmin and added the fields to the ***_threads and ***_posts tables myself. Not sure if the problem within the product was resolved or not, anybody install this since Eikinskjaldi updated the xml file?


All times are GMT. The time now is 06: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.02210 seconds
  • Memory Usage 1,840KB
  • 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
  • (13)bbcode_code_printable
  • (3)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
  • (40)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