Jump to content

BellQuestWars

Members
  • Posts

    46
  • Joined

  • Last visited

    Never

Everything posted by BellQuestWars

  1. aight, I only have one object I'll try clearing image, dont think it will work though... Haha thanks! Didnt think that would work! Still one bug though, when the player is directly under the object, it draws it on the northeast and north box, but probably a simple bug, quick fix. Okay, the problem was I forgot to clear image in North, knew it would be simple...
  2. So I wrote this code, what its supposed to do is draw an image on a grid space, based on its X,Y coordinates from a mySql database, compared to the player X,Y. Heres the code: <table> <tr> <td> <?php //northwest echo "nw"; $x1 = $_SESSION[x] - 1; $y1 = $_SESSION[y] + 1; $hasobject1 = mysql_query("SELECT * FROM objects WHERE x='$x1' && y='$y1'"); while($row = mysql_fetch_array($hasobject1)) { $image = "space_228.gif"; $image = $row[image]; } if(!empty($image)){ echo "<IMG SRC=$image WIDTH=64 HEIGHT=64 onerror='onImgError(this)>'"; } else{ echo "<IMG SRC='space_228.gif' WIDTH=64 HEIGHT=64>"; } ?></td> <td><?php //north echo "n"; $x2 = $_SESSION[x]; $y2 = $_SESSION[y] + 1; $hasobject2 = mysql_query("SELECT * FROM objects WHERE x='$x2' && y='$y2'"); while($row = mysql_fetch_array($hasobject2)) { $image = "space_228.gif"; $image = $row[image]; } if(!empty($image)){ echo "<IMG SRC=$image WIDTH=64 HEIGHT=64 onerror='onImgError(this)>'"; } else{ echo "<IMG SRC='space_228.gif' WIDTH=64 HEIGHT=64>"; } ?></td> <td><?php //northeast echo "ne"; $x3 = $_SESSION[x] + 1; $y3 = $_SESSION[y] + 1; $hasobject3 = mysql_query("SELECT * FROM objects WHERE x='$x3' && y='$y3'"); while($row = mysql_fetch_array($hasobject3)) { $image = "space_228.gif"; $image = $row[image]; } if(!empty($image)){ echo "<IMG SRC=$image WIDTH=64 HEIGHT=64 onerror='onImgError(this)>'"; } else{ echo "<IMG SRC='space_228.gif' WIDTH=64 HEIGHT=64>"; } ?></td> </tr> <tr> <td><?php //wesr echo "w"; $x4 = $_SESSION[x] - 1; $y4 = $_SESSION[y]; $hasobject4 = mysql_query("SELECT * FROM objects WHERE x='$x4' && y='$y4'"); while($row = mysql_fetch_array($hasobject4)) { $image = "space_228.gif"; $image = $row[image]; } if(!empty($image)){ echo "<IMG SRC=$image WIDTH=64 HEIGHT=64 onerror='onImgError(this)>'"; } else{ echo "<IMG SRC='space_228.gif' WIDTH=64 HEIGHT=64>"; } ?></td> <td><?php echo "p"; //player echo "<IMG SRC='spaceship_wire5.jpg' WIDTH=64 HEIGHT=64>"; ?></td> <td><?php //east echo "e"; $x5 = $_SESSION[x] + 1; $y5 = $_SESSION[y]; $hasobject5 = mysql_query("SELECT * FROM objects WHERE x='$x5' && y='$y5'"); while($row = mysql_fetch_array($hasobject5)) { $image = "space_228.gif"; $image = $row[image]; } if(!empty($image)){ echo "<IMG SRC=$image WIDTH=64 HEIGHT=64 onerror='onImgError(this)>'"; } else{ echo "<IMG SRC='space_228.gif' WIDTH=64 HEIGHT=64>"; } ?></td> </tr> <tr> <td><?php //southwest echo "sw"; $x6 = $_SESSION[x] - 1; $y6 = $_SESSION[y] - 1; $hasobject6 = mysql_query("SELECT * FROM objects WHERE x='$x6' && y='$y6'"); while($row = mysql_fetch_array($hasobject6)) { $image = "space_228.gif"; $image = $row[image]; } if(!empty($image)){ echo "<IMG SRC=$image WIDTH=64 HEIGHT=64 onerror='onImgError(this)>'"; } else{ echo "<IMG SRC='space_228.gif' WIDTH=64 HEIGHT=64>"; } ?></td> <td><?php //south echo "s"; $x7 = $_SESSION[x]; $y7 = $_SESSION[y] - 1; $hasobject7 = mysql_query("SELECT * FROM objects WHERE x='$x7' && y='$y7'"); while($row = mysql_fetch_array($hasobject7)) { $image = "space_228.gif"; $image = $row[image]; } if(!empty($image)){ echo "<IMG SRC=$image WIDTH=64 HEIGHT=64 onerror='onImgError(this)>'"; } else{ echo "<IMG SRC='space_228.gif' WIDTH=64 HEIGHT=64>"; } ?></td> <td><?php //southeast echo "se"; $x8 = $_SESSION[x] + 1; $y8 = $_SESSION[y] - 1; $hasobject8 = mysql_query("SELECT * FROM objects WHERE x='$x8' && y='$y8'"); while($row = mysql_fetch_array($hasobject8)) { $image = "space_228.gif"; $image = $row[image]; } if(!empty($image)){ echo "<IMG SRC=$image WIDTH=64 HEIGHT=64 onerror='onImgError(this)>'"; } else{ echo "<IMG SRC='space_228.gif' WIDTH=64 HEIGHT=64>"; } ?></td> </tr> </table> Now what happens is it draws the image on a bunch of different spots. The object is at 0,0. It doesnt display the object if the object is out of range of the player, or the player is at 0,0. But if the player is near the object, it draws it on like half the grid spaces, and on some places everywhere but the players. Heres the page, login with test, password test. http://spacetimemmo.webuda.com/login.php
  3. Not much would change for me, except I may have to figure some things out, but that only takes an extra couple of hours. I do lots of things for fun, I visit friends, I read, I play sports, I practice Thai-Chi, I play games with my little brother, etc.
  4. My group of friends at school all have PS3 except one kid who plays X-Box live and hes been laughing at all of us for the past 16 days... They are supposedly giving us a free month of PS+, which doesnt mean shit to me as all I play on my PS3 is Black Ops (I sold MW2 when Black Ops came out, and its the only game I have.) I've been playing more Lord of the Rings Online and practicing programming and the musical (Beauty and the Beast) I'm in for the past 16 days, so its been kinda good (I'm the lead in the play, and I didnt know all my lines.) Lets hope it stays off for mothers day so I actually spend time with my mother (joking.)
  5. I'm sure many of you know this already, but Sony's Playstation network has been down for 15 weeks. It is supposed to come back online this week, but things are looking better as the network goes online in Japan. What are your thoughts on it? Do you think they handled it right? Do you think otherOS is anygood? Is the Playstation network complete crap?
  6. I think I have the displaying of other players figured out, but I cant really test it until my host puts website back on (they check for malicious content 2 days after you open a website, and that takes about 2 days.)
  7. Okay, I have it down. Now how would I make it display all players that are online and on a specific room? Would I do something like in a page called showplayers.php put: <?php require_once("connect.php"); session_start() $map = $_GET[map] $results = mysql_query("SELECT * FROM members WHERE online='true' AND map='$map'"); I dont know what else I would put to get each players X and Y? I would call this page every time the player moves, but then how would I go about displaying the players? I'm stumped on this one.
  8. Okay, so I have a script that uses a php variable to get a number, and the php variable is collected from the database. The problem is the php variable is a string, and the Javascript variable is a number, so I need a way to convert a string into a number. Heres my php script: <?php session_start(); require_once("connect.php"); $result = mysql_query("SELECT * FROM members WHERE username='$_SESSION[username]'"); $x = $row[x]; $y = $row[y]; ?>
  9. Thanks yawl... Been stopping paying attention to this thread for some reason.
  10. Okay, so I fixed the PHP script so that the page does change, it was a simple typo (should have been upercase X and Y in the adress bar...) But now I need to figure out the problem with the AJAX part...
  11. Okay, This code isnt working: if (keyp == 56) { p1y = -1; var url = 'update.php?X='+p1x+'&Y='+p1y; var xhr = new XMLHttpRequest(); this.privates.xhr.open("GET", url, true); xhr.send(null); } This is the code that changes variables when the 8 key is pressed (up on the keypad) But for some reason, when the key is pressed, the players moves up, but nothing changes in the database. Also if I go to the url mypage.com/update.php?x=3&y=3, it doesnt change the datbase. Heres update.php: session_start(); require_once("connect.php"); $x = $_GET[X]; $y = $_GET[Y]; mysql_query("UPDATE members SET x = '$x' WHERE username = '$_SESSION[username]'"); mysql_query("UPDATE members SET y = '$y' WHERE username = '$_SESSION[username]'"); ?>
  12. Okay, This code isnt working: if (keyp == 56) { p1y = -1; var url = 'update.php?X='+p1x+'&Y='+p1y; var xhr = new XMLHttpRequest(); this.privates.xhr.open("GET", url, true); xhr.send(null); } This is the code that changes variables when the 8 key is pressed (up on the keypad) But for some reason, nothing happens when the key is pressed, except for the players movement. Also if I go to the url mypage.com/update.php?x=3&y=3, it doesnt change the datbase. Heres update.php: session_start(); require_once("connect.php"); $x = $_GET[X]; $y = $_GET[Y]; mysql_query("UPDATE members SET x = '$x' WHERE username = '$_SESSION[username]'"); mysql_query("UPDATE members SET y = '$y' WHERE username = '$_SESSION[username]'"); ?>
  13. Oh wait, now I think I understand. I would have the var url = 'update.php?X='+x+'&Y='+y; xmlhttp.open("GET",url,true); xmlhttp.send(); Then on the page update.php, I would have something like: $x=$_GET["X"]; $y=$_GET["Y"]; $query = mysql_query("UPDATE users SET x = '$x' WHERE user = '$_SESSION[user]'"); $query = mysql_query("UPDATE users SET y = '$y' WHERE user = '$_SESSION[user]'"); I'm hoping that code will work. Just posting here first so I dont get frustrated from errors.
  14. Okay thanks. So from reading that, how a table would be updated I would have this code on one page: xmlhttp.open("GET","update.php",true); Then on update.php I would have what I would normally have if I was using a html form, such as: $result = mysql_query("UPDATE users SET x='$_GET[x]' WHERE username='$_SESSION[name]'") I'm guessing thats how it works, but it probably isnt.
  15. Okay, I looked up jquery, and Installed it onto my webpage. How would I go about updating a MySql table using Jquery? Is there a function for updating and reading MySql tables?
  16. Can anyone point me to a good AJAX tutorial? I really want to learn how to use AJAX with MySQL, but I dont know how.
  17. Thats what I thought too. I have decided not to do the project this post was for, so this may be closed.
  18. Thank you, I have been looking for a small example script like that. Thats really been my only problem is finding a small snippet that will update a variable, so I could sort of see how it works, but all the script I have found are long and confusing.
  19. I understand how they work, I just heard a little rumor that they could be used with javascript. I thought this was weird.
  20. Okay, I have been looking into this for the last 3 hours, and cant find shit. I have a page with a javascript game where the player moves around on a map. They have an X and Y coordinate, but I'm having a problem. The problem is I need to store that info in a database, and I'm having trouble learning AJAX. Heres a little list of things: Play loads the game. A php variable is taken from a database. The player goes to those X and Y coordinates. The player may move around. Once they move, the player is sent to a php page that updates the Database information. The page is refreshed to the game again, where they may then move around some more. The problem is, when the page is changed the values are lost. For some reasons cookies aren't working at all (like just not working for anything, even a completely different file.) I heard something about using $_GET or $_POST, but I dont see how...
  21. Databases are queried via user input all the time. What do you think a user registration form ultimately does? Or when data is retrieved based on a GET value? The key is in sanitizing the input. To the OP: If you don't want to use ajax to stop the page from refreshing, just use a PHP session. Sessions can work even when it's just one page refreshing over and over. Then it's just a matter of: var myVar = <?php echo $_SESSION['myVar']; ?>; For ajax, hardly anyone writes raw ajax any longer. Take a look at jQuery's ajax functions, especially $.get() and $.post(). Okay, thanks, but I need to change a session variable from within a javascript. Heres what I need to do: Player loads the page, they get their X and Y coordinates from a database. The player moves. When the player moves, their X and Y coordinates change. This must then change in the database. The player may then load the page again, and their X and Y will be saved. Problem isnt getting the variables from the database, the problem is updating it. I'm having a hard time learning AJAX. Can I simply run something like ajax.query("MYSQL QUERY HERE"); And then come up with some security things when I need to start worrying?
  22. But how the program works is the player moves a character and then a variable is changed, but that variable is lost when the page is refreshed, so it would keep saving the players starting spot.
×
×
  • 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.