News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

Dice roll mod ... again.

Started by Adin, February 02, 2005, 08:49:07 AM

Previous topic - Next topic

Ardenn

I modified 1.7 with this code to and only in post.php.  I used the code found on page 3 of the thread.  Works like a charm except when 8's are rolled and then the 8 ) triggers the forum smily.  I fixed that and I love the thing.  Needs to be placed into a true mod though.
Ardenn // Traxxus
http://www.twinwand.com
D&D Play by Post Community Looking for Players and DM's

Deadfire

I agree, as well how did you make the 8 ) not produce a smiley?

Rasyr

Likely the same way you did - with a space...  :D

gwalior

Thank you for this good work to all of you !

It works fine for me, and because I doesn't need the total (playing Vampire the masquerade), I change the code by :

function rolldice($dice, $sides, $sign, $modifier)
{
   global $settings;

   $total = 0;
   $temp = '(';   
   
   if ($dice>40) {return 'Sorry, too many rolls!';}
   if ($sides>100) {return 'Sorry, too many sides!';}
   
   if ($dice > 1)
   {
      for ($i=0; $i < ($dice-1); $i++)
      {
         $dv = rand(1, $sides);
              $temp .= $dv . ', ';
         $total=$total+$dv;
      }
   }
        $dv = rand(1, $sides);
        $temp .= $dv;
   $total=$total+$dv;

   if ($sign == '+')
   {             
      $total=$total+$modifier;
   } elseif ($sign == '-') {
      $total=$total-$modifier;         
   } else {
    $temp .= ')';

            {return '<div style="background-color: #FFFFFF;"><img src="' . $settings['images_url'] . '/dice.gif"  alt=""

/>R&eacute;sultat des ' . $dice . ' d&eacute;(s) ' . $sides .' : ' . $temp . '' ;}
   }   
}


But i have still a problem, I don't know how to stop the background color in white.
If I write text after the dice function, it is written in the background (screen to explain)



Someone could help ?
Thanks

Rasyr

In the code you posted, try changing the following

$temp . '' ;}

to

$temp . '</div>' ;}

Simply put, you aren't closing the div tag that you open just before the image tag.

gwalior

Thank you very much, you're right :  :)

I tried all the places to put the </div> but not where you said !

thanks !

gwalior

What I do :
creating a smiley with code like  :dice #d: for example.
Then click on the smiley and replace # by the number you need, and enjoy.

If you doesn't want the "d" or an other message, you could change the code in the $_POST['message'] code.

nitroglicerino

Could be this available for 2.0?

Sarah4

I can't get this to work with 1.1.7. What am I doing wrong?

I followed the instructions from page 3:

I downloaded the RPG.php file, put it in my /smf/Sources directory.

I then edited Post.php as instructed.

What is the command used to activate the function? I tried :dice 2d6 but it doesnt work.

Do you have to make the server re-parse the core files or something before it will work?

Can someone help me out?

Sarah4

Nevermind. Syntax Error. :)

For anyone confused the correct syntax is :roll 2d6+5:

Or whatever you want obviously ..

Mazinman

I placed the code on my website and it has worked great! My thanks to the creators of it!

Would it possible to apply the code to private messages in the forum so players can send me private dice rolls? If it is possible, could someone please let me know how to do it?

Thank you very much once again! I appreciate it!

gwalior

Up...
Anybody got an idée to make it working in 2.0 ?
There is no more post.php file
Can it works in another file ?

clockworkjoe

awesome. It works great on my forums at hxxp:www.slangdesign.com/forums [nonactive]

Elbos

Who can make this...

:dice subject 1d20:


;)

lordevil

http://custom.simplemachines.org/mods/index.php?action=download;mod=2032;id=116786;image

How can I change this text to white? What file would the text be stored in? Its the Dice roller Mod, I know its been ages ago but it sure will be handy for some forum games we want to run. Thanks for any input.

Arantor

Ask in the mod's support thread, I will NOT answer support questions for that mod here.
Holder of controversial views, all of which my own.


Sarah4

Quote from: shanks on November 06, 2005, 03:54:40 PM
I have now checked the roller with both 1.0.5 and 1.1 RC1, and it works fine for both... aside from the dice gif (but that's hardly important).

I have now also moved the roller functions into their own file. Over time I'll be improving how it works and adding other RPG related figures. This way the amount of editting of core SMF files will be reduced, and most updates can be handled by a simple RPG.php file replacement.

Attached below is the aforementioned RPG.php and an editted post.php file for 1.1. RC1. Simply place each file in the Sources folder. However if you have installed any other mods/alterations and you are unsure if post.php has other changes within it then you'll want to manually edit the file as below:

Find, in Post.php:

preparsecode($_POST['message']);


Add after:

include 'RPG.php';
$_POST['message'] = preg_replace('~:dice (\d+)d(\d+)(\D*?)(\d*?):~ei', "dice('\$1', '\$2', '\$3', '\$4')", $_POST['message']);
$_POST['message'] = preg_replace('~:stats (\d+)d(\d+)(\D*?)(\d*?),(\D+),(\d+):~ei', "stats('\$1', '\$2', '\$3', '\$4', '\$5', '\$6')", $_POST['message']);


One final caveat, being new to php I do not know whether or not the use of include opens up any security risks, but I can't logically think of any. So, until verified by one knowledgeable in php, please understand that you use this at your own risk.

If you prefer to omit the use of RPG.php you may copy and paste the functions into post.php above the line:

function post()


I followed those instructions as I did previously but it does not appear to work with this latest version of SMF 1x.

Here's my files. I added the include for RPG.php that contains the roller functions as instructed in Post.php (its on line 1341).

Can someone tell me if this is wrong? It all looks ok to me tbh.

I am guessing something is missing or wrong that wasnt in the last few verisons of SMF? Or I made some kind of mistake?


Sarah4

Ahh nevermind. Syntax error ..

I was calling the script with :roll 2d6: and its actually :dice 2d6:

God knows why I thought it was roll .. sheesh.

Cassiel


ictus

did anyone get this up and running with smf2.0 as the dice mod in the mod site isn't as good as this one....no open ended or fudge dice :(

Advertisement: