DELETE-ME-NOW- Posted August 13, 2010 Posted August 13, 2010 Now ive been trying staff colours, and ive been using this code in globals.php function username($user_level,$username) { $staff_colours = array( 0 => '#000', 1 => '#fff', 2 => '#CC0', 3 => '#FFC', 5 => '#006' ); $return_data = (array_key_exists($user_level, $staff_colours)) ? '<span style="color: '.$staff_colours[$user_level].';">'.$username.'</span>' : $username ; return $return_data; } echo username($ir['user_level'],$ir['username']); Ive put it in the right place in that file, but it still wont change the colour of staffs names on the site :/ So whats wrong with that code? Quote
Dominion Posted August 13, 2010 Posted August 13, 2010 well take it out of globals.php and use a file like this and see if it errors to test the function <?php include "globals.php"; function username($user_level,$username) { $staff_colours = array( 0 => '#000', 1 => '#fff', 2 => '#CC0', 3 => '#FFC', 5 => '#006' ); $return_data = (array_key_exists($user_level, $staff_colours)) ? '<span style="color: '.$staff_colours[$user_level].';">'.$username.'</span>' : $username ; return $return_data; } echo username($ir['user_level'],$ir['username']); ?> if it errors post the error if it shows your name as whatever colour you have set it to then your using the function wrong >< Quote
DELETE-ME-NOW- Posted August 13, 2010 Author Posted August 13, 2010 hmm. well the function is working cause when i goto that file, the colours are working. But how come when i put it in globals.php, it doesnt change the colour of you name on the rest of the pages? Quote
Dominion Posted August 13, 2010 Posted August 13, 2010 i am not trying to patronise you but did you just add the function and do nothing else ? Quote
DELETE-ME-NOW- Posted August 13, 2010 Author Posted August 13, 2010 Yea :/ But as globals loads on every page, that functions changes every name? Right? Sorry if im wrong XD im still a noob :( Quote
rulerofzu Posted August 13, 2010 Posted August 13, 2010 Functions are not automatic. You are specifying a set of instructions which will be processed every time you call the function name. So through your game if you wish to use that function then where you have $ir['username'] change it to username($ir['user_level'],$ir['username']) Quote
DELETE-ME-NOW- Posted August 13, 2010 Author Posted August 13, 2010 ahh thanks. Ill try it. Yea MWG did ^ ^. I got the code from another thread Quote
Paul Evans Posted August 13, 2010 Posted August 13, 2010 Yeah the member MakeWebGames produced it as a example i believe, i use it on my game but a little more advanced. Quote
bladewolf2010 Posted August 14, 2010 Posted August 14, 2010 whats it like on your site paul. everything is little more advanced on your site. Quote
rulerofzu Posted August 14, 2010 Posted August 14, 2010 That would be as Paul has and is still learning PHP rather than copying with no idea what it is your copying. No offence but at least attempt to learn and understand what it is your copying! I use something like it on zu. More advanced too :D Quote
Paul Evans Posted August 14, 2010 Posted August 14, 2010 mine works out the colours linking (which uses my link function) and optional adds image (don't ask) also implicating some other upgrades at a later date, when MakeWebGames coded that it was just a example i suggest you look up the functions used on php.net Quote
DELETE-ME-NOW- Posted August 14, 2010 Author Posted August 14, 2010 ok thanks for the help guys :D As i sayed, im still a noob as ive only been coding for a few months, but im improving :o Quote
Dominion Posted August 14, 2010 Posted August 14, 2010 its nice to know people are learning use php.net to learn away from mccodes to many people are locked to using the database class and $ir things @bladewolf2010 - anything free should be changed and made better before going on your site after all you don't want a site like the 1000's already up... Quote
Paul Evans Posted August 14, 2010 Posted August 14, 2010 Well MakeWebGames coded it as a example we simply improve before putting it on our games :) and we give him props for it. Quote
bladewolf2010 Posted August 15, 2010 Posted August 15, 2010 @dominion I completely understand it should be changed up before going on a website. but most people want the next million dollar game like torn so they create same thing well attempt to :P Quote
Dominion Posted August 15, 2010 Posted August 15, 2010 and the ones that are just copys are the ones that fail so bad :P 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.