Jump to content

[SOLVED] Skill Calculators.


`Karl

Recommended Posts

I've managed to make a skill calculator for a game I play.

 

However, I want each of the iterations to be highlighted in green in a player can do it, and red if not. Then Yellow if they will be able to do it by the time they reach their goal.

 

However, everyones experiences differs.

 

Level 1 - 0 Exp

Level 2 - 83 Exp

Level 3 - 174 Exp

Level 4 - 276 Exp

 

and so on. A player can have any experience between these levels. such as 182, this would be level 3. So if an iteration required Level 4, they couldn't do it so I would like Level 4 to be highlighted red.

 

So I need the code to figure out which level they are from the experience they give, then highlight the iterations accordingly. I will show you the calculator I've coded, however, I don't want to publicly post it.

 

Thanks

~Karl

Link to comment
https://forums.phpfreaks.com/topic/180648-solved-skill-calculators/
Share on other sites

im not sure if i just read your post wrong but this should be very simple. you can use a simple if block:

 

if($user_xp < 83){
level one
} elseif($user_xp >= 83 && $user_xp < 174){
level two
} elseif($user_xp >= 174 && $user_xp < 276){
level 3
} 

 

You would just do what you needed to do inside of each block

Following on from what you put, I want each thing to highlight according to whether or not a player can do the iteration or not.

 

In theory, this should work:

if($arr['level'] <= $level) {
$colour = "24ff00";
} elseif ($arr['level'] > $level){
$colour = "ff0000";
}

 

$arr['level'] is the level required, which is taken from a database. However, it highlights it all green at the moment, even if a player cannot do the task.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.