Jump to content

wannabe_god

Members
  • Posts

    27
  • Joined

  • Last visited

wannabe_god's Achievements

Newbie

Newbie (1/7)

0

Reputation

  1. hi, im making a php mmorpg.The player already is able to register and log in, and walk though my world, seeing other players.Now as just walking quite boring, i am busy with the attack code.Let me first explain how the walking works:We search in the database the position from the player named [name]Then we search the names of all players in the positions around the player and generate a minimap and gamefield.If the player moves, the x and y are updated.Now for the attack script, i wanted to make something like:clicking on a player positioned on (-53,34) makes you go to the url index.php?attack=-53|34now we check if -53,34 is not too far away, 'couse we dont want players to be able just to type something and have huge siege weapons So if there is something on that postion, we check what it is (a tree, a player, an AI monster, ...)And then the attacking script with losing lifepoints etc. will be executed but it is not yet complete. I have a little problem first.Internet Explorer saves the adresses, and when i succesfully attacked another player, and walk away, i can select the url where i attacked him, and now my player moves to the position where i attacked that player the last time. He doesnt change any other thing in the database, the x and y stay normal.In opera everything works fine (microsoft )here's my attack script: //update settings$users=mysql_fetch_row(mysql_query("select * from users where name='".$name."'"));$char=mysql_fetch_row(mysql_query("select * from settings where name='".$name."'"));//attackif (isset($_GET["attack"])){ $canx=0; $cany=0; $x1=$char[1]; $y1=$char[2]; $fightpos=explode("|",$_GET["attack"]); //check if can attack x $x2=$fightpos[0]; if($x2-$x1<=$char[17]) {//$char[17] is the max range $canx=1; } //check if can attack y $y2=$fightpos[1]; if($y2-$y1<=$char[17]) { $cany=1; } //the actual attacking if($canx && $cany){ $attack_object=mysql_fetch_row(mysql_query("select * from map where x='$x2' and y='$y2'")); if ($attack_object){//if there is SOMETHING on the position we want to attack $isplayer=mysql_fetch_row(mysql_query("select * from settings where x='$x2' and y='$y2'")); if($isplayer){//if its a player $attacking=1; } } }} after that i just echo "attack" on top if attack is succesful (as this is before the body part)
  2. Hey,For keeping users logged in, i set a cookie with their name and password.Now i made a logof page, but that one doesnt work the way i want him to. <?setcookie("settings","",time()+3600);?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /><? if(!$_GET["ref"])echo("<meta http-equiv=\"refresh\" content=\"1;url=logoff.php?ref=1\" />");elseecho("<meta http-equiv=\"refresh\" content=\"1;url=index.php\" />");?><title>Logoff</title></head><body><? echo($_COOKIE["settings"]."<br />"); ?>Logging out...</body></html> I tried a moment in the past to delete the cookie, but that doesnt work.Now everything works fine in opera, he first shows me the old cookie and then an empty one after the refresh, but in IE it keeps saying that i'm logged in. he just doesn't sets the cookie.edit--wtf... i edit, even remove my logoff.php page, but opera keeps opening an older version of it
  3. I use php with mysql.I'm new to mysql, but everything works fine (mostly)Now i searched a way to show all users in the database, and as the function mysql_fetch_column doesnt exists, I thought of making an extra table with all users. However, i think i will encounter a problem like this often, so...... could someone help?
  4. I would like to read one or two lines of a document on the server to echo on the homepage with a link like "read more" to view the complete document.But if I read a line php reads the source code of the html document. I just want to read the output. Someone knows how to do that?
  5. wannabe_god

    html in a mail

    I made a contact form on my page, and the code when sent is <?php //send mail if ($_GET["p"] == "sendmail"){ $text="This mail comes from: " . $_POST["from"] . "\n<hr />\n\n" . str_replace("script","-script-",$_POST["message"]); if (isset($_POST["message"]) && isset($_POST["from"])){ //gonna make it better echo("<div class=\"info\">"); if (mail("***@hotmail.com",$_POST["subject"],$text)) echo("Mail succesfully sent :D"); else echo("Mail could not be sent :("); echo("</div>"); } }(...)?> almost everything workes fine, just hotmail returns just <hr /> in my mail program, and i dont understand why, i didnt used htmlspecialchars() or something like that.... :)edit: the problem is not very urge - i used just ____________ instead of <hr />, but i prefer making <hr /> work
  6. do u want something like this: if (file_exists($_GET["page"] . ".php")) include($_GET["page"] . ".php")else include("main.php") ?
  7. @sigh: i want to echo the javascript with php, not separate them @aspnetguy: like<?phpecho("<script>" . \n);echo("<alert(\"hey\")" . \n);echo("</script>" . \n);?>i suppose?
  8. I tried to combine javascript and php, and some one lines js commands work wellecho("<script>alert(\"test\")</script>");but now I have larger javascripts, and when I echo all the commands he doesn't work anymore ("error on the page" and he just doesnt works), and it is too hard to check the html output of the php script to check whats wrong, 'couse the echoëd code has no newlines in the source.... Could someone please help me out
  9. Thank you! :)I knew it was something like that, i just tested it with / ...
  10. I'd like a way to ignore a quote, or something like that, so that i can write a double quote in a string. Something like document_write('''<td onmouseover="alert('hi')">hi</td>'''); why are there no triple quotes
  11. how to say that my page links to another automaticly after X seconds?
  12. Do you know that .gif images don't need to have a loop? So that they play once and stay at the last image? You can choose loop or no loop wit unfreez, so if you choose no loop, and use that non looping gif as rollover... ^^
  13. is there a way to check if the user exit's the browser?onunload doesn't work, as it checks if the user leaves the page... this is the case:I have a little php script who links to itself, for the forms etc..Now I change a cookie every time to look how many times the user refreshed/filled in the form. So I want that at the end of the "session", when leaving the page to go to another/exit the browser, I want to reset the cookie...
  14. wannabe_god

    search array

    with array_search you can search an array...so <?php$array=array("test1","test2","test3");echo array_search("test2",$array);?> will give 2.But i just want to check if "test2" is in the array $array. True or false, not a key...something like <?php$array=array("test1","test2","test3","test4");if value_is_in_array("test5") //I don't know the functionecho "test5 is in the array"elseecho "test5 is not in the array"?>
  15. THX!that was what i were looking for!
×
×
  • Create New...