The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#11
|
||||
|
||||
Hmm, a problem I've come in contact with this hack is whether to make the functions return a value relative to the first time they're called, or upon every page refresh.
For example, I'll use the code from my last post: Usage: [random="100"]200[/random] Masked: [random="{option}"]{param}[/random] PHP: rand({option}, {param}); Because vBulletin retains BBCode tags in posts, and doesn't substitute them with hard-coded values (which absolutely makes sense), this would mean upon page refresh a function is called everytime. In the case of functions that return non-static values, like rand(), you're going to get a new random number everytime you refresh the page. I'm not sure if your hack will be affected by this mudpyr8 in a negative way, but let me know your thoughts. I could hard-code the values for specific functions, making the first generated return value replaced with its tag, and upon page refresh it'll never update. This would also be a tad more efficient since you aren't calling custom functions over and over again upon page refresh, but the downside is if you were to ever change the bbcode tag or bbcode function from the AdminCP, the previous instances that have already been posted wouldn't be updated. Although, whether that is a huge concern.. I wouldn't think so. I'll probably add an option for the administrator to decide how they want it. Quote:
As for passing an incorrect amount of arguments, or the wrong datatype of a argument, normally this would result in a parse error. But, just apply the @ in front of a function, and you suppress its error messages. |
#12
|
||||
|
||||
For the dice roller I definitely would not want it to refresh every time, only generate a result the first time. Having an option would be great, even if it was part of the function definition and not an option in the admincp.
Ensuring only strings are passed is fine. Does that mean if they are numerical values they have to be retyped, say using 'int()'? Thanks again. |
#13
|
||||
|
||||
PHP is very lenient on data type handling (unlike, say, c++).
A numerical value can be a string, as long as it is all numbers. A numerical string, however, isn't a true integer value. However it can easily be so by casting: (int) to the string. Still, in many cases a numerical string will work in place of an argument in a function, even if it calls for an int. For example, PHP function rand() only takes integers, yet in this hack the numerical string arguments passed work fine. By the way, I've finished this hack (except for 1 minor bug, although probably major in your case :ermm: ) and will be releasing it shortly. edit: https://vborg.vbsupport.ru/showthrea...threadid=63113 |
#14
|
||||
|
||||
Well, here is the die roller: http://www.tekhed.com/dice/
I won't keep it up forever, but you can try it. The output in the table is what I would return from the function. Thanks for all of your help. http://www.tekhed.com/dice/ |
#15
|
|||
|
|||
Theres a phpBB script that does exactly what your after:
http://www.phpbb.com/phpBB/viewtopic.php?t=124404 If only someone would convert it to vBulletin |
#16
|
||||
|
||||
Thanks. My dice code was already working under phpbb and I've ported it over using the BBCode that calls PHP mod for VB.
The dice roller you linked to doesn't handle, as far as I can tell, open ended dice, Savage World dice, and Hero dice, which mine does. Thanks for the link though. |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|