Jump to content

wannabe_god

Members
  • Posts

    27
  • Joined

  • Last visited

Everything posted by wannabe_god

  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!
  16. HeyI use 4 styles on my site, and in 1 of them, I want to have white links, and in another red links.Changing the link color is easy in html, head tag, link="color" vlink etc., but if I do that, the link colors are the same for the whole page.Someone who knows how to fix that?
  17. @justsomeguy hey that's a nice idea... just "sitename"+"php variable"+scorevariableall I need now is better learning java
  18. ow really, i hate miniclip games on other sites...if I want miniclip games, i go to www.miniclip.com, but not to another unknown site...
  19. no, no, i meant java (that one, from sun ).<applet sh t></applet>, you know.But Is there a way to connect from java to php? just scores, so only one variable is required, and only once, so maybe I could put it into a database and remove it immedeatly...?
  20. wannabe_god

    java to php

    can i sent variables/other info from java to php?If yes: howI just want to send the score of the player in a java game (made by me of course) to a php page (coocies?)
  21. in every case, it works :)thx, if empty($array[$i]) is what i needed :)ps @Aleksanteri: with only one action, you don't need { and }
  22. I don't really see what you added apart of a for loop who doesn't help me mutch becouse I did not have a function to tell the cellamount.However, I just found out, (well, I asked someone...) that count($input) counts the fields of the array. Thanks for trying to help, though.this works... for($i=0;$i<count($input);$i++) echo $i+1 . ": " . $input[$i] . "<br>";
  23. wannabe_god

    empty array?

    how can I check if array[$i] is empty?To use like thisCodeif array[$i] != empty //how to check that it is empty{$i++; //lets do next...echo "array position " . $i . " is filled with " . array[$i] . "<br>";}EDITanother question that will solve the problem:how to find the length of an array?
  24. Does nobody knows this??or does i have to wait a little longer?it is a big problem, you know...on some computers everything works well, but on others you only see the iframes when you hit refresh, and on some computers you dont see the iframes at all (well, 0.3 seconds...)
  25. On my site I made some Iframes (http://tabourel.osbweb.nl)but if the size of the window is changed, you dont see the iframes no more, until you refresh. If the window is too large, you don't see them at all.Does anybody knows how to fix that?
×
×
  • Create New...