The Arcive of vBulletin Modifications Site. |
|
|
#1
|
|||
|
|||
|
Hi,
Can anyone tell me why this won't work? It's for creating rainbow usernames but for some reason it doesn't work. Code:
if( strpos( $user['musername'], 'rainbow: true;' ) !== false )
{
$i = $b = 0;
$username = '';
$colours = array('d31539', 'ff7e00', 'ffc20e', '90d125', '187acb', '6f3198', 'ab1d8e');
while( $i < strlen( $user['username'] ) )
{
if( $b > ( count( $colours ) - 1 ) ) $b = 0;
$username .= '<span style="color: #' . $colours[ $b ] . '">' . $user['username'][$i] . '</span>';
++$b;
++$i;
}
$user['musername'] = '<strong>' . $username . '</strong>';
Code:
<strong style="color: #FFBC58; rainbow: true;"> Code:
</strong> |
|
#2
|
|||
|
|||
|
You have to split the string up into an array. Here's what I got working:
Code:
function rainbow($str)
{
$array = str_split($str);
$i = $b = 0;
$str = '';
$colours = array('d31539', 'ff7e00', 'ffc20e', '90d125', '187acb', '6f3198', 'ab1d8e');
while( $i < count($array) )
{
if( $b > ( count( $colours ) - 1 ) ) $b = 0;
$str .= '<span style="color: #' . $colours[ $b ] . '">' . $array[$i] . '</span>';
++$b;
++$i;
}
return $str;
}
|
|
#3
|
|||
|
|||
|
What hook location did you use? Could you post a screenshot of it?
For some reason, it turns quite a lot of my text a yellow colour but no rainbow effect. |
|
#4
|
|||
|
|||
|
I found that the code you posted in post #1 works using hook fetch_musername, but you're just missing a closing '}' at the end.
|
|
#5
|
|||
|
|||
|
Quote:
Edit: Got it working. You can close this thread. |
![]() |
|
|
| X vBulletin 3.8.12 by vBS Debug Information | |
|---|---|
|
|
More Information |
|
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|