Jump to content
MakeWebGames

Quick help please


shrek1609

Recommended Posts

Re: Quick help please

This is what I use to change the color of my staff usernames

 

if($r['user_level'] > 1 ) { $r['username'] = "<font color=#FF00D4>{$r['username']}</font>}

 

but if you want to make it that way on the mainmenu and stuff like for when a staff member can see their own name then this should work

 

if($ir['user_level'] > 1 ) { $ir['username'] = "<font color=#FF00D4>{$ir['username']}</font>}

 

You can change the color to whatever you want it to be, I use hot pink cause one of my staff didn't think I would. lol

Link to comment
Share on other sites

Re: Quick help please

Here add this into ur header:

$t = mysql_query("SELECT * FROM users WHERE userid='{$_GET['u']}'") or die(mysql_error());

$c = mysql_fetch_assoc($t);

if($c['user_level'] == 2 || $ir['user_level'] == 2) {

$r['username'] = "<font color=red>{$r['username']}</font>";

$ir['username'] = "<font color=red>{$ir['username']}</font>";

}

if($c['user_level'] == 3 || $ir['user_level'] == 3) {

$r['username'] = "<font color=blue>{$r['username']}</font>";

$ir['username'] = "<font color=blue>{$ir['username']}</font>";

}

if($c['user_level'] == 5 || $ir['user_level'] == 5) {

$r['username'] = "<font color=yellow>{$r['username']}</font>";

$ir['username'] = "<font color=yellow>{$ir['username']}</font>";

}

Then the username will appear in the color as u want on the view user and on every page you use ur name will appear in the color i hope unless your other code dont destroy and stuff.

Floydian could help you a bit with my code.

Link to comment
Share on other sites

Re: Quick help please

soz killah, there isn't much I can do with that. It looked interesting, but closer inspection showed me number one: you did select * which would be a big waste if all you want is the username...

Secondly, that will only affect one username, not all usernames on a page. so, there's no sense in adding that to the header if it can't add color to all usernames.

Personally, I take userid's in the database, and run them through a function I call: profile()

that function is used everywhere there is a clickable username, and it can make usernames colorcoded :-) if you want it too. but, ya gotta add the function in everywhere you want to use it.

 

This is not mc code compatible code, but it demonstrates the idea of what my profile code does. Adding in user_level to the query, and then colorizing the names accordingly from there would be a snap, and it's something I may do at some point. It'd take all of 3 minutes to colorize every name on my site ;)

// Link to user profile
function profile($id) {
$q = sprintf('select username, user_id from users where user_id = %d limit 1', (int) $id);
$query = query($q);
if (mysql_num_rows($query) < 1) {
	$username = "User does not exist";
}
else {
	list($name, $id) = fa($query);
	$profile = <<<EOT
[url="index.php?p=view&case=view&user_id=$id"]$name[/url] [$id]
EOT;
}
return $profile;
}
Link to comment
Share on other sites

Re: Quick help please

I converted this to mccode based:

// Link to user profile

function profile($id) {

$q = sprintf('select username, userid from users where userid = %d limit 1', (int) $id);

$query = query($q);

if (mysql_num_rows($query) < 1) {

$username = "User does not exist";

}

else {

list($name, $id) = fa($query);

$profile = <<<EOT

$name [$id]

EOT;

}

return $profile;

}

And floydian my code would work only for viewusers.php and every other page the actual user looks at because of the $ir and the $r since basicly thats the most common used var's in mccodes :lol:

Link to comment
Share on other sites

Re: Quick help please

in my personal opinion the only pages you really need to color code the names would be usersonline, userlist, and viewuser. Because if someone is staff they would know and wouldn't really need their name to be colored on the main page. So like I said if it is on either of those 3 then I can help ya with it, if it is any of the others then there isn't much I could do lol.

Link to comment
Share on other sites

Re: Quick help please

killah, you are simply wrong about how your code would work.

first and foremost, the $r variable WOULD NOT be set before the header executes so it's pointless, and I know you could not have tested the code out, and if you did, you would see that it would not work that way.

aye caramba....

Link to comment
Share on other sites

Guest Anonymous

Re: Quick help please

Well as a hint... I use a function called name_format... which basically performs various tricks...

 

function name_format( $user )
{
$donator_image = "";

if ($user['is_a_staff_member'])
{
	$link_color = "red";
}
else if ($user['is_a_donator'])
{
	$link_color = "green";

	$donator_image = "[img=donator.png]";
}
else
{
	$link_color = "blue";
}

return sprinf
(
	"[url='view-user-profile.php?user-id=%u']%s%s[%u][/url]",

	$user['id-number'],
	$link_color,
	$user['name'],
	$donator_image,
	$user['id-number']
);
}

 

Then everytime I want to display a users name (nicely colored and with a little donator image) I just call:

 

echo name_format($user);

 

Simple!

Link to comment
Share on other sites

Re: Quick help please

Nice function Nyna ;)

killah, I see what you mean, but unfortunately it isn't going to work that way.

Consider Nyna's function, it tests to see if a name is a staff members name (in generic terms of course) or a regular player, and if they are a regular player it checks to see if they are a donor.

In order to do that, you have to have a name (or userid or some other data linked to the user such as donor_days).

When $h->startheaders() is called, you won't have any of that data.

Well, I'm not sure if I can explain it 100% perfect, but hopefully that gets the point across.

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...