The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
||||
|
||||
Tag Replacements in vBulletin...
I'm trying to program a new tag replacement (such as quote or color) that would generate a random die throw (dice), and I'm doing it by modifying code from a phpBB hack. I'm asking how I can convert the following code to work with vBulletin:
Code:
$occurances = preg_match_all("#\[dice\]([-\s\w+/*]*?)\[/dice\]#i", $text, $temp); //list($usec,$sec)=explode(" ",microtime()); mt_srand((double)microtime()*1000000);//$sec * $usec); // Loop to fix randomness problem of results when multiple die rolls are made in a single post - Hades for($i=0;$i<=$occurances;$i++) { $dice_seed = mt_rand(); $text = preg_replace("#\[dice\]([-\s\w+/*]*?)\[/dice\]#i", "[dice:$uid]\\1 = $dice_seed [/dice:$uid] $limit", $text, 1); $text = preg_replace("#\[dice=(\\\\\".*?\\\\\")\]([-\s\w+/*]*?)\[/dice\]#i", "[dice:$uid=\\1]\\2 = $dice_seed [/dice:$uid] $limit", $text, 1); } $text = preg_replace("#\[dice\]([-\s\w+/*]*?)=([\s\d]*?)\[/dice\]#i", "[dice:$uid]\\1 = \\2 = Fixed[/dice:$uid]", $text); $text = preg_replace("#\[dice\]([-\s\w+/*]*?)=([\s\d]*?)=\s*?Fixed\s*?\[/dice\]#i", "[dice:$uid]\\1 = \\2 = Fixed[/dice:$uid]", $text); $text = preg_replace("#\[dice=(\\\\\".*?\\\\\")\]([-\s\w+/*]*?)=([\s\d]*?)\[/dice\]#i", "[dice:$uid=\\1]\\2 = \\3 = Fixed[/dice:$uid]", $text); $text = preg_replace("#\[dice=(\\\\\".*?\\\\\")\]([-\s\w+/*]*?)=([\s\d]*?)=\s*?Fixed\s*?\[/dice\]#i", "[dice:$uid=\\1]\\2 = \\3 = Fixed[/dice:$uid]", $text); Code:
$bbcodes['custom']['find']['[dice]'] = 'What goes here?'; $bbcodes['custom']['replace']['[dice]'] = "handle_bbcode_dice('\\2')"; $bbcodes['custom']['recurse']['dice'][0] = array('handler' => 'handle_bbcode_dice'); Thank you to anyone that assists with this. |
#2
|
||||
|
||||
Moved to PHP/MySQL forum
|
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|