vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   Rainbow Username (https://vborg.vbsupport.ru/showthread.php?t=296130)

Black Snow 03-14-2013 09:15 PM

Rainbow Username
 
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>';

I also made the usergroup HTML markup to:
Code:

<strong style="color: #FFBC58; rainbow: true;">
Code:

</strong>

nerbert 03-15-2013 01:51 AM

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;
}


Black Snow 03-15-2013 09:28 PM

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.

kh99 03-16-2013 12:06 AM

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.

Black Snow 03-17-2013 08:41 PM

Quote:

Originally Posted by kh99 (Post 2410265)
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.

Could you post a screenshot if it working? I used the code that nerbert posted with the same hook location you mentioned and it didn't work.

Edit: Got it working. You can close this thread.


All times are GMT. The time now is 08:44 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01147 seconds
  • Memory Usage 1,723KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (4)bbcode_code_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (5)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete