MyBB Community Forums

Full Version: DyMy Dice: Parse HTML in post around roll?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi there! This is a question concerning DyMy Dice and I was hoping someone would be able to help me =3

What I'm trying to do is have the /roll 1d6 or whatever replaced with the normal message, but with a <div class="dice">ROLL</div> around it. HTML is not enabled in posts on my board, so I thought this would be a good way to be able to differentiate between faked rolls and real ones.

To combat other possible cheating (deleting, editing) I'm not allowing members to delete their posts in the forums this plugin is used in, and all the posts are going to have an edit log thanks to another plugin I found -- this is the only thing I have left to "cheat-proof".

Now, the problem is this. I was able to get the <div class="dice">ROLL</div> to show up in the post absolutely fine -- the issue is the HTML doesn't "activate", so it literally shows up as I posted it right there without any of the actual styling taking place.

Is there any way to get the posts to allow the plugin's styling without enabling HTML for the posts? Enabling HTML would be kind of counterproductive seeing then members could just copy the div class and type in the HTML no problem.

I tried to change the div into a MyCode, but then you just wrap [dice][/dice] around the roll, and same deal.

This is currently the line I'm trying to edit:

$msg = preg_replace("#/dice {$m[1]}d{$m[2]}\+{$m[3]}#i", "<div class=\"dice\">{$m[1]}d{$m[2]}+{$m[3]} rolled for a total of: {$total} {$dice}</div>", $msg, 1);

I am not very PHP savvy; what little I know was all self-taught, so I'm struggling to figure out what to do in this scenario -- like if I just need to get a hook added on, or what. Any help would be appreciated.
Pretty soon I'll be releasing a new version of this plugin that totally eliminates cheating by making rolls separate from the post.
Ah, okay =3 That would be fantastic! I'll just monitor the forum more closely for potential issues until that's released then rather than mess with the headache of me not being PHP savvy xD

Thanks for the update, Dylan!
I know the thread is fairly old now, but I was wondering about the status of the new version, Dylan. Were you able to update the dice yet? The current version v1.1 (as of May 12, 2014) still allows dice rolls to be edited.