Hello everyone
Its my first post but i really need some help with this script.
The script works great and it does what i want to do but i have decided to change it so when it counts "$user['totalgames']" it will count them as 5 points each and i would also like to include another variable that would be "$user['totalcomments']" and it would represent the total comments made by this user and the script should add them all together and echo the current rank but how would i make the script add 4 points for each "totalgames" or "totalcomments".
Example:
User Teddy has 10 totalgames( total game plays) and 5 totalcomments (comments posted) i want to script to count each game play for 5 points so 10 * 5 = 50 and each comment for 10 points so 5 * 10 = 50 and the total is 100 points
How do i do that ?
I know it sounds confusing but i have no idea how else to explain it
Thanks everyone in advance and if you have more questions please replay and i will check this forum every day.
Here is the script:
Code:<?php
echo "<font>Current Rank<br><br></font>";
if ($user['totalgames'] > 0 && $user['totalgames'] < 10 ) {
echo "Keep Playing you noob.<br>";
}
elseif($user['totalgames'] > 10 && $user['totalgames'] < 20 ){
echo "You are a knight<br><br>";
}
elseif($user['totalgames'] > 20 && $user['totalgames'] < 50 ){
echo "You are a King<br><br>";
}
elseif($user['totalgames'] > 50 && $user['totalgames'] < 100 ){
echo "You are a noob :)<br><br>";
}
elseif($user['totalgames'] > 100 && $user['totalgames'] < 150 ){
echo "You are a noob :)<br><br>";
}
elseif($user['totalgames'] > 150 && $user['totalgames'] < 200 ){
echo "You are the man/woman :)<br><br>";
}
elseif($user['totalgames'] > 200 ){
echo "Holy Cow!!!<br><br>";
}
else {
echo "Error Retreaving Rank<br>";
}
echo "<br><br>";
?>
Thanks everyone in advance.
Code:$user['totalgames'] = 5 * $user['totalgames'];
$user['totalcomments'] = 10 * $user['totalcomments'];
LOL thank you sooooo much
![]()
No problem. Should you have any other questions, don't hesitate to ask!
I have another problem
Whats wrong with this script ?
Edit: oops i forgot some of those " ; "
sorry
Thank youCode:<?php
$games = 5 * $user['totalgames'];
$comments = 10 * $user['totalcomments'];
$total = $games + $comments
echo "$total"
echo "<font>Current Rank<br><br></font>";
if ($total > 0 && $total < 10 ) {
echo "Keep Playing you noob.<br>";
}
elseif($total > 10 && $total < 20 ){
echo "You are a knight<br><br>";
}
elseif($total > 20 && $total < 50 ){
echo "You are a King<br><br>";
}
elseif($total > 50 && $total < 100 ){
echo "You are a noob :)<br><br>";
}
elseif($total > 100 && $total < 150 ){
echo "You are a noob :)<br><br>";
}
elseif($total > 150 && $total < 200 ){
echo "You are the man/woman :)<br><br>";
}
elseif($total > 200 ){
echo "Holy Cow!!!<br><br>";
}
else {
echo "Error Retreaving Rank<br>";
}
echo "<br><br>";
?>![]()
hehe. If you have a problem use a IDE such as Eclipse for PHP so it tells you what exactly is wrong and exactly where as you save it.
It's much easierAlso in MS Word, if you make a spelling error it's underlined Eclipse does the same thing but with syntax for PHP.
jQuery Selectors Tutorial - jQuery Striped Table tutorial - jQuery Events - jQuery Validation
Sorry if I don't post as often as I did, I'll try to get here as much as possible! I'm working my bum off to get this scholarship and other stuff!
Well i have a question thats kind of complicated
I did some more modifications to the script and now it counts 3 variables and adds them together to get the total and then according to that it would display the current player's rank (points).
I would like to include this script on my main front page but i am not sure how to make it look into the database and get all the values, calculate them and display the top player.
The script below does that for just one user and thats the user how is looking into his profile (only for the current profile).
If i show the script on the front page it wont know which user to look for so it wont display the points each user has.
I tried to put some comments and make the script more readable
The part that says i did not wrote this script is the one that came with the website script and i did not wrote it (just copy and paste).
Here is the script so far:
Code:<?php
// calculate the player with most high scores starts here (I did not wrote this script)
$query = "SELECT nameid, player, COUNT(player) AS total FROM games_champs GROUP BY player ORDER BY total DESC LIMIT 3";
$scores = get_games_score("diffquery=" . $query);
$i = 0;
if (count($scores) != 0)
{
foreach ($scores as $score)
{
$i++;
$query = $db->query("SELECT nameid FROM games_champs WHERE `player` = '" . $score['player'] . "'");
$hscore = mysql_num_rows($query);
$d_score = date("d/m/Y @ H:i:s", $score['date']);
$user = get_user("id=" . _sp($score['player']));
echo "<img src='[themedir]rank/" . $i . ".gif' style='border: 0px;'><a class='contentlink' href='" . get_profile_link("id=" . _sp($user['id'])) . "'>{$user['username']}</a> - <b>" . $hscore . "</b> " . language("highscores", true) . "";
}
}
// calculate the player with most high scores ends here (I did not wrote this script)
// Get other values and add them all together starts here
$games = 5 * $user['totalgames'];
$comments = 10 * $user['totalcomments'];
$highscore = 15 * $hscore;
$total = $games + $comments + $highscore;
echo "<div width='100' height='100' border='1'>
Points: $total <br>";
// Get other values and add them all together ends here
// Display different text according to the points user has starts here
echo "<font>Current Rank<br><br></font>";
if ($total > 0 && $total < 10 ) {
echo "Keep Playing you noob.<br>";
}
elseif($total > 10 && $total < 20 ){
echo "You are a knight<br><br>";
}
elseif($total > 20 && $total < 50 ){
echo "You are a King<br><br>";
}
elseif($total > 50 && $total < 100 ){
echo "You are a noob :)<br><br>";
}
elseif($total > 100 && $total < 150 ){
echo "You are a noob :)<br><br>";
}
elseif($total > 150 && $total < 200 ){
echo "You are the man/woman :)<br><br>";
}
elseif($total > 200 ){
echo "Holy Cow!!!<br><br>";
}
// Display different text according to the points user has ends here
// Error Starts here
else {
echo "Error Retreaving Rank<br>";
// Error Ends here
}
echo "</div><br><br>";
?>
Thanks for all the help and if you cant figure it out please let me know and i will post the entire page.
Last edited by djkee; 10-16-2008 at 03:58 PM. Reason: Spelling :D
I don't know MySQL but I can give an idea that I believe that will make it work.
If that returns the user points in the userCP to add it to the front page to show the top players you could do the following;
1. Create a new variable that will set how many users you want to show on the homepage, for example 10.
2. Now create a for or foreach loop that will return the top ten players by connecting to the database and output the results in descending order.
Need more help ask someone that knows MySQL.
jQuery Selectors Tutorial - jQuery Striped Table tutorial - jQuery Events - jQuery Validation
Sorry if I don't post as often as I did, I'll try to get here as much as possible! I'm working my bum off to get this scholarship and other stuff!
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks