Jump to content

Jiraiya

Members
  • Posts

    206
  • Joined

  • Last visited

    Never

Posts posted by Jiraiya

  1. this is the entire code so far i still didnt find any errors

     

    <?php
    
    mysql_connect("database", "username", "password") or die(mysql_error());
    mysql_select_db("members") or die(mysql_error());
    
    $sql = mysql_query("SELECT * FROM users WHERE username = '$username'");
    $row = mysql_fetch_array($sql);
    if ($row['gold'] >= 100) {
      $sql = "UPDATE users SET gold = gold-100, potions = potions+1 WHERE username = '$username'") or die(mysql_error());
    echo "<center>You have bought one health potion.</center>";
    }else{
    echo "<center>You don't have enough gold. Come back when you getmore.</center>";
    }
    
    ?>
    

  2. i checked that and it still shows up white on the web browers

    <?php
    $sql = mysql_query("SELECT * FROM users WHERE username = '$username'");
    $row = mysql_fetch_array($sql);
    if ($row['gold'] >= 100) {
      $sql = "UPDATE users SET gold=gold-100, potions=potions+1 WHERE username = '$username'") or die(mysql_error();
    echo "<center>You have bought one health potion.</center>";
    }else{
    echo "<center>You don't have enough gold. Come back when you getmore.</center>";
    }
    ?>

  3. is there something wrong with the code it keeps coming up blank on my webpage.

     

    <?php
    $sql = mysql_query("SELECT * FROM users WHERE username = '$username'");
    $row = mysql_fetch_array($sql);
    if ($row['gold'] >= 100) {
      $sql = "UPDATE users SET gold=gold-100, potions=potions+1 WHERE username = '$username'") or die(mysql_error());
    echo '<center>You have bought one health potion</center>';
    }else{
    echo '<center>You don't have enough gold. Come back when you get more.</center>';
    }
    
    ?>

  4. I looked online for tutorials on how to do this but i still don't understand im trying to use a if statement that if($row['gold'] >= 100) then it subtracts 100 from row gold and then adds 1 to row "potions" if anyone could help me or send a tutorial my way i would be very grateful.

  5. I was wondering if i would be able to expand on this code i made so that it does the same thing but for different set numbers kinda like this

    if kills >50 & <100 set rank x

    if rank = x echo cannot rank up

    if kills >100 & < 150 set rank x

    if rank = x echo...

    if kills > 150 & < 200 set rank x

    if rank = x 

    but with it being all in one script, and how would i do this this my current code shown below.

    $sql = mysql_query("SELECT * FROM table WHERE username = '$username'");
    $row = mysql_fetch_array($sql);
    if($row['kills'] >= 25){
    mysql_query("UPDATE `table` SET `variable` = 'new rank' WHERE username = '$username'") or die(mysql_error());
    echo '<center>You have ranked up. '.$username.'</center>';
    }else{
    echo '<center>Your not good enough to rank up yet!</center>';
    }
    

  6. the script is working but its not doing what i need it to do. im trying to get it to verifiy that both variables for both players are both equal to "Forest Of Death" and if either players location variable is not set to "Forest Of Death" i dont want the rest of the script to run here is the whole code

     

    $UserSL = $UserS['location']; // syntax error need sem-colon
    $NPCL = $NPC['location']; // syntax error need sem-colon
    if($NPCL == "Home") {echo "User is at thier house! <br><br>";
    exit();
    }
    if($UserSL == "Home") {echo "You must be in the city to fight! <br><br>";
    exit();
    }
    
    echo "Begin the fight!";
    
    if(!isset($_GET['user']))
    {
    echo "You have not selected a user to fight!<br><br>";
    $NPCS = mysql_query("SELECT * FROM `users`");
    while($Show = mysql_fetch_array($NPCS))
      {
      echo "<a href=\"AttackPlayer.php? Action=Attack&user=" . $Show['username'] . "\">" . $Show['username'] . "</a><br>";
      }
    exit();
    }
    $NPC = mysql_escape_string($_GET['user']);
    $username = $_COOKIE['ID_my_site'];
    if($_GET[Action] = Attack)
    {
    if($username == $NPC){echo "You cannot fight yourself! <br><br>"; exit();}
    $UserS = mysql_query("SELECT * FROM `users` WHERE username='$username'");
    $UserS = mysql_fetch_array($UserS);
    $UserH = $UserS['health'];
    if($UserH == '0'){echo "You have no health you cannot fight! <br><br>"; exit();}
    $UserA = $UserS['skill'];
    $UserK = $UserS['kills'] +1;
    
    $UserSkill = $UserS['skill'];
    $UserA *= .1;
    $NPCS = mysql_query("SELECT * FROM `users` WHERE username='$NPC'");
    $NPCS = mysql_fetch_array($NPCS);
    $NPCH = $NPCS['health'];
    if($NPCH == '0'){echo "You cannot attack someone that has no health! <br><br>"; exit();}
    $NPCA = $NPCS['skill'];
    $NPCSkill = $NPCS['skill'];
    $NPCA *= .1;
    
    
    $run = 1;
    While($run > 0){
    $NPCH -= $UserA;
    if($NPCH <= 0)
      {
      $xp = $NPCSkill * .020;
      echo "You win and have gained " . $xp . " skill from " . $NPC . "";
      $UserA = $UserSkill + $xp;
      mysql_query("UPDATE `users`
      SET skill='$UserA', health='$UserH', kills='$UserK'
      WHERE username='$username'");
    
      $NPCA = $NPCSkill * .97;
      mysql_query("UPDATE `users`
      SET skill='$NPCA', health='0'
      WHERE username='$NPC'");
    
      exit();
      }
    
    $UserH -= $NPCA;
    if($UserH <= 0)
      {
      echo "You have lost";
      $xp = $UserSkill * .030;
      $UserA = $NPCSkill + $xp;
      mysql_query("UPDATE `users`
      SET skill='$UserA', health='$UserH', kill='kill +1'
      WHERE username='$NPC'");
    
      $UserA = $UserSkill * .97;
      mysql_query("UPDATE `users`
      SET skill='$UserA', health='0'
      WHERE username='$username'");
    
      exit();
      }
    }
    }
    
    ?>
    
    </body>
    </html>
    

  7. so this then

    $UserSL = $UserS['location']
    $NPCL = $NPC['location']
    if($NPCL ==" Home") {echo "User is at thier house! <br><br>";
    exit();
    }
    if($UserSL == "Home") {echo "You must be in the city to fight! <br><br>";
    exit();
    }

  8. is this look good? its supposed to stop another script on the same page if both variables dont match

     

    $UserSL = $UserS['location']
    $NPCL = $NPC['location']
    if($NPCL = Home) {echo "User is at thier house! <br><br>";
    exit();
    }
    if($UserSL = Home) {echo "You must be in the city to fight! <br><br>";
    exit();
    }

  9. i have a script that allows users to view other members profiles but im not sure how to create a script that  checks if the target profile has there profile variable set to "public" so i need it to check if the target profile's user has there "profile" variable set to "public" and if it is set to public continue to run the script to view the profile but if it he "profile" variable is set to anything but "public" it redirects the user trying to view the profile to another page

  10. i was wondering if i could create a file upload script with php that stores the url for a picture and stores the url under a "picture" variable in my database. so my question is there a way i can echo the url that is stored in the database but have it show the picture instead of the url

  11. i need help editing my script. i tried to do it my self but it didn't work. im trying to make it so my attack player script will only run if the location variable for both players is set to "Forest Of Death"

     

     

     

     

     

    <?php
    mysql_connect("localhost", "username", "password") or die(mysql_error());
    mysql_select_db("members") or die(mysql_error());
    
    $username = $_COOKIE['ID_my_site']; 
    mysql_query("UPDATE `users` SET `location` = 'Forest Of Death' WHERE username = '$username'") or die(mysql_error());
    echo "<center>You have entered the Forest of Death. death lurks around every corner, every tree, every face... " . "</center>";
    
    
    $playerA = "Forest Of Death";
    $playerB = "Forest Of Death";
    
    IF ($playerA == $playerB) {
    //they can attack
    }
    else {
    //they can't attack
    }
    
    
    
    
    
    
    session_start();
    if(!isset($_GET['user']))
    {
    echo "You have not selected a user to fight!<br><br>";
    $NPCS = mysql_query("SELECT * FROM `users`");
    while($Show = mysql_fetch_array($NPCS))
      {
      echo "<a href=\"AttackPlayer.php? Action=Attack&user=" . $Show['username'] . "\">" . $Show['username'] . "</a><br>";
      }
    exit();
    }
    $NPC = mysql_escape_string($_GET['user']);
    $username = $_COOKIE['ID_my_site'];
    if($_GET[Action] = Attack)
    {
    if($username == $NPC){echo "You cannot fight yourself! <br><br>"; exit();}
    $UserS = mysql_query("SELECT * FROM `users` WHERE username='$username'");
    $UserS = mysql_fetch_array($UserS);
    $UserH = $UserS['health'];
    if($UserH == '0'){echo "You have no health you cannot fight! <br><br>"; exit();}
    $UserA = $UserS['skill'];
    $UserK = $UserS['kills'] +1;
    $UserSkill = $UserS['skill'];
    $UserA *= .1;
    $NPCS = mysql_query("SELECT * FROM `users` WHERE username='$NPC'");
    $NPCS = mysql_fetch_array($NPCS);
    $NPCH = $NPCS['health'];
    if($NPCH == '0'){echo "You cannot attack someone that has no health! <br><br>"; exit();}
    $NPCA = $NPCS['skill'];
    $NPCSkill = $NPCS['skill'];
    $NPCA *= .1;
    
    
    $run = 1;
    While($run > 0){
    $NPCH -= $UserA;
    if($NPCH <= 0)
      {
      $xp = $NPCSkill * .035;
      echo "You win and have gained " . $xp . " skill from " . $NPC . "";
      $UserA = $UserSkill + $xp;
      mysql_query("UPDATE `users`
      SET skill='$UserA', health='$UserH', kills='$UserK'
      WHERE username='$username'");
    
      $NPCA = $NPCSkill * .97;
      mysql_query("UPDATE `users`
      SET skill='$NPCA', health='0'
      WHERE username='$NPC'");
    
      exit();
      }
    
    $UserH -= $NPCA;
    if($UserH <= 0)
      {
      echo "You have lost";
      $xp = $UserSkill * .035;
      $UserA = $NPCSkill + $xp;
      mysql_query("UPDATE `users`
      SET skill='$UserA', health='$UserH', kill='kill +1'
      WHERE username='$NPC'");
    
      $UserA = $UserSkill * .97;
      mysql_query("UPDATE `users`
      SET skill='$UserA', health='0'
      WHERE username='$username'");
    
      exit();
      }
    }
    }
    
    ?>
    
    </body>
    </html>
    

  12. i need help editing my script to make it work with a cron, i need it to update every players variable even if the player is not logged on

     

     

      function UpdateHealthBar($player){
      if($player != ''){
      $sql  = mysql_query("SELECT `username`,`max_health`, `health`, `last_update` FROM `users` WHERE `username` = '$player'") or die(mysql_error());
      $user = mysql_fetch_assoc($sql) or die(mysql_error());
      
         // vars
         $username    = $user['username'];
         $user_health = $user['health'];
         $max_health  = $user['max_health'];
      
    
         mysql_query("UPDATE `users` SET `health` = '$max_health', `last_update` = '$last_update' WHERE `username` = '$player'") or die(mysql_error());
        }	
      }
    }
    UpdateHealthBar($player);

×
×
  • 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.