Jump to content
MakeWebGames

A Somewhat Gradient Name


SMOKEY_TEK

Recommended Posts

i've done this a couple months back i think.. i did something with an if check (for example let your script check for.. if this player has name color 100 , 110 , 120, 130 etc (in the database) and if as example is 110 than let him make the names in the script that color... ehm hard to explain with the right codes atm but the idea is good, and just insert an table in your database players info place^^ ..

maybe if someone does understand all im saying he could help you further now<.<

Link to comment
Share on other sites

Are you trying to this automatically or let the user type in bbcode to do it themselves?

if you want to do it automatically, it is a very simple and easy code where you can change the colors up top, or make them database variables and let the user change them.

Demo: http://www.pure2012.com/testcolor.php

 

[noparse]
<?

## edit these
$username="SMOKEY_TEK";
$color1="#FF0000";
$color2="#000000";

## do not edit this
$var="{$username}";$math=strlen($var);$flip=1; $x=0; while($math > 0){ if($flip == 1){ $char=substr("$var",$x,1); $name.="<font color='$color1'>$char</font>"; $flip=2; $math=($math - 1); $x++; $flip=2; }else{ $char=substr("$var",$x,1); $name.="<font color='$color2'>$char</font>"; $math=($math - 1); $x++; $flip=1; } }

## show name (style this)
//echo "<b>".$name."</b>";
echo $name;

?>
[/noparse]

 

your welcome makeweb world, you should click +1 to my rep on this thread :)

Edited by runthis
Link to comment
Share on other sites

Are you trying to this automatically or let the user type in bbcode to do it themselves?

if you want to do it automatically, it is a very simple and easy code where you can change the colors up top, or make them database variables and let the user change them.

Demo: http://www.pure2012.com/testcolor.php

[noparse]
<?

## edit these
$username="SMOKEY_TEK";
$color1="#FF0000";
$color2="#000000";

## do not edit this
$var="{$username}";$math=strlen($var);$flip=1; $x=0; while($math > 0){ if($flip == 1){ $char=substr("$var",$x,1); $name.="<font color='$color1'>$char</font>"; $flip=2; $math=($math - 1); $x++; $flip=2; }else{ $char=substr("$var",$x,1); $name.="<font color='$color2'>$char</font>"; $math=($math - 1); $x++; $flip=1; } }

## show name (style this)
//echo "<b>".$name."</b>";
echo $name;

?>
[/noparse]

your welcome makeweb world, you should click +1 to my rep on this thread :)

Over-complicated...

<?php
$username="SMOKEY_TEK";
$colours = array (
   'even' => '#FF0000',
   'odd' => '#000'
);

$length = strlen($username);
$newName = '';
for ($i = 0; $i < $length; $i++) {
   $state = (($i+1) % 2 == 0) ? 'even' : 'odd';
   $newName .= '<span style="color: '.$colours[$state].'">'.$username[$i].'</span>';
}

echo $newName;

Would be a simpler method, also much easier to read.

Or the link RulerOfZu posted.

Or even http://blog.kungf.eu/wp-content/uploads/gradient.class.phps, may be a more suitable option, if you're using it for multiple members.

Edited by Djkanna
Link to comment
Share on other sites

Over-complicated...
<?php
$username="SMOKEY_TEK";
$colours = array (
   'even' => '#FF0000',
   'odd' => '#000'
);

$length = strlen($username);
$newName = '';
for ($i = 0; $i < $length; $i++) {
   $state = (($i+1) % 2 == 0) ? 'even' : 'odd';
   $newName .= '<span style="color: '.$colours[$state].'">'.$username[$i].'</span>';
}

echo $newName;

Would be a simpler method, also much easier to read.

I get this error: Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ')' in /home/hitmanm1/public_html/spicedup.php on line 6

Line 6 follows:

$colours = array (
Link to comment
Share on other sites

Over-complicated...
<?php
$username="SMOKEY_TEK";
$colours = array (
   'even' => '#FF0000',
   'odd' => '#000'
);

$length = strlen($username);
$newName = '';
for ($i = 0; $i < $length; $i++) {
   $state = (($i+1) % 2 == 0) ? 'even' : 'odd';
   $newName .= '<span style="color: '.$colours[$state].'">'.$username[$i].'</span>';
}

echo $newName;

Would be a simpler method, also much easier to read.

Or the link RulerOfZu posted.

Or even http://blog.kungf.eu/wp-content/uploads/gradient.class.phps, may be a more suitable option, if you're using it for multiple members.

Djkanna your the man coded it in my game less than one hour with that code thanks for the post users are happy with the new names

Link to comment
Share on other sites

Like all coding it can be streamlined and optimized which is what DJK did here. If you cannot accept this maybe you should be doing something else.

says the guy whose main coding expertise (at least what you are advertising) is mccodes.

 

Would be a simpler method, also much easier to read.

Why would he need to read it easier, hes plugging into a functions page and never looking at it again except maybe to change the colors. Also, take a closer look, mine is alot easier to read, all you need to know is the name, and colors.

 

Or even http://blog.kungf.eu/wp-content/uploads/gradient.class.phps, may be a more suitable option, if you're using it for multiple members.

Both of our scripts would work fine for multiple members.

"The while loop 90% of the time is indeed slightly faster (than the for loop)" according to phpbench.com

The point is, both scripts work and work at milliseconds away from each other. So whats the big deal. In my own benchmark test against both of our scripts and 1000 users, we were equally as fast 95% of the time and my script doesn't have to use any inline styling, standard html guaranteed to work any and everywhere in any browser/os.

Edited by runthis
Link to comment
Share on other sites

Ive been coding a long time in php, asp, asp.net and have produced custom code and modifications for ecommerce software and if your referring to rulerofzu.com its been developed much further than mccodes which you would expect from a successful game.

Those with limited foresight see mccodes as a run of the mill limited base engine. If you take that engine with a goal in mind rewrite and develop further then you have something completely different.

I only advertise zu in my sig here as its a game community and I dont need to advertise my other work or projects here as I am not desperate to prove anything.

Link to comment
Share on other sites

we could further improve the script by taking out the inline style and adding the colors to the linked stylesheet with a class. We could also shorten all the variables too. Also by removing

$newName = ''; not needed to dot-add in php

 

<?php
$u = "SMOKEY_TEK";
$l = strlen($u);
for ($i = 0; $i < $l; $i++) {
   $nN .= "<span class='c{$i}'>".$u[$i]."</span>";
}
echo $nN;
?>

 

we could improve the script further by making it three lines and removing un-needed white space (like the whitespace surrounding equal signs, ew) .

 

<?php
$u="SMOKEY_TEK";
$l=strlen($u); for($i=0; $i < $l; $i++){ $nN.="<span class='c{$i}'>".$u[$i]."</span>"; }
echo $nN;
?>

 

 

 

I dont need to advertise my other work or projects here as I am not desperate to prove anything.

You are the only one in this thread advertising anything, and you further advertise by bringing up your years of technical expertise. just drop it

Edited by runthis
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...