View Full Version : Dice Roll for vB3
Kentaurus
02-28-2004, 10:00 PM
Tested in 3.0.7
Update:
The hack has been updated with new instructions, to allow more than one roll per post. If you are updating Please undo the file edits from the previous version before applying the new one. If you are installing this for the first time you're ok.
This hack is most useful to roleplaying communities, but you can also
have fun with it in any forum. It implements a new code, with which
you can do a dice roll. You can roll as much as 3 dices of 30 faces and as
less as 1 dice of 2 faces.
Once you roll the dice it is stored in the post so you cannot roll again even
if you edit the post or whatever.
Please keep in mind the [img] tag should be disabled in the forum where the dice tag is going to be used. It is not mandatory and the hack will work even with the [img] tag enabled but to prevent cheating I would recommend it.
How to use it:
[dice={dices}]{faces}
Example:
25
This will roll two dices of 25 faces each one
6
This will roll one dice of 6 faces
I am attaching a zip with some sample images.. they are not the best ones but they are dices and show the numbers. If someone could make a new set of dices "prettier" than the ones I got I would be grateful :)
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
Some portions of the code are (c) Jelsoft Enterprises Ltd.
ChuanSE
03-01-2004, 01:26 AM
What would be the point of this amigo?
/me just curious =]
Kentaurus
03-01-2004, 01:58 AM
What would be the point of this amigo?
* ChuanSE just curious =]
In my forums we have a role playing section. If you have ever played any role game the ability to do a dice roll come in handy. Other forums would have no use for them.
MrNase
03-01-2004, 09:27 AM
Will
6
do something like 3+4+1+4+6+4?
Kentaurus
03-01-2004, 12:17 PM
Will
6
do something like 3+4+1+4+6+4?
It would.
But it is limited to 3 dices :) You can change that, though.
Gio Takahashi
03-02-2004, 02:50 AM
what is the highest number of dice and sides could you go?
Erwin
03-02-2004, 09:11 AM
Very cool concept. :) You can do lots with this.
Kentaurus
03-02-2004, 03:53 PM
what is the highest number of dice and sides could you go?
By default, 3.
You can edit it to go to any number of dices, to keep it logical I wouldn't put more than the ones that can fit in a screen.
Morrus
03-04-2004, 11:56 PM
By default, 3.
You can edit it to go to any number of dices, to keep it logical I wouldn't put more than the ones that can fit in a screen.
What edits would you need to make to increase the number of dice?
Hoffi
03-05-2004, 08:41 AM
How are they stored in the Post? I searched this if it is impossible to chnage the Value. (OK, directly in the Database only!)
Holidazed
03-05-2004, 08:30 PM
Has not this hack already been done by Madacc at https://vborg.vbsupport.ru/showthread.php?t=61668&highlight=dice for vb2.xx?
I am not saying this is a ripoff of that code. I am just saying that if this hack worked more like that hack, it would be very cool.
Instead of images, have it just do it in text. Maybe if we could ember the roll dice command inside of an existing post, that would be awesome.
Kentaurus
03-06-2004, 08:49 PM
Has not this hack already been done by Madacc at https://vborg.vbsupport.ru/showthread.php?t=61668&highlight=dice for vb2.xx?
I am not saying this is a ripoff of that code. I am just saying that if this hack worked more like that hack, it would be very cool.
Instead of images, have it just do it in text. Maybe if we could ember the roll dice command inside of an existing post, that would be awesome.
I searched for this hack because I needed it in my forum, I wasn't able to find it so I started to code it myself. When I release a hack I don't look into other people vb2 code, that way I keep my hack 100% original.
I have no use for only text, I want the dice to be shown as an image, also I like my syntax to throw the dice so I will stick with it :) I don't know if it is the best one to use but it sounded logical when I designed it.
Kentaurus
03-06-2004, 08:52 PM
What edits would you need to make to increase the number of dice?
I am sorry, i should had make this hack more friendly. If more people use it I would upgrade it to be more friendly to customize. Right now to increase the number of dice
look for
$dice = eregi_replace(".*\[dice=([123])\]([0-9]?[0-9])\[\/dice\].*","\\1 \\2",$post['message']);
Add numbers depending on the number of dice you allow. Ej, for adding support for 4, 5 and 6 dices:
$dice = eregi_replace(".*\[dice=([123456])\]([0-9]?[0-9])\[\/dice\].*","\\1 \\2",$post['message']);
also look for
$post['message'] = preg_replace("/\[dice=[123]\][0-9]?[0-9]\[\/dice\]/i","[dice]",$post['message']);
In a similar way change it to:
$post['message'] = preg_replace("/\[dice=[123456]\][0-9]?[0-9]\[\/dice\]/i","[dice]",$post['message']);
Kentaurus
03-06-2004, 08:55 PM
How are they stored in the Post? I searched this if it is impossible to chnage the Value. (OK, directly in the Database only!)
When a user does a dice roll the result of the roll is generated and stored in the post. Then the post of the user is edited only to contain [dice]
Then no matters if the user edits the post they can no longer change the dice roll, in fact, they only see a [dice]. The results have been already been stored with the post in the database. The only think they could do is to "delete" the dice roll.
Hoffi
03-10-2004, 04:46 AM
When a user does a dice roll the result of the roll is generated and stored in the post. Then the post of the user is edited only to contain [dice]
Then no matters if the user edits the post they can no longer change the dice roll, in fact, they only see a [dice]. The results have been already been stored with the post in the database. The only think they could do is to "delete" the dice roll.
Works great. What should i change to roll 10 and 20 sided Dices. And maybe 12 sided are also needed.
Great would be a option where I can put in the posiible sidenumbers comma seperated.
Hoffi
03-10-2004, 04:54 PM
Hey, there are some undocumentated features in the Code. ;)
I modified my postbit_dice that it shows which dices were rolled.
<fieldset>
<legend><strong>$dicesno W$dicesfaces</strong> mit $dicepoints Augen</legend>
$dicedata
</fieldset>
Thats for me very interesting and it is good so!
mudpyr8
03-25-2004, 04:14 PM
I'll take a look at this. I have a custom dice roller I wrote for phpbb. It handled Hero dice (STUN/BODY), Deadlands, Open Ending, and others. It worked great in phpbb, but I am new to vB so I just have to figure out where to move the functions and what not.
It doesn't store the rolls in the DB, but that hasn't been an issue on our board so I'm more looking for the functionality. If I get some time, I will try to convert it.
On the DB storage: I don't think that will work unless you tie the message ID to the store, and even then someone could create a new message anyway. If you had the [roll] code generate a result and store it in the DB, referencing by some kind of record ID, the roller could just delete the record ID and reroll anyway.
I think the bottom line is to either a) disallow editing at the forum level or b) make it known that any edited post with a roll will be considered a failed roll/minimum roll (forcing a reroll just means the people who roll crappy will edit their post so they will *have* to reroll).
a) is the easiest solution.
Hoffi
03-26-2004, 06:30 AM
It works perfectly how it stores the dice-rolls. Nothing can changed later. But you even can edit your Post.
The Roll ist stored in an extra Database-field of each Message.
mudpyr8
03-26-2004, 02:01 PM
Well, if I get a bad roll why not just delete the whole message and then roll again in a new message?
What about multiple rolls in a single message?
Hoffi
03-27-2004, 08:44 AM
If you can delete your Post, you can do it. But I idsallow Postdeleting.
Only one Roll per Post is possible.
mudpyr8
03-28-2004, 11:09 AM
Just a different approach, I guess. My code allows for multiple rolls per post, which is convenient, but you either have to disallow editing or establish a convention that any message that has rolls in it when edited becomes invalid IF the roll was a success/good. It hasn't been a problem as the people on the boards find it useful enough they don't want to abuse it.
Bad Bunny
04-07-2004, 03:26 PM
Works great! When I make some dice images, I'll be sure to share. ;)
Thanks
Bad Bunny
04-07-2004, 03:44 PM
Works great! When I make some dice images, I'll be sure to share. ;)
Thanks
I just had a thought as I was expirmenting with it...it would be MORE than great if a bbcode could be made for this, so we could have a button to add it in a post, as opposed to having to insert it manually.
mudpyr8
04-07-2004, 11:19 PM
I posted my code so you could play with it if you want. I'm waiting for VeloCD to finish his bbcode admincp before I integrate it.
http://www.tekhed.com/dice/
Bro_Joey_Gowdy
04-08-2004, 02:04 PM
/me clicks install
The General
04-08-2004, 05:11 PM
Cool hack!!!
I run a pretty big D&D forum and this comes in veryVERY handy! :D
Catch-22|BL
04-13-2004, 09:00 AM
Clean and hassle free installation!
I just played a game of craps with myself. ;)
Fluous
05-03-2004, 12:56 AM
in my functions new posts there is this line on line 425 i think
list ($nodices, $faces) = split(" ",$dice);
and it says thats an error, above it are a { and the line below a } any idea? (thats when i go to the forum display
heres what it says
Parse error: parse error in /home/gameraxi/public_html/forum/includes/functions_newpost.php on line 425
Fatal error: Call to undefined function: fetch_emailchecked() in /home/gameraxi/public_html/forum/forumdisplay.php on line 207
Merlin_
05-07-2004, 01:04 AM
Just FYI, "dice" is already plural. A single cube is a "die."
Kentaurus
05-16-2004, 08:17 AM
in my functions new posts there is this line on line 425 i think
list ($nodices, $faces) = split(" ",$dice);
and it says thats an error, above it are a { and the line below a } any idea? (thats when i go to the forum display
heres what it says
Parse error: parse error in /home/gameraxi/public_html/forum/includes/functions_newpost.php on line 425
Fatal error: Call to undefined function: fetch_emailchecked() in /home/gameraxi/public_html/forum/forumdisplay.php on line 207
Please reapply the hack, that is a single line deleted that messed up your code :)
Fluous
05-17-2004, 03:16 AM
Got it. What I don't like is that users can't roll dice more then once per thread. I mean if we're gunna relax and chat. It should be allowed that they can do it. But I must say that it would be easy if you could edit post. But not edit posts that have rolled dice. Like if it wouldn't give you anything to delete. And even if they went and edited the message and deleted everything there. It would still show.
Kentaurus
05-17-2004, 04:09 AM
They can roll more than once per thread, it is once per post :)
They can edit their post, but they cannot edit the dice roll, once rolled it is stored there and the are not able to edit it.
dndog
05-21-2004, 03:39 AM
How can I allow users to roll multiple times per post? Think about it - for a few simple dice rolls, members have to post like 3 or 4 times in a thread.
Bad Bunny
05-21-2004, 07:48 PM
How can I allow users to roll multiple times per post? Think about it - for a few simple dice rolls, members have to post like 3 or 4 times in a thread.
Yeah, that would be really nice indeedy.
Matrixgl
06-02-2004, 09:19 PM
not working on vB 3.0.1
I installed it, everything went smooth, but when I post a reply, the pictures doesnt show up, instead I get the actual code that I put in when I posted.
Like if I post 6, it shows up as 6 in the thread instead of showing the pictures.
Anub1s
06-03-2004, 01:32 AM
i also use 3.0.1. and works great!
maybe you wont create all the templates or miss a line code
Gracias kentaurus =D
Hoffi
06-16-2004, 10:30 AM
not working on vB 3.0.1
I installed it, everything went smooth, but when I post a reply, the pictures doesnt show up, instead I get the actual code that I put in when I posted.
Like if I post 6, it shows up as 6 in the thread instead of showing the pictures.
It works great in vB3.01 - maybe you did not chnage the Code. In the original Code only 3 Dice are allowed. If you enter incorrect Code the BB-Code will still in the Post. After Edit the Post the Dice-BB-Code won't changed.
dndog
07-15-2004, 06:34 PM
Is there anyway I can reproduce this hack to roll more dice by means of creating 10 sets of the dice bbcode (, , etc.)? I think thats a perfect solution to the "one roll per post" problem.
I'm trying to install this on 3.0.6. but the code seems to have changed on functions_newpost.php. I'm not handy enough with php to know what to change or how, so if someone can help I'd appreciate it.
Here's the code in the instructions:
// ### POST NEW POST ###
$DB_site->query("
INSERT INTO " . TABLE_PREFIX . "post
(threadid, parentid, title, username, userid, dateline, pagetext, allowsmilie,
showsignature, ipaddress, iconid, visible, attach)
VALUES
($threadinfo[threadid], $parentid, '" . addslashes($post['title']) . "',
'" . addslashes($post['postusername']) . "', $bbuserinfo[userid], " . TIMENOW . ",
'" . addslashes($post['message']) . "', $post[enablesmilies], $post[signature],
'" . addslashes($post['ipaddress']) . "', $post[iconid], $post[visible], $totalattachments)
");
and here's what I'm looking at on my functions_newpost.php file....
// ### POST NEW POST ###
$DB_site->query("
INSERT INTO " . TABLE_PREFIX . "post
(threadid, parentid, title, username, userid, dateline, pagetext, allowsmilie,
showsignature, ipaddress, iconid, visible, attach)
VALUES
($threadinfo[threadid], $parentid, '" . addslashes($post['title']) . "',
'" . addslashes($post['postusername']) . "', $bbuserinfo[userid], " . TIMENOW . ",
'" . addslashes($post['message']) . "', $post[enablesmilies], $post[signature],
'" . addslashes($post['ipaddress']) . "', $post[iconid], $post[visible], $totalattachments)
");
$post['postid'] = $DB_site->insert_id();
if ($type == 'thread')
{
$DB_site->query("
UPDATE " . TABLE_PREFIX . "thread
SET firstpostid = $post[postid]
WHERE threadid = $threadinfo[threadid]
");
$post['visible'] = $threadinfo['visible'];
}
// now update the attachments .. if we have any visible OR not, otherwise the hourly cleanup will wipe them out
if ($totalattachments)
{
Any ideas how I can work around this? I'm trying to plan an rpg and really need this feature if possible. :ermm:
Lizard King
03-30-2005, 08:33 PM
Is there a way that we can get this working in 3.0.7 ?
Hoffi
04-01-2005, 11:15 AM
Let me take a look how to run this with 3.07 - in the next days i will do this.
Oooh wonderful :) Good luck getting it to work! I'm still in need of it *nods*
Mijae
06-30-2005, 07:22 PM
I just reinstalled this and now I get errors?
http://www.invoid.net/forum/showthread.php?t=5360
The code has been changed I see, whats wrong?
Hoffi
07-14-2005, 12:07 AM
Uh... the upload is a new Version with makes it possible to roll more than one time in an Post. Great!
But how to translate the old ones?
rfelice
10-09-2005, 07:46 PM
Any chance that someone can port this to 3.5?
I haven't the time to look at it just yet.
Dreiko
12-04-2005, 06:16 PM
Yeah, I would love to see this in 3.5 =)
Hoffi
12-15-2005, 06:42 AM
Yea, I did. I just wrote him a PM and read after it, that I can release it without permission.
So I will write a readme file, because for some Features (I added a few... ;)) you need to modify the JavaScript Files. There exist no Hooks. This will be only neccesary If you want a Button in the Editor! I release it this Week, because I must translate it into English. IT's written in Germen. If someone want to help, fell free to contact me.
soravok
01-05-2006, 12:49 AM
Any updates on when a 3.5 version of this will be available?
soravok
03-06-2006, 05:53 AM
Anything anything at all? an Update of some sort?
Hoffi
03-07-2006, 05:39 AM
It works with one Problem. If you roll dice in a Post that starts a Thread there will be an error and the thread isn't created. I must solve this Problem. The second Problem is, that if you have Rolls of the first Version in the Database (the one with only on Roll per Post) the thread is not showing up. If I solve this I release it. If you all want this Buggy Version I can release it as Beta. Maybe some of you have an Idea.
Thaddeus
03-31-2006, 01:26 PM
Shameless bump. Some of us are still waiting for this.
Kentaurus
06-17-2006, 04:59 AM
A nice port for vb3.5 by Eikinskjaldi is here:
https://vborg.vbsupport.ru/showthread.php?t=113972
vBulletin® v3.8.12 by vBS, Copyright ©2000-2024, vBulletin Solutions Inc.