Closed Thread
Results 1 to 8 of 8

Thread: Help with custom rank script.

  1. #1
    djkee's Avatar
    djkee is offline Newbie
    Join Date
    Oct 2008
    Location
    Underground
    Posts
    5
    Rep Power
    0

    Question Help with custom rank script.

    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'] > && $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.

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Location
    Advertising world
    Posts
    Many

     
  3. #2
    Join Date
    Jul 2006
    Location
    Amherst, New York, United States
    Posts
    6,277
    Blog Entries
    26
    Rep Power
    20

    Re: Help with custom rank script.

    Code:
    $user['totalgames'] = $user['totalgames'];
    $user['totalcomments'] = 10 $user['totalcomments']; 

  4. #3
    djkee's Avatar
    djkee is offline Newbie
    Join Date
    Oct 2008
    Location
    Underground
    Posts
    5
    Rep Power
    0

    Re: Help with custom rank script.

    LOL thank you sooooo much

  5. #4
    Join Date
    Jul 2006
    Location
    Amherst, New York, United States
    Posts
    6,277
    Blog Entries
    26
    Rep Power
    20

    Re: Help with custom rank script.

    No problem. Should you have any other questions, don't hesitate to ask!

  6. #5
    djkee's Avatar
    djkee is offline Newbie
    Join Date
    Oct 2008
    Location
    Underground
    Posts
    5
    Rep Power
    0

    Re: Help with custom rank script.

    I have another problem

    Whats wrong with this script ?

    Edit: oops i forgot some of those " ; "

    sorry


    Code:
           <?php

        $games 
    $user['totalgames'];
        
    $comments 10 $user['totalcomments'];
        
    $total $games $comments
        
    echo "$total"

        
    echo "<font>Current Rank<br><br></font>";
         if (
    $total && $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>";
        
    ?>
    Thank you

  7. #6
    Join Date
    Sep 2008
    Location
    Australia
    Posts
    4,834
    Blog Entries
    10
    Rep Power
    51

    Re: Help with custom rank script.

    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 easier Also 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!

  8. #7
    djkee's Avatar
    djkee is offline Newbie
    Join Date
    Oct 2008
    Location
    Underground
    Posts
    5
    Rep Power
    0

    Re: Help with custom rank script.

    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 $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 && $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

  9. #8
    Join Date
    Sep 2008
    Location
    Australia
    Posts
    4,834
    Blog Entries
    10
    Rep Power
    51

    Re: Help with custom rank script.

    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!

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 11
    Last Post: 01-20-2011, 12:52 PM
  2. Need help to increase the page rank of website!!!
    By martin.luther in forum Search Engine Optimization
    Replies: 18
    Last Post: 01-21-2010, 10:44 PM
  3. All Rank Images:)
    By Donovan in forum The Lounge
    Replies: 22
    Last Post: 12-31-2008, 07:01 AM
  4. How do I see what I rank for a certain keyword?
    By Kaabi in forum Search Engine Optimization
    Replies: 12
    Last Post: 01-02-2007, 11:08 PM
  5. Which SE do you rank well in?
    By Nightracer in forum Search Engine Optimization
    Replies: 13
    Last Post: 08-01-2006, 07:55 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts