PDA

View Full Version : Dice Roller Hack [BBCode]


Eikinskjaldi
04-24-2006, 10:00 PM
Dice Roller Hack [BBCode]
RPG Dice is currently a updated version (https://vborg.vbsupport.ru/showpost.php?p=994284&postcount=117)
Another updated version (https://vborg.vbsupport.ru/showpost.php?p=1017963&postcount=167)

Note: Updated package includes only the correct XML.

This hack is a port of: Dice Roll for vB3 (https://vborg.vbsupport.ru/showthread.php?t=62042&highlight=Dice+roll) and permissions was given to port by the following statement.


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

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 6 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/attachment.php?attachmentid=17033&d=1078098688
https://vborg.vbsupport.ru/attachment.php?attachmentid=17034&d=1078098702

Ahsin1
04-24-2006, 11:51 PM
Click Install

Hell?
04-25-2006, 12:50 AM
When I test:
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

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


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/newthread.php?do=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
<td><smallfont><b>Dice roll with $dicesno dices of $dicesfaces faces: $dicepoints points</b></smallfont></td>
CHANGE TO
<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
if ($faces[$i] >= 2 && $faces[$i] <= 30)
CHANGED TO
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:
preg_match_all("/\[dice=([1-5])\]([0-9]?[0-9])\[\/dice\]/",$post['message'],$diceresult);
CHANGE TO:
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 5

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?
FROMpreg_match_all("/\[dice=([1-5])\]([0-9]?[0-9]?[0-9])\[\/dice\]/",$post['message'],$diceresult);
TOpreg_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
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?

Ziki
05-13-2006, 02:02 PM
Wanted to ask same

Eq4bits
05-22-2006, 02:34 AM
ugh, some a****** stole my gmail addy and I'm locked out of it... which is the addy I used for my ORIGINAL username here... Rukbat... so if there have been any posts since May 12 attributed to the Rukbat i.d. it is NOT me, they hacked my groups website that I administer AND my static IP also, that's getting reassigned tomorrow, it's been a nightmare getting everything kinda straight.
If anyone has a request for specific colors/shapes of dice for this mod, either post here or pm me with this, my new, username.

Emmy2
05-24-2006, 01:33 PM
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):

but the code would execute as: 6

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?

Zowners
05-24-2006, 02:54 PM
FIND
<td><smallfont><b>Dice roll with $dicesno dices of $dicesfaces faces: $dicepoints points</b></smallfont></td>
CHANGE TO
<td><smallfont><b>Dice roll with $dicesno die of $dicesfaces faces: $dicepoints points</b></smallfont></td>

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

soravok
05-25-2006, 09:20 AM
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.

Emmy2
05-25-2006, 09:51 PM
can I try another question? I'm trying to simplify the dice roll for my members...trust me, inputting 6 is beyond most of them.

Ideally, it would be great if I could add a clickable button on the quickreply toolbar menu that automatically inserts a pre-determined text string into the reply box (in this case, the actual bbcode I want them to use, which is 6 ... that way they don't have to type it themselves). Is there any way to do this? I've been searching around the net for a few hours and I can't find anything (I'm no coder).

Any help really appreciated.

cclaerhout
05-26-2006, 01:26 AM
I think Emmy2 idea is good.

Why not having in the editor tool bar a collpase icon showing a different choice of dice : dice 4 ; dice 6 ; dice 10 ; dice 12 ; dice 20. RPG gamers will love that !

The php code sould also be rewritten.

Because i'm not a php coder, i can't do that. But i've already developped the different dice pictures :) I think you will like them ;)

In the joined archive, you will find png pictures (better for transparency) et adobe psd file.

Tell us if you think you can make our wishes become true :banana:

Zowners
05-26-2006, 05:20 AM
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.

Eikinskjaldi
05-26-2006, 06:29 AM
I personally was in a hurry with this and I have made no plans to work on it. I ported it per request when I had some free time, but as it stands my free time might not be coming back for awhile, iv got 6 projects lined up in my future. So if another coder wants to take and mod this then its free game as I just don't have time for it.

If it doesnt not work for you then you may need to use phpmyadmin and manually add the database iformation, it is all in the install code that can be found in the product by hitting edit. I don't have it handy but it is basic field adding.

Emmy2
05-26-2006, 12:09 PM
Zowners, I don't know if this will help you but let me relate my installation experience. I just installed this a few days ago. I noticed in the unzipped file that there were TWO product xml files, named:

Eiken-DiceRoller-0_1
Eiken-DiceRoller-1_0

I assumed the 1_0 was the newer one and tried to import that one. However, I got database errors, the product wasn't installing into the dabatase correctly (maybe like you are getting now). So I UNINSTALLED that one, and installed the other product...the Eiken-DiceRoller-0_1 file. That one worked and the version listed for it in the admin panel is "1.0" (even though the file is named 0_1). I have no idea why there are two files, why one works and one doesn't, but I thought I'd relay that in case you are having the same problem I did.

As for creating a button for the dice roll...I'll go ask in a general coding forum to see if anyone can assist. It's not necessarily just a function of the dice roll, but a button to input ANY pre-defined text into the reply box, so maybe someone can help.

Eq4bits
05-26-2006, 01:03 PM
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.

Eq4bits
05-26-2006, 01:18 PM
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 100 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.

Eq4bits
05-26-2006, 01:49 PM
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... :D

Eq4bits
05-26-2006, 03:08 PM
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):
<?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,
Y
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 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 6 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.

Eq4bits
05-26-2006, 03:15 PM
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):

but the code would execute as: 6


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?

cclaerhout
05-26-2006, 03:16 PM
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.

cclaerhout
05-26-2006, 03:18 PM
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.

BeaLzeBuB
05-26-2006, 03:38 PM
it doesn't show the dices.I imported it and it doesn't show the dices there is only 6

Eq4bits
05-26-2006, 03:58 PM
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....

Eq4bits
05-26-2006, 04:18 PM
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 :D
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 preg_match_all("/\[dice=([1-5])\]([0-9]?[0-9])\[\/dice\]/",$post['message'],$diceresult); TO 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' inif ($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)

Eq4bits
05-26-2006, 04:23 PM
it doesn't show the dices.I imported it and it doesn't show the dices there is only 6

Check your 'thread' and 'post' tables in your database to be sure the 'dice' field was added to both tables.

Be sure you uploaded images of dice to the vBulletin forum images directory into a file named 'dice'. The dice file with the product are the old images and are pretty ugly and only go up to 30. If you want to use more than 30 faces you'll need to make dice for those numbers or download the Blue Dice.zip file that is attached to one of my previous posts (prettier dice and numbered 1-100)

Eq4bits
05-26-2006, 04:32 PM
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 ;)

cclaerhout
Do you know if that also corrected the problem of having a dice roll in a post that is the first post of a new thread?

Emmy2
05-26-2006, 04:59 PM
Yes Eq4bits, a button or collaspible menu for rolling dice that automatically inputs the correct bbcode for each roll when a user clicks on it. If collapsible isn't possible, just a single button would work. I could create more than one button to include variations of the roll.

I have also asked for coding help for this in the general forums, since this idea wouldn't necessarily be exclusive to rolling dice.

here is the thread I've asked...

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

Eq4bits
05-26-2006, 05:48 PM
Okay, what preset would you like? I'm working on it now

Emmy2
05-26-2006, 06:24 PM
cool! for a preset, how about...

6 if it's just one button

If it's a menu....

6
6
6
6
6

As long as there is some code to start off I think I can change it to whatever I want later, but for a start those presets would do.

Thanks, it'll be great if this works!

Eq4bits
05-27-2006, 01:30 AM
So far I'm not having any luck, like I said I'm no whiz at this but usually given time and a LOT of mistakes I'll eventually figure something out.

It *definiately* doesn't work by just adding a new bbcode via the admincp... I can get the button there, no problem, but it won't execute and show the dice...

OH I just thought of something, if you've installed this and the dice pics aren't showing you MAY need to change the permission/ on your image file to 777 and on the dice file to 777

Eq4bits
05-27-2006, 01:35 AM
I'm still going to continue playing with this to try to get it to work via a button on the editor or a dropdown on the editor, but until then emmy if you don't need to 'store' the results in the d/b and just want your users to roll dice and don't need it to show in a post take a look at this alternative thread https://vborg.vbsupport.ru/showthread.php?t=97797&highlight=dice

Eikinskjaldi
05-27-2006, 05:45 AM
Well paint me up and call me a liar, Due to some demand from my users and a few holes in my alternate dice roller I use I think I will be coming back and working on this hack some more. I don't know yet if I will release the same one here as on my forum since this one being an extension needs to avoid code edits, but I thank those who have supported people and ried to help them, I will be adding your names to the first post and I'll check the package again on the SQL error.

If your dice are not parsing then it is most likely a plugin issue and you should ensure all plugins are turned on. Making a drop down for the post bit doesn't seem to difficult, Much like using the color code in a modified format, I may look into this when iIrevisit this hack, I may have a new version up in the next few days, depending on my scedual.

[[Yes, I am pushing back other work for this as its been something iv been avoiding taking care of at my own site and now its time to tackle it before I get beaten up by disgruntled DM's.]]

-Eikinskjaldi-

cclaerhout
05-27-2006, 09:31 AM
Here is a new xml product file :
-SQL error is fixed
-Display dice in first post of a new thread is OK (i guess my code can be improved a lot ;) )

Now we all can try to make the version of the hack i've described above :D
Here (https://vborg.vbsupport.ru/showpost.php?p=988391&postcount=47)

cclaerhout
05-27-2006, 11:20 AM
Well, here is a preview of "RPG DiceRoller". I still have to work on the user interface.

You want to play a D4 ?
4

You want to play a D6 ?
6

You want to play a D8 ?
8

You want to play a D10 ?
10

You want to play a D12 ?
12

You want to play a D20 ?
20

Other dices won't work because pictures don't exist ;)

N.B : Pictures are in png format. To avoid grey line arround them in Internet Explorer 6, you need a png transparency hack (available here). Otherwise i could do a gif release.

akanevsky
05-27-2006, 11:24 AM
Although I see no practical use for me, this is a very nice hack technical-wise.

Eq4bits
05-27-2006, 02:42 PM
Well, here is a preview of "RPG DiceRoller". I still have to work on the user interface.

You want to play a D4 ?
4

You want to play a D6 ?
6

You want to play a D8 ?
8

You want to play a D10 ?
10

You want to play a D12 ?
12

You want to play a D20 ?
20

Other dices won't work because pictures don't exist ;)

N.B : Pictures are in png format. To avoid grey line arround them in Internet Explorer 6, you need a png transparency hack (available here). Otherwise i could do a gif release.

So you can only roll 1 dice at a time with this version? Any way to make it work to ALWAYS roll a die with 6 faces but make the # of dice variable? i.e.
6
6
6
6
6

That's what Emmy2 is looking for.
My group uses anywhere from 1-9 dice and anywhere from 2-100 faces, I was TRYING to just make a new bbcode button in the admincp bbcode manager, i could get the button image to work, but when you'd click it and vB asks you to input the number for the {option} the result would look like:



you still had to put the 'face' variable/option/param in physically between the two sets of brackets, but the quotes vB automatically put around the #ofdice of course kept it from working, was having trouble with the 'html' part in the 'add bbcode' panel also..

*sigh*... I just have to face it somethings I *can* do and some I just don't have the knowledge for.. I'm just belligerant and keep at it though... till I'm cross-eyed... LOL

I didn't realize IE put grey borders around gifs, i've never noticed it before.... hmmmm
If anyone wants me to turn the 1-100 Blue Dice in pentagonal shape (that I did as Rukbat) into png's let me know and I'll do a batch conversion and re-zip & re-upload here.

Eq4bits
05-27-2006, 02:45 PM
cclaerhout,
One more question...
is the 'roll' still stored in the d/b?

Emmy2
05-27-2006, 03:27 PM
There now seems to be several of you working on variations for this, and that's great! So, not to sidetrack everyone but I have a few more ideas....

Suppose I wanted to install this hack more than once, what would I need to change in the original xml file? In other words I want one hack called "dice" and another hack called "cards" that does the same thing but uses separate database tables and images. So for example, I can have one game that throws dice and another game that draws playing cards. Or another game that rolls letters of the alphabet.

In other words, suppose I want 3 separate games. Dice, Cards, Alpha, if you want to name them. What parts of the original script could I change so that I can install this game a second and third time (in a different place, not overwriting the first game)?

Then, to play, users would type (or I'd create buttons for):

6
to roll a 6 sided dice five times

52
to draw 5 cards from a 52-card deck

26
to roll 9 letters out of the 26 letter alphabet

I'm dreaming big here folks! :P

Another idea....suppose for the card game users are drawing 5 cards and I don't want them to draw the same card twice (this could also apply to dice). Is there a way to limit it so the same card/dice isn't drawn/rolled more than once in a roll of multiple die or cards?

Yeah, this is all pretty much off-base for the current project, but I thought I'd just throw these ideas out there.

cclaerhout
05-27-2006, 04:31 PM
So you can only roll 1 dice at a time with this version?
No, as many as you want.

The dice are still in database.

Eikinskjaldi
05-27-2006, 05:00 PM
Well a standard deck has 52 cards so you bbcode would probaly look more like 5. With private text you could be on your way to having poker in threads. as far as limiting it, ya, it could be limited, it'd be as simple as stoirng the values in a array and testing to make shure none equal eachother.

However back on dice, Another idea is a prompt box which you can enter the number to roll after having selected the sides from a drop down.I'll look into that avenue. I am going to making a steep departure from the old system of rolling dice as it doesn't work for me, so this drop down idea won't work for me, in any case, all that well. Seeing as I help run one of the largest gaming sites for PbP it isnt easy to keep everything simple. A sample new style roll would be:
1d20 1d20 1d6

Which would provide a much cleaner more cingular less bulky output. I also don't want images, so I will probaly provide to XML's, one with them and one without. If you visit my forum and check out some of the dice rolls you can see the output I will probaly be aiming for as I want to try and keep my dice standard.

The cards thing shouldn't be to hard and i'll look into it if I have time.

cclaerhout
05-27-2006, 10:32 PM
Here is the kind of interface i'd like. It would be a popup. I'm going to ask Michelle (https://vborg.vbsupport.ru/showthread.php?t=100043) if she can help us.

cclaerhout
05-28-2006, 07:38 AM
Michelle is sorry but she doesn't have time to work on this. If an advanced coder can have a look, it would be nice.

Emmy2
05-28-2006, 11:49 PM
Could the "onclick" command be used in conjuction with an image button to insert the roll into the textarea?

I've been looking at the smilie code and that's what it does. Click a smilie and it inserts something like :smilie: into the text box. Instead of :smilie: I need it to insert the code for a dice roll.

So something like this to create a button (this is just me expressing my idea, it is NOT real code): <img src="http://www.mysite.com/dicebutton.gif" onclick="return value('6')">


Then I think you'd have to create a little javascript to put in the page head for the onclick command, right? Can anyone help with this? I'm really keen to get it working.

Emmy2
05-29-2006, 05:48 PM
Michelle is sorry but she doesn't have time to work on this. If an advanced coder can have a look, it would be nice.

I'm not a coder but I think I did it! I've created code that will add an image button or a regular button to the quick reply and regular editors that when clicked by user automatically inserts the text for one pre-defined dice roll. It doesn't have a drop-down menu for multiple options, but hey it's a start! And maybe with the base code in place someone can look at it and see how to add a menu. All I did was research on google and played with some code I found and kept testing and this one finally worked.

I will post the code late tonight when I get home from work...I have been working on this all day.

:banana:

cclaerhout
05-29-2006, 05:57 PM
I'm waiting for you :) Since your last post, i've imagined a new user interface easier to code if you manage to do what you're trying.

The code will be something like this :
<fieldset style="width:140px;">
<legend style="font-size: 14px;color:black;font-weight:bold;">Dice menu</legend>
<span style="font-size: 12px;color:black;font-weight:bold;">D04 : </span>
<input style="font-size: 9px; width:20px" type="submit" name="Submit" value="x1"><input style="font-size: 9px; width:20px" type="submit" name="Submit" value="x2"><input style="font-size: 9px; width:20px" type="submit" name="Submit" value="x3"><input style="font-size: 9px; width:20px" type="submit" name="Submit" value="x4"><input style="font-size: 9px; width:20px" type="submit" name="Submit" value="x5">
<br />
<span style="font-size: 12px;color:black;font-weight:bold;">D06 : </span>
<input style="font-size: 9px; width:20px" type="submit" name="Submit" value="x1"><input style="font-size: 9px; width:20px" type="submit" name="Submit" value="x2"><input style="font-size: 9px; width:20px" type="submit" name="Submit" value="x3"><input style="font-size: 9px; width:20px" type="submit" name="Submit" value="x4"><input style="font-size: 9px; width:20px" type="submit" name="Submit" value="x5">
<br />
<span style="font-size: 12px;color:black;font-weight:bold;">D08 : </span>
<input style="font-size: 9px; width:20px" type="submit" name="Submit" value="x1"><input style="font-size: 9px; width:20px" type="submit" name="Submit" value="x2"><input style="font-size: 9px; width:20px" type="submit" name="Submit" value="x3"><input style="font-size: 9px; width:20px" type="submit" name="Submit" value="x4"><input style="font-size: 9px; width:20px" type="submit" name="Submit" value="x5">
<br />
<span style="font-size: 12px;color:black;font-weight:bold;">D10 : </span>
<input style="font-size: 9px; width:20px" type="submit" name="Submit" value="x1"><input style="font-size: 9px; width:20px" type="submit" name="Submit" value="x2"><input style="font-size: 9px; width:20px" type="submit" name="Submit" value="x3"><input style="font-size: 9px; width:20px" type="submit" name="Submit" value="x4"><input style="font-size: 9px; width:20px" type="submit" name="Submit" value="x5">
<br />
<span style="font-size: 12px;color:black;font-weight:bold;">D12 : </span>
<input style="font-size: 9px; width:20px" type="submit" name="Submit" value="x1"><input style="font-size: 9px; width:20px" type="submit" name="Submit" value="x2"><input style="font-size: 9px; width:20px" type="submit" name="Submit" value="x3"><input style="font-size: 9px; width:20px" type="submit" name="Submit" value="x4"><input style="font-size: 9px; width:20px" type="submit" name="Submit" value="x5">
<br />
<span style="font-size: 12px;color:black;font-weight:bold;">D20 : </span>
<input style="font-size: 9px; width:20px" type="submit" name="Submit" value="x1"><input style="font-size: 9px; width:20px" type="submit" name="Submit" value="x2"><input style="font-size: 9px; width:20px" type="submit" name="Submit" value="x3"><input style="font-size: 9px; width:20px" type="submit" name="Submit" value="x4"><input style="font-size: 9px; width:20px" type="submit" name="Submit" value="x5">
<br />
</fieldset>

Eq4bits
05-29-2006, 07:57 PM
I'm not a coder but I think I did it! I've created code that will add an image button or a regular button to the quick reply and regular editors that when clicked by user automatically inserts the text for one pre-defined dice roll. It doesn't have a drop-down menu for multiple options, but hey it's a start! And maybe with the base code in place someone can look at it and see how to add a menu. All I did was research on google and played with some code I found and kept testing and this one finally worked.

I will post the code late tonight when I get home from work...I have been working on this all day.

:banana:

Emmy, that can be done via the adminCP bbcode manager and what i was playing with. I stuck a small gif of a blank die in the images/editor file and then in adminCP>BBcode did the 'add new bbcode' thing. I could get it to give me a return of into a posting window, but even after sticking in '6' between the two tags when I submitted it wouldn't show the dice in the post... just the 'total points'.

Looking forward to seeing your fix around it.

cclaerhout
05-29-2006, 08:08 PM
Emmy, that can be done via the adminCP bbcode manager and what i was playing with. I stuck a small gif of a blank die in the images/editor file and then in adminCP>BBcode did the 'add new bbcode' thing. I could get it to give me a return of into a posting window, but even after sticking in '6' between the two tags when I submitted it wouldn't show the dice in the post... just the 'total points'.

Looking forward to seeing your fix around it.


This method has two problems :
1)you have to enter the number of faces.
2)you can't specify the number of dice.

Eq4bits
05-29-2006, 10:05 PM
yeah I know, is why my eyes started bleeding trying to make it do one or the other and had to quite

Emmy2
05-30-2006, 01:24 AM
vb Coders...

Okay, here is the code I worked out to add a button to the editor to automatically insert a dice roll.

Remember I’m not a coder, so use this at your own risk. I just kept fiddling with it until it worked. I don’t know the possibility of any negative consequences of the script, so if there are flaws I’m not responsible! I also have never posted code or instructions before, so I hope my directions are coherent.

I've included code for three different button types....a simple text link, a text button, and an image button. Choose the one you prefer. The two best are the text link and the image button. The text button is a little buggy, but still works.

You need to install the script in two places, so that a button shows up on both the quick reply editor and the regular editor. So find these templates:

editor_toolbar_on
showthread_quickreply

Into each template you will add a bit of code to make a button. To find the places to insert the code....

In editor_toolbar_on look for:
$vBeditTemplate[extrabuttons]
In showthread_quickreply look for:
<if condition="!is_browser('opera')">


ABOVE each of those lines add ONE of the following codes to make your button:

For a text button on the editor toolbar:
<td><input type="button" value="Roll 3 Dice" onclick="document.getElementById('{$editorid}_textarea').va lue += '6';"></a></td>

For a text link on the editor toolbar:
<td><a href="javascript:void(0);" onclick="document.getElementById('{$editorid}_textarea').va lue += '6';
return false;">Roll 2 Dice</a></td>

For an image button on the editor toolbar:
<td><a href="javascript:void(0);"><img src="http://www.yoursite.com/diceimage.gif" title="Roll 5 Dice"
onclick="document.getElementById('{$editorid}_textarea').va lue += '6';"></a></td>

Be sure to change the variables to suit your site....ie. the image url to your own image, and the variables of the dice roll to what you want. (an example is 6 but you can create whatever roll you want), and/or the name of the text button to what you want.

Theoretically you can add as many buttons for as many different rolls as you want. However, I know that is too cumbersome. Ideally some sort of option menu would be ideal, like for smilies or fonts. But I don’t know how to code that. Maybe someone else can help now that I've worked out the basic code.

Btw, this script could be used for more than just dice roll. It could be used for any other complex bbcode string that you want to preset, or even for full sentences (“Your post was very helpful to me.”). Just anything that would save the user some keystrokes (as long as there are no quotes in the text string, I think that would mess things up).

Eq4bits
05-30-2006, 05:14 AM
In showthread_quickreply look for:
<div>$vBeditTemplate[extrabuttons]</div>

Emmy,
am using ver. 3.5.4 I don't have that code in my showthread_quickreply template... it's never been changed since the upgrade. Any suggestions as to where to add this?

Emmy2
05-30-2006, 09:31 AM
Oops, sorry, that is my fault. My showthread_quickreply is already hacked and that must be some additional code I have in mine.

Try putting it just before this line:

<if condition="!is_browser('opera')">

I can't test it, but I think it goes there.

cclaerhout
05-30-2006, 09:33 AM
You dit it ;)

I've finished to integrate your code. I'm trying to improve user interface now.

Zowners
05-30-2006, 02:28 PM
Okay I did what Emmy said and that worked perfectly.

For those who only see the "6" and no images, be sure to UNINSTALL the 1_0 xml file before installing the 0_1 file. I believe the reason I had so many problems was that instead of unintalling I kept overwriting.

Eikinskjaldi
05-30-2006, 07:30 PM
Also, for those who dont want a million buttons you can use this instead:

<script type="text/javascript">
function dropDownDice(obj){
if(obj.value != ''){
var data = obj.value;
var indx = data.indexOf(';');
var diceToRoll = data.substr(0,indx);
var faces = data.substr(indx+1);
document.getElementById('{$editorid}_textarea').va lue += ''+faces+'';
}
}
</script>

<td><select onChange="dropDownDice(this);">
<option></option>
<option value="1;6">1d6</option>
<option value="2;6">2d6</option>
<option value="3;6">3d6</option>
<option value="4;6">4d6</option>
<option value="5;6">5d6</option>
<option value="6;6">6d6</option>
</select></td>
Place it where you would place the other ones, just above the:

<if condition="!is_browser('opera')">


Should help with those who dont want to clutter there editor.

NOTE: These do not work if you have WYSIWIG turned on.

To add a new dice just add:

<option value="Number of dice to roll;Number of faces">Descriptor</option>

Eikinskjaldi
05-30-2006, 07:52 PM
....and another variation that requires less work from you but a little more from the users:

<script type="text/javascript">
function dropDownDice(obj,obj2){
var diceToRoll = document.getElementById(obj).value;
var faces = document.getElementById(obj2).value;
document.getElementById('{$editorid}_textarea').va lue += ''+faces+'';
}
</script>

<td><select id="{$editorid}_dicetoroll">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
</select></td>
<td><span style="color:black;"><b>D</b><span></td>
<td><select id="{$editorid}_dicefaces">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
</select></td>
<td><input type="button" onClick="dropDownDice('{$editorid}_dicetoroll','{$editorid} _dicefaces');" value="Add Dice" /></td>


same rules apply as above, Attaching a screenshot of this one since it is a little different.

Eq4bits
05-30-2006, 09:26 PM
so these only work with quick reply or the non advanced wysiwyg editor? or it won't even work on quick reply if the other is enabled?

cclaerhout
05-30-2006, 09:44 PM
RPG DICE IS READY !

That's good, i've finished my job :) Sorry for the delay, i had a busy day.

So what's new :
-sql problem is fixed
-dice in first thread are working
-new user interface integrated in Quickreply and in Editor tool bar


And the best for the end :

Everything is automatically installed with the xml product file :)


To see the result, have a look at the pictures.

P.S : I'd like to know if i can translate and distribute this hack to vbulletin-fr for french users.


EDIT : files removed for a new release.

Emmy2
05-30-2006, 10:00 PM
wow, all of the menus look great! I'll be studying them and figuring out which one to add to my site. So glad we were able to figure something out for this...will really make it easier for the game players.

so these only work with quick reply or the non advanced wysiwyg editor? or it won't even work on quick reply if the other is enabled?
I think he just means the wysiwyg editor will simply show the dice bbcode in the textarea, not actually "execute" it live like it does for other bbcode functions. Am I right on that?


Is this a good time to re-ask one last question I have? I mentioned it before in another post. But I would like to install this hack more than once, to use to play different games that have different images...numbered dice, playing cards, rolling alphabet letters. If I took the xml file and changed every instance of "dice" to "dice2" and then imported it would I get a second installation of the game that uses [dice2] as the bbcode? Would that work? Or can someone rewrite the code using "cards" and "alpha" instead? Thanks for any help.

Eikinskjaldi
05-30-2006, 10:38 PM
Yes, in theory if you changed all that it would make a new bbcode, but of identical function. you'd need to add new templates as well if you wanted to change output and modify the code for cards to some extent.

You can translate this into any langauge you'd like, but it isnt done yet. I like the drop down below but I prefer my own method as its smaller, to each his own.

When i attempted the use of it in a WYSIWIG it did not apear in the editor because you have to write special code from what i recall to handle the WYSIWIG. That is something a little more complex then this simple JS. It should in theory show up but unparsed. I may look into this later. In a few hours when i have this other work done i am going to tackle the code and rip it to pieces for my own uses which does sort of render the buttons as useless to some extent but I will see what I can do.

cclaerhout
05-30-2006, 10:42 PM
Just to say that i've also got the wysiwyg problem.

Emmy2
05-30-2006, 10:55 PM
speaking of modifying the code for cards....I guess what I'd need is something that assures that the same card isn't drawn twice (suppose you draw 5 cards...two of them can't be the ace of hearts...unlike dice, where you CAN roll the same number twice). I don't suppose anyone here would know how to make that modification? :hopeful: :D

Oh, oh, oh....just had another idea. What would be ideal for cards is if the same card couldn't be drawn more than once in EACH THREAD. That way if you're playing a card game, taking turns drawing from the deck, you don't get cards repeating themselves, no matter who is doing the drawing. If each thread was a new game, then limiting it to one draw of each card PER THREAD would be the way to go. I would absolutely love this....any possibility?

cclaerhout
05-30-2006, 11:33 PM
To avoid the wysiwyg problem, just tell for the moment your members to click "A/A" in the top right corner of the editor to make dice buttons work.

To see RPG Dice in action go there : www.lesatirique.info/forum/showthread.php?t=2421

Eq4bits
05-31-2006, 12:43 AM
Thanks for the work around cclaerhout, or should I say Merci?
One more question, on your interface can you 'mix' the different dice in one roll? i.e. 1d5 1d10 1d20 (1 for # of dice,d for dice, 5/10/20 for # of faces) did that make sense?

Eq4bits
05-31-2006, 01:23 AM
To add a new dice just add:

<option value="Number of dice to roll;Number of faces">Descriptor</option>


where in the template does one put that option value? which template?

Eikinskjaldi
05-31-2006, 02:41 AM
Add that to the select in the same post. It will add another entry to the option drop down.

darkram
05-31-2006, 03:02 AM
Nice work cclaerhout!

Although there seems to be another bug, when rolling multiples of a d10 sometimes it drops the last image of the dice. For instances if I do 2d10 I only see one image of the dice and if I do 3d10 I only see 2 images. It seems to replace an image with the "D10" at times.

Here is an example that I have:
http://www.darkram4.com/forums/showthread.php?p=9#post9

Emmy2
05-31-2006, 08:23 AM
The script is executing okay but you are getting red x's instead of two of the images. It looks like those images are missing, either they were accidentally left out of the package or they didn't upload properly to your images folder.

You're missing:

d10_8.png
d10_9.png

cclaerhout
05-31-2006, 09:24 AM
Thanks for the work around cclaerhout, or should I say Merci?
One more question, on your interface can you 'mix' the different dice in one roll? i.e. 1d5 1d10 1d20 (1 for # of dice,d for dice, 5/10/20 for # of faces) did that make sense?

"De rien" ;) (translation : you're welcome.

As the original script you can mix dice, but it will give you several windows with one for the D4, one for the D6, one for D10, etc. In fact the roll is the moment whrn you press the "Ok" button. I think it's better to have several windows to count different faces dice seperately.

But you can't launch a 1D5, because D5 doesn't exist in user interface. If you do it manually with the bbcode, the dice window will be blank because the D5 has no picture (i don't think it exists).

cclaerhout
05-31-2006, 09:27 AM
The script is executing okay but you are getting red x's instead of two of the images. It looks like those images are missing, either they were accidentally left out of the package or they didn't upload properly to your images folder.

You're missing:

d10_8.png
d10_9.png


In fact i've seen this problem yesterday night (In France it was night) but i was too tired to correct it ;D

It's very easy : picture exist but are called "d10_08.png
d10_09.png" ; rename them "d10_8.png" "d10_9.png"

cclaerhout
05-31-2006, 09:29 AM
Nice work cclaerhout!

Although there seems to be another bug, when rolling multiples of a d10 sometimes it drops the last image of the dice. For instances if I do 2d10 I only see one image of the dice and if I do 3d10 I only see 2 images. It seems to replace an image with the "D10" at times.

Here is an example that I have:
http://www.darkram4.com/forums/showthread.php?p=9#post9

I'm going to look at this problem. Let me a little time because it's time to eat here ! :D

cclaerhout
05-31-2006, 09:59 AM
Are you sure of this bug ?
I've tried here (http://www.lesatirique.info/forum/showthread.php?p=25506#post25506) and it works well.

P.S : your vB style is very nice.

cclaerhout
05-31-2006, 10:10 AM
I've updated my archive here (https://vborg.vbsupport.ru/showpost.php?p=993225&postcount=93).

The name of two pictures have been corrected.

Eikinskjaldi you don't answer me, can i distribute RPG hack to vbulletin-fr.org ? Of course, everybody will be in the credit.

darkram
05-31-2006, 03:05 PM
Are you sure of this bug ?
I've tried here (http://www.lesatirique.info/forum/showthread.php?p=25506#post25506) and it works well.

P.S : your vB style is very nice.

Seems to be working now after I reinstalled it. Thanks again for a great job so far folks!

:banana:

BTW: Thanks its from the World of Warcraft style here.

Emmy2
05-31-2006, 03:21 PM
I've got another question/idea.

I'm using Eiken's drop down menu to choose the dice roll. Is there any way to have that menu ONLY show up in my games forum? So it doesn't appear on all the toolbars in all my forums?

What would the conditional statement for that be? I can express it verbally but I can't code it....
<if forum id = 6>
code for menu here
</if>

But that's not code I know! but what would the REAL code for that be?

cclaerhout
05-31-2006, 05:03 PM
The solution is :

For forums ID :

<if condition="in_array($GLOBALS[forumid], array(XX,XX,XX,XX))">THE CODE</if>

For usegroup ID :

<if condition="in_array($bbuserinfo[usergroupid], array(XX,XX,XX,XX))">THE CODE</if>

For the both :


<if condition="in_array($GLOBALS[forumid], array(XX,XX,XX,XX)) AND in_array($bbuserinfo[usergroupid], array(XX,XX,XX,XX))">THE CODE</if>


If you don't want some forumid or usergroupid access to the dice just use
!in_array instead in_array.

cclaerhout
05-31-2006, 05:15 PM
I've updated again RPG DICE archive... I've forgot to rename one picture this morning :D I musn't be awaken.

To make me forgiven, i've uploaded a new blue dice set in option.

Click here to see the post (https://vborg.vbsupport.ru/showpost.php?p=993225&postcount=93)

Emmy2
05-31-2006, 05:18 PM
cclaerhout, thank you so much! I will try it out. Quick question though, do I need to use an array if it's just one forum I want in there?

cclaerhout
05-31-2006, 05:21 PM
cclaerhout, thank you so much! I will try it out. Quick question though, do I need to use an array if it's just one forum I want in there?
Using one won't kill your forum ;)

Just use that syntax :
<if condition="in_array($GLOBALS[forumid], array(XX))">THE CODE</if>

If you want to add a parameter later, it would be easier with the array syntax.

Eikinskjaldi
05-31-2006, 06:05 PM
He makes a very good point, its not how id do it for a released hack with options page, but for this hack this is the smart way to go, at least for now, I havn't decided if the re-write will use option pages, maybe.

Emmy2
05-31-2006, 06:45 PM
okay thanks, I'll give it a try!

cclaerhout
05-31-2006, 10:45 PM
RPG DICE
Version 2.0

>Credits :
-Dice Roll (original script) by Rigel Kentaurus
-Ported to vB 3.5 by Eikinskjaldi
-RPG version developped by C?dric Claerhout
-Thanks to Emmy2 for her help

>What does this hack do ?
It gives your forum a RPG Dice system.

>Is it hard to install ?
No at all !
-Download a set of dice (red or blue at the moment) then upload the images to ./images/dice in your main forum directory,
you will need to create the dice folder.
-Go into ACP and upload the XML through the product manager.
-Go to vBulletin options (admincp) and configure RPG Dice.

>Is there any bug ?
Unfortunately yes. Just one. The user interface dice buttons doen't work with wysiwyg editor. Solution : tell your members to click on the A/A button in the top right corner of the editor.

>Functionalities :
-(nice :D)user interface to throw the dice integrated both in classic editor and quickreply
-admincp configuration to choose usergroupid and forumid
-type of dice : D4, D6, D8, D10, D12 and D20
-Dice pictures in PNG format
-installation only requires one xml file thanks to vB product import system

cclaerhout
05-31-2006, 10:54 PM
I still haven't had my answer to a question i've asked several times above. Can i distribution the french version of this hack on vbulletin-fr.org ?

Eikinskjaldi
06-01-2006, 12:55 AM
I said yes a page back....

Emmy2
06-01-2006, 01:00 AM
Thanks to Emmy2 for his help
Emmy2 is a her. ;)

cclaerhout
06-01-2006, 01:20 AM
I said yes a page back....
You said i can translate it but not distribute it in french vB forum ;)


Emmy 2 is a her.
:rolleyes: Sorry :D
I will correct it in the archive.

cclaerhout
06-01-2006, 01:32 AM
Corrected ;)

Emmy2
06-01-2006, 11:54 AM
thanks cclaerhout!

Just an update on what I'm doing...

Remember I spoke of installing this mod more than once to play different games? Well, I took cclaerhout's 2.0 xml file version of the script (the one WITHOUT the user interface), here in this post:

https://vborg.vbsupport.ru/showpost.php?p=989708&postcount=69

and replaced all instances of "dice" with "playcard". Then I installed it and it created a new game using [playcard] as the bbcode. (I also changed the maximum number of images from 30 to 52 in the xml file).

I found a nice set of public domain card images to use here:

http://www.greywyvern.com/webslavent?msg=183

I renamed them 1.png through 52.png. Then I had to change the playcard template to $points.png instead of $points.gif since the images are a different format. Then I used Eikin's drop down script to code a menu to choose how many cards to draw out of the deck.

I'm also going to do the same thing with "alphadice"...that is, install a version of the game that rolls alphabet letters instead of numbers.

The possibilities for games are endless. My forum is not an RPG. But users could do something like this....roll a dice (a number) and an alphabet dice (a letter)...then you have to make up that number of words beginning with that letter that pertain to the tv show (my forum is about a tv show). So, roll a 5 and a B...5 words that start with B about the tv show. We could play boggle with the alphabet or hold lotteries with numbers.

Just lots of variations for games to come up with.

My toolbar menu is attached (it would only show in the Games forum, using cclaerhout's array code). First there's the "dice" game, then "alphadice", then "playcard". This is just a mock-up...I'll try and get better images.

Because each game (dice, alphadice and cards) has a set number of "faces" in my setup (my dice have 6 sides, there are 26 letters in the alphabet, and 52 cards in a deck) so my drop down menu only contains the number of rolls to make (or cards to draw).

So long story short, I now have several games and combinations of games to play on my forum. The only thing I need is an adjustment to the card script that would allow only ONE instance of each card per thread (there can't be two aces of hearts in a game).

So....[insert pleading voice here] can anyone help me to tweak the script for that game so only one instance of each card is drawn per thread? I am SO CLOSE to having a complete game feature for my members to use...just need that one final element. Anyone?

Ziki
06-01-2006, 12:28 PM
So does this work now?(Not RPG dice)

Emmy2
06-03-2006, 03:44 PM
As far as I know all the bugs are worked out.

Another question...

Any idea how I use text instead of images for the results of the dice roll? I think someone mentioned they were doing this. I get as far as creating 1.txt, 2.txt, 3.txt etc. files but then I don't know how to modify the templates so it uses the text in those files instead of an image url.

Any ideas?

Emmy2
06-08-2006, 11:35 AM
I don't know if anyone needs this, but I believe we concluded that the number of dice faces could only go up to 100 (if you altered the code from the original 30 to 100). However, I think I just made mine able to go higher. Here's how:

In dice_process_data change this:

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

to this:

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


and then change this line further down to however fany faces you want (where my 999 is):

if ($faces[$i] >= 2 && $faces[$i] <= 999)

Again, provided you have images up to whatever maximum number you choose.

It seems to work on my board. Does that seem like correct code?

Eq4bits
06-08-2006, 11:58 AM
Yeah, that's it... I was only interested in taking it to 100 as that is the most my members needed and added the extra '?[0-9]' in another post for code change. and you *may* actually want to add another '?[0-9]' in there. If a person were to roll more than 1 die of 999 faces you'd probably need the extra integer placing... for the resulting points....

soravok
06-09-2006, 10:37 AM
Is the first post in a thread issue fixed and is the mod file for download finished? As in I don't need to feed through the thread here in order to make it work.

Eq4bits
06-10-2006, 08:27 PM
it depends on if you want the basic one or the one with the fancy interface. For the basic use THIS ONE (https://vborg.vbsupport.ru/showpost.php?p=989708&postcount=69)
you may still need to go in and change the 30 for the 'faces' to 100 or whatever it is you may need as well as adding the extra '?[0-9]' as described above in Emmy2's post;
for the fancy interface one cclaerhaut made look at post #117 on page 8 of this thread.
be sure to upload the dice images too :D

soravok
06-12-2006, 02:48 AM
Database error in vBulletin 3.5.4:

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

MySQL Error : Table 'mouldyskull.thread' doesn't exist
Error Number : 1146
Date : Sunday, June 11th 2006 @ 11:46:28 PM
Script : http://mouldyskull.com/admincp/plugin.php
Referrer : http://mouldyskull.com/admincp/plugin.php?do=productadd
IP Address :
Username : aaron
Classname : vb_database

I just tried to install the new version and that's what happened when I tried to import it via product manager, any suggestions?

Eq4bits
06-13-2006, 04:16 PM
Are all your tables in the vb database for your forum prefixed with mouldyskull?
My first thought when looking at the error message you show is that the '.' (period) between mouldyskull & thread should be a '_' (underscore).
Do you have access to phpMyAdmin to where you can go add the dice fields manually?

soravok
06-13-2006, 08:08 PM
What's phpMyAdmin?

RFViet
06-13-2006, 10:37 PM
it would be nice if we can make it worked on vBshout box !!!

RFViet
06-14-2006, 01:48 AM
RPG DICE
Version 2.0

>Credits :
-Dice Roll (original script) by Rigel Kentaurus
-Ported to vB 3.5 by Eikinskjaldi
-RPG version developped by C?dric Claerhout
-Thanks to Emmy2 for her help

>What does this hack do ?
It gives your forum a RPG Dice system.

>Is it hard to install ?
No at all !
-Download a set of dice (red or blue at the moment) then upload the images to ./images/dice in your main forum directory,
you will need to create the dice folder.
-Go into ACP and upload the XML through the product manager.
-Go to vBulletin options (admincp) and configure RPG Dice.

>Is there any bug ?
Unfortunately yes. Just one. The user interface dice buttons doen't work with wysiwyg editor. Solution : tell your members to click on the A/A button in the top right corner of the editor.

>Functionalities :
-(nice :D)user interface to throw the dice integrated both in classic editor and quickreply
-admincp configuration to choose usergroupid and forumid
-type of dice : D4, D6, D8, D10, D12 and D20
-Dice pictures in PNG format
-installation only requires one xml file thanks to vB product import system

Nice !!. If I want 6 face dice only, how to disable other buttons ???

Eq4bits
06-14-2006, 02:16 AM
What's phpMyAdmin?

It's a common interface for administering your databases (I guess that's the best way to 'splain it)... Regardless... however you can get in to actually 'view' your vb database tables, go there.
view the structure of the ***_thread and ***_post tables to be sure the 'dice' field was added.
If not you need to add a field to each table and in both cases name the field 'dice' set them to mediumtxt and NOT NULL.

cclaerhout
06-15-2006, 09:36 AM
Nice !!. If I want 6 face dice only, how to disable other buttons ???

A little gift for you, eventhough it's no more a RPG DICE hack if you only keep D6 :D Use this install xml file instead of the official one.

RFViet
06-15-2006, 01:26 PM
A little gift for you, eventhough it's no more a RPG DICE hack if you only keep D6 :D Use this install xml file instead of the official one.

Let me try it , thanks.
By the way !! do you know why it doesn't work on vBshout box ?? we can use other bbcode but dice roller !!!

soravok
06-16-2006, 03:52 PM
It's a common interface for administering your databases (I guess that's the best way to 'splain it)... Regardless... however you can get in to actually 'view' your vb database tables, go there.
view the structure of the ***_thread and ***_post tables to be sure the 'dice' field was added.
If not you need to add a field to each table and in both cases name the field 'dice' set them to mediumtxt and NOT NULL.

Is there a place I can download/install this application for viewing my DB's?

Eq4bits
06-17-2006, 05:24 PM
try looking in the admincp your host provides you, that's how I get to mine... i just click a link from there and it opens it.

soravok
06-18-2006, 06:49 PM
Well I'm pretty sure I don't have an admincp from my host, I might try and install it though... Any other thoughts on how this could possibly be fixed?

Eq4bits
06-18-2006, 07:10 PM
The admincp I'm talking about is the same place you go to edit your webpages, where you see all the vbulletin files ... where they are located...

When you installed vbulletin you had to add the name of the d/b for your forum(s) in the config.php... whatever that value is you could use to set a direct path to your d/b in the xml file for this product.
so wherever you saved the xml file on your computer, go to where it's listed, right click, open with>notepad (or whatever editor you use) then
look for
<installcode>

$db->hide_errors();
$db->query_write("ALTER TABLE `" . TABLE_PREFIX . "post` ADD `dice` MEDIUMTEXT NOT NULL ;");
$db->query_write("ALTER TABLE `" . TABLE_PREFIX . "thread` ADD `dice` MEDIUMTEXT NOT NULL ;");
$db->show_errors();

</installcode>
-
<uninstallcode>

$db->hide_errors();
$db->query_write("ALTER TABLE `" . TABLE_PREFIX . "post` DROP `dice` ");
$db->query_write("ALTER TABLE `" . TABLE_PREFIX . "thread` DROP `dice` ");
$db->show_errors();

</uninstallcode>
THEN change it as follows... Making the asterisks the prefix you used for all your other tables (that you found in your config.php file)
<installcode>

$db->hide_errors();
$db->query_write("ALTER TABLE `****_ post` ADD `dice` MEDIUMTEXT NOT NULL ;");
$db->query_write("ALTER TABLE `****_thread` ADD `dice` MEDIUMTEXT NOT NULL ;");
$db->show_errors();

</installcode>
-
<uninstallcode>

$db->hide_errors();
$db->query_write("ALTER TABLE `" . TABLE_PREFIX . "post` DROP `dice` ");
$db->query_write("ALTER TABLE `" . TABLE_PREFIX . "thread` DROP `dice` ");
$db->show_errors();

</uninstallcode>
Hopefully THAT will work.

soravok
06-19-2006, 01:59 AM
Okay I'll give that a shot, but not everyone runs thier web server through a control panel interface. Mines attached to my ~/ on my box's user account.

soravok
06-19-2006, 02:13 AM
Okay thanks that did fix the problem, but it still won't let me post a roll on the first post of the forum. Any idea when / if that will be fixed?

Eq4bits
06-19-2006, 03:15 AM
the roll in first post of new thread is fixed if you used the xml file provided on page 5 of this thread, post #69

soravok
06-19-2006, 02:11 PM
Database error in vBulletin 3.5.4:

Invalid SQL:
INSERT INTO vbthread
(postusername, postuserid, title, iconid, visible, forumid, dice, dateline, open, attach, lastpost, lastposter, replycount, hiddencount)
VALUES
('aaron', 1, 'Dice roller testing', 0, 1, 8, 'a:1:{i:0;a:3:{s:5:\"dices\";s:1:\"4\";s:5:\"faces\";s:1:\"5\";s:4:\"data\";a:4:{i:0;i:4;i:1;i:1;i:2;i:1;i:3;i:1;}}}', 1150725773, 1, 0, 1150725773, 'aaron', 0, 0);

MySQL Error : Unknown column 'dice' in 'field list'
Error Number : 1054
Date : Monday, June 19th 2006 @ 10:02:53 AM
Script : http://mouldyskull.com/newthread.php
Referrer : http://mouldyskull.com/newthread.php?do=newthread&f=8
IP Address : 207.6.57.62
Username : aaron
Classname : vb_database


I made the appropriate changes listed above to the new XML file provided in post #69 and I get this error when I try to roll on the first post of a thread.

Eq4bits
06-19-2006, 02:20 PM
It still looks like the 'dice' field has NOT been added into your _thread table... Are all your tables vbtablename? usually from my experience the tables are preceeded with ****_tablename

Are you able to run a MySQL query to add the fields yourself?

Unless you have some way of accessing your vbulletin database and adding the 'dice' field yourself, or running the sql query, I'm not really sure what else to advise.

I must admit, I'm still trying to get used to the product and plug-in process since switching to vB from phpbb2 (where EVERYTHING was a find/copy/paste-before/after/replace and adding tables/fields/etc was 'done by hand') While I'm glad for that learning experience the products and plug-ins are such a time saving convenience.

soravok
06-20-2006, 05:57 PM
Couple of bugs I noticed, if you preview a roll it deletes your roll syntax & if you edit a previous post with a roll it deletes your roll syntax. Any thoughts on if this is going to be fixed?

Eq4bits
06-20-2006, 06:13 PM
no it shouldn't be fixed... keeps a player from ummmm 'cheating' by editing the roll if they don't like the result ;)

soravok
06-20-2006, 06:50 PM
Why not make it retain the syntax but reroll the values everytime the forum is edited or previewed then have the post say "Values were edited @ such and such time" and just have the preview values be rolled seperately from the submitted values. Makes sense to me that way you can't cheat.

WNxWakko
06-20-2006, 09:05 PM
This mod totally crashed my server.

I strongly advise against this mod until he cleans up all the bad code.

soravok
06-21-2006, 04:25 AM
This mod totally crashed my server.

I strongly advise against this mod until he cleans up all the bad code.


Odd, it works perfectly for me.

soravok
06-21-2006, 11:27 PM
Is the total amount of dice to be rolled still limited to 5? If not does anyone know what the max is? Also is there a way to disable the images? If say I just wanted it to have numerical outputs?

Eikinskjaldi
06-22-2006, 05:50 AM
for disabling images just change the template to your suiting, may require some php skill for variables.

Iv been on vacation and it has sucked and is still sucking but thats the state of things, As for this code crashing a server, nothing iv seen has done so and no where iv set this up has it crashed.

As for multiple dice fix, someone posted it earlier, page 1 or 2.

Campbell
06-24-2006, 01:33 AM
Hello all -

I have installed this mod from the source files in the lead post. What I receive when I roll dice from the postbit with any editor (quick, new thread, reply, etc) is the code [dice0] in text in the postbit. This is obviously not the die image, but everything else in the postbit works. (Controls etc.)

Can someone validate or post a reply with the latest code and the latest instructions? There are so many files flying through the topic in replies that I can't tell what is current and what isn't.

Alternatively if anyone has seen the error I mention, help a brother out as this functionality would make my life much easier as a RPG site admin.

Best regards,
A

note that my beta board is at http://www.sovereignrpg.com/community head to the Ona's workshop forum to see the test failures.

soravok
06-24-2006, 08:45 PM
Supposedly it's a feature so that you can't cheat, but it would make more sense to have the rolls marked "fixed" if you've edited the post and have the preview button generate a different set of values everytime you press it. So that the previewed rolls and the posted rolls are different.

Campbell
06-24-2006, 11:06 PM
Update -

It seems as if everything works on my forum with the exception of rendering the die images. Very strange. It's not a matter of custom image forum paths due to my skin as the same behavior happens with default skin. Is there any reason why png files wouldn't render on a VB installation using php?

yes I have enabled php in my bbcode area. Thought of that.

note this is on a 3.5.4 clean install

Best,
A


Hello all -

I have installed this mod from the source files in the lead post. What I receive when I roll dice from the postbit with any editor (quick, new thread, reply, etc) is the code [dice0] in text in the postbit. This is obviously not the die image, but everything else in the postbit works. (Controls etc.)

Can someone validate or post a reply with the latest code and the latest instructions? There are so many files flying through the topic in replies that I can't tell what is current and what isn't.

Alternatively if anyone has seen the error I mention, help a brother out as this functionality would make my life much easier as a RPG site admin.

Best regards,
A

note that my beta board is at http://www.sovereignrpg.com/community head to the Ona's workshop forum to see the test failures.

Eq4bits
06-25-2006, 01:12 AM
Did you physically upload the images to your forum(s)/images/dice folder?
I know that sounds like a silly question but some have been under the impression that installing the product puts the images where they are supposed to go..... but you have to ftp/upload the images separately to a dice folder in your vb images file on your server/host server....

I know the png images show up for all my users/members running IE, firefox and mozilla.

As to the limitations of number of dice for the 'original' hack being 5....
The only limit I've personally had is for over 9 dice. To change from 5 limit to 9 limit:
open the xml file in an editor and
FIND
preg_match_all("/\[dice=([1-5])\]([0-9]?[0-9])\[\/dice\]/",$post['message'],$diceresult);
CHANGE TO
preg_match_all("/\[dice=([1-9])\]([0-9]?[0-9]?[0-9])\[\/dice\]/",$post['message'],$diceresult);
before installing/reinstalling/overwriting.

Eq4bits
06-25-2006, 01:34 AM
The dice images in the Dice zip file only go up to 30, therefore if you are using 'faces' higher than 30 the image will not show up.

A blank blue gif is included in the 'blue' folder (after extracting the dice zip file) and a blank white gif is included in the 'white' folder, depending on which you use, for making numbers higher than 30 for faces 31-100.

OR use this attached zip file for blue octagonal dice numbered 1-100 (originally attached to my post as Rukbat on page 3 or 4 of this thread...) they are in gif format

hope this helps :D

Campbell
06-25-2006, 01:48 AM
To answer your question Eq, yes I've uploaded the images.

This is complicated by the fact that I'm on the mac platform, though I've tested using Safari and Firefox and end up with the same end result. I see the php call, but no images.

I opted to use RPG dice due to the dice panel. When I tested the original roller in this thread it worked fine. However, when that roller didn't display images I was able to pull the source path from the broken link and find where my issue was.

With RPG dice, all I get is [dice0] or [dice1] and with no path I have nothing to go on.

Any assistance would be greatly appreciated.

Best regards,
A

Eq4bits
06-25-2006, 01:52 AM
Hmmm, no clue, I haven't used the RPG dice thingy. I *did* go to your dice test thread at your site and the images show up in the last few posts on my puter (Windows XP/Mozilla 1.7.13) *but* they are the funky original dice NOT the RPG dice cclaerhout did in the png format.

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

- for rolling and showing only the results or sum
- for rolling and seeing the result of each dice as well as the sum
- for open rolls

Each of these takes and optional label for the roll, to be included in the tag after the '=' sign, e.g. 4d6 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:

4d6 to get the sum of 4 six sided die.
d% for a percentage roll (same as 1d100)
4d6b3 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 (http://slithytoves.sytes.net/%7Edavid/forums/showthread.php?p=6422#post6422). 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 6 ?

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


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/plugin.php?do=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

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


<?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
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 (https://vborg.vbsupport.ru/showpost.php?p=1017963&postcount=167)'s BBCode dice: http://roleplayerguild.com/f3/new-dice-system-52860/ (RoleplayerGuild.com - New: Dice System.). 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:
.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
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.php?p=1017963&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
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.