rednspirited Posted July 24, 2019 Posted July 24, 2019 I want to change the color of staff names by the staff level how would I go about coding that so it out ranks the donor colored names? Quote
Magictallguy Posted July 24, 2019 Posted July 24, 2019 You'll have to edit all instances of a username being displayed. What have you got and what have you tried so far? Quote
Shades Posted July 24, 2019 Posted July 24, 2019 Do you have a link? I wouldn't mind helping out. Quote
rednspirited Posted July 24, 2019 Author Posted July 24, 2019 heres what i got } if ($r['donatordays']) { $r['username'] = "<font color=red>{$r['username']}</font>"; $d = "<img src='donator.gif' alt='Donator: {$r['donatordays']} Days Left' title='Donator: {$r['donatordays']} Days Left' />"; } else if ($r['user_level'] == 2) { $r['username'] = "<font color=blue>{$r['username']}</font>"; $d = } if ($r['laston'] >= time() - 15 * 60) { $on = "<font color=green><b>Online</b></font>"; } else { $on = "<font color=red><b>Offline</b></font>"; } Quote
Shades Posted July 24, 2019 Posted July 24, 2019 (edited) How about creating a function? function username($userid) { global $db, $ir; if(!$userid) { return 'N/A'; } $colours = array( 1 => 'brown', 2 => 'gold', 3 => 'blue' ); $select = mysql_query("SELECT `username`, `user_level` FROM `users` WHERE `userid` = " . $userid); if(!$mysql_num_rows($select)) { return 'N/A'; } $user = mysql_fetch_array($select); $ret = ''; if($user['user_level'] > 1) { $ret = "<a href='viewuser.php?u=".$userid."' style='color:".$colours[$user['user_level']].";'>".$user['username']."</a>"; } else if(!$user['user_level']) { $ret = "<a href='viewuser.php?u=".$userid."' style='color:brown;' title='NPC'>".$user['username']."</a>"; } return $ret; } Add that to global functions and when you want to a username to display use e.g. - <?php echo username($r['userid']); ?> You can still add on to this to show donator users and etc. Edited July 24, 2019 by Shades Quote
rednspirited Posted July 24, 2019 Author Posted July 24, 2019 i can try it :) but tomorrow when my mind isnt squashed :) ty for the help and idea :) Quote
Magictallguy Posted July 25, 2019 Posted July 25, 2019 Reason for your staff colours not overriding donator is because you've added them after the donator colouring condition. Flip 'em round (see example below) if ($r['user_level'] == 2) { $r['username'] = "<font color=blue>{$r['username']}</font>"; $d = ''; } elseif ($r['donatordays']) { $r['username'] = "<font color=red>{$r['username']}</font>"; $d = "<img src='donator.gif' alt='Donator: {$r['donatordays']} Days Left' title='Donator: {$r['donatordays']} Days Left' />"; } If you don't mind your staff members also having the donator icon (if applicable), you can set $d between your colour conditions and username output <?php $color = null; if($r['user_level'] == 2) { $color = 'blue'; } elseif($r['donatordays'] > 0) { $color = 'red'; } if($r['donatordays'] > 0) { $titleAlt = 'Donator: '.$r['donatordays'].' Day'.($r['donatordays'] == 1 ? '' : 's').' Left'; $d = ' <img src="donator.gif" title="'.$titleAlt.'" alt="'.$titleAlt.'" />'; } else { $d = ''; } if($color !== null) { $r['username'] = '<span style="color:'.$color.';">'.$r['username'].'</span>'; } // Output echo $r['username'],$d; That being said, I would recommend throwing this logic into a function seeing as there are 120 instances of a username being echoed out somewhere - that's a lot of places to update in order to unify your changes.@Shades's function would get you off the ground. Tweak to your liking and implement across the board! Quote
Shades Posted July 25, 2019 Posted July 25, 2019 Thanks for the advice! Was not sure how I would have been able to do that! Now I know thank you @Magictallguy Quote
rednspirited Posted July 25, 2019 Author Posted July 25, 2019 ok than it is good i was out of it last night :) will try putting it first thanks :) got at least on to change lol but its a work in progress :) Quote
Sim Posted September 10, 2020 Posted September 10, 2020 (edited) I got a mod called VIP Passes. What exactly is a Donator Mod though? Sounds like something I might like to create. B/:) Edited September 10, 2020 by Sim Quote
ags_cs4 Posted September 10, 2020 Posted September 10, 2020 @Danny_T this is old topic and wrong forum to talk about GL, donator mod there is none like what u want check Point Mod by Chris in the market Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.