SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Thread: Game/PHP mySQL

  1. #1
    SitePoint Member
    Join Date
    May 2007
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Game/PHP mySQL

    Hi,

    I am developing an RPG game in Unity 3D where player stats, quests, items etc are stored on a mySQL database.

    Tables:

    Players
    id
    player_name
    email_address
    password

    Quests
    id
    npc_name
    quest_name
    quest_text
    reward_id
    required_items

    Player Stats
    id
    player_id
    completed_quests

    Code for returning quests to the game


    PHP Code:
        if(isset($_GET['name'])) {
            
    $player_id 1;
            
    $name $_GET['name'];
            
    $query "SELECT * FROM `Quests` WHERE `npc_name` = '$name'";
            
    $result mysql_query($query) or die('Query failed: ' mysql_error());
        
            
    $num_results mysql_num_rows($result); 
        
            for(
    $i 0$i $num_results$i++)
            {
                 
    $row mysql_fetch_array($result);
                 echo 
    $row['quest_name'] . "*" $row['quest_text'] . "*" $row['npc_name']  . "*" $row['required_items'];
            }
        } 
    What I would like to do is return quests that the player has not completed. Could someone advise me the best approach.

    Thanks

    Jason

  2. #2
    SitePoint Member
    Join Date
    May 2007
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Would it be best to create another table called `completed_quests` and hold the players_id, quest_id, date_completed etc. Then when retrieving a quest it could check this table for completed quests by the players_id.

    Thanks

    Jason


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
  •