Jump to content

slyte33

Members
  • Posts

    137
  • Joined

  • Last visited

Everything posted by slyte33

  1. What I am trying to do is display 'drug' price changes for my online rpg game. I have a cron that runs once every 15 minutes, and the time when the cron runs is inserted into the DB. I have a for loop that looks like this: if ($_GET['chart']) { $drugprices=$db->execute("select * from drugs_pricechange where name='".$_GET['chart']."' order by time desc limit 24"); echo "<table width=\"540\" bgcolor=\"666666\" cellspacing=\"1\">"; echo "<tr>"; echo "<td class=\"dark\" colspan=\"3\" align=\"center\"><b>Drug price changes for ".$_GET['chart']."</td>"; echo "</tr>"; for($i=1;$dp=$drugprices->fetchrow();$i++) { echo "<tr>"; echo "<td>"; echo "<b>"; echo date('G:i', $dp['time']); echo "</b>"; echo " | $".$dp['newprice'].""; echo " | "; if ($dp['sign']=="+"){$color="green";}else{$color="red";} echo "<font color=\"$color>\""; echo "".$dp['sign'].""; echo "$".$dp['pchange'].""; echo "<br></font>"; if ($i % 8 == 0){echo "<td class=\"light\">";} } die; } As you can see, this would not work. Every 8 "$i" that is looped would start a new row. Although it does not work unless i put <tr><td> right after the for loop starts.(which results in 1 row, 24 columns) If you understand the code above you can see what I'm asking, kinda. I want 3 rows, 8 columns with the time the cron ran to be displayed like this: 1|9|17 2|10|18 3|11|19 4|12|20 5|13|21 6|14|22 7|15|23 8|16|24 The only way I can get this to work is by using <tr> instead which would result in this: 1|2|3 4|5|6 7|8|9 10|11|12 13|14|15 16|17|18 19|20|21 22|23|24 All help would me much appreciated, thank you !
  2. Sorry. I am using ADODB, and I left the top part out: $atker = $db->execute("select * from players where id=$player->id"); $attacker = $atker->fetchrow(); foreach($attacker as $key=>$value) { $atker->$key = $value; } $def = $db->execute("select * from players where id=".$_GET['id'].""); $defender = $def->fetchrow(); foreach($defender as $key=>$value) { $def->$key = $value; } $atkerweapon=$db->execute("select * from pweapons where player_id=".$atker->id." and status='eq' and type='weapon'"); $defarmor=$db->execute("select * from pweapons where player_id=".$def->id." and status='eq' and type='armour'"); $defarmdef = Defenders armor / 100 // divide by 100 to get a percent of the defenders armor; i.e 1,000 defence * .75(75) = +750 extra defence As for the algorithm, I will have to try and work that out, but it would take awhile. It works alright so far, i've used plenty of different combinations and all works well. I am just wondering, is there a better way. I've seen this used before: [your strength]/[enemies defence] but thats too simple and would give someone waaay to much strength if the defence is lower than the strength. Did i better explain it?
  3. Hello, for 5 hours straight now I have been altering my MMORPG game battle formulas(or should I say min/max damage formulas). I have so far, what I think is pretty decent, a formula that calculates how hard the attacker will hit based on his/her strength vs the enemies defence. If anyone knows of a better formula, please do give me advice , else how did I do? if ($defarmor->recordcount() > 0) { $defarm=$defarmor->fetchrow(); $defarmdef = $defarm['damage'] / 100; }else{ $defarmdef = 1; } if ($atkerweapon->recordcount() > 0) { $atkwep=$atkerweapon->fetchrow(); $atkwepatk = $atkwep['damage'] / 100; }else{ $atkwepatk = 1; } $mult=$atker->strength/$def->defence/10; $defender = (($def->defence * .25) + ($def->defence * $defarmdef) + ($def->defence * $mult)); $atkmaxdmg= ((($atker->strength * $atkwepatk) + (($atker->strength) * 1))) - $defender; $atkmindmg= ((($atker->strength * $atkwepatk) + (($atker->strength) * .7))) - $defender; $atker->maxdmg = $atkmaxdmg; $atker->maxdmg = ($atker->maxdmg <= 1)?0:$atker->maxdmg; $atker->maxdmg = ($atker->maxdmg <= 1)?0:$atker->maxdmg; $atker->mindmg = $atkmindmg; $atker->mindmg = ($atker->mindmg <= 1)?0:$atker->mindmg; $atkerdmgg = mt_rand($atker->mindmg, $atker->maxdmg);
  4. Sorry for the late reply, this will not work either because what is $USER_IP defined as? A player's IP? I want it to go through the entire players database, and if their are duplicate IP's - than display them. Thank you for the help, though. And if I am wrong, please correct me on how the code above finds dupe IP's in a table.
  5. Hello, I have created a function that will replace curse words in a text file with stars(*). The problem I am facing, however, is that if someone types, for example "cassie", it will replace the string like this: "C***ie"; What I am wanting to do, is just replace the word if it is typed as just that whole word, so it wouldn't block the 'ass' out in cassie. Here is my function: function LangFilter($ToFilter) { $Foul = @file("foul.txt"); foreach($Foul as $FoulWord) { $FoulWord = trim($FoulWord); if (preg_match("/".$FoulWord."/i", $ToFilter)) { $WordLength = strlen($FoulWord); for ($i = 1; $i <= $WordLength; $i++) { $RepChar .= "*"; } $ToFilter = eregi_replace($FoulWord, $RepChar, trim($ToFilter)); $RepChar = ""; } } return $ToFilter; } All help is much appreciated, thanks!
  6. I've searched google for hours and finally found a code that has blocked over 50+ proxies that i've tried from accessing my site: if( @fsockopen( $_SERVER['REMOTE_ADDR'], 80, $errstr, $errno, 1 ) ) { echo "Not allowed, using proxy!"; ext(); } What I am asking is, how effective is this? Can it be bypassed or anything? All help on this would be appreciated, thanks!
  7. What I want to do, though, is only display that if the IP is stored 2+ times in the DB, that way it only displays people with multiple accounts(same IP)
  8. Hello, What I am trying to do is if a player's IP address is used twice(stored twice in DB; aka multiple accounts), then display their IP address and username. For example: IP addresses stored: 123.45.678.90 09.876.54.321 456.789.10.11 123.45.678.90 89.79.455.243 As you can see, 123.45.678.90 is stored twice, so display on webpage: 123.45.678.90 - [username for account one] 123.45.678.90 - [username for account two] I hope this explains it, all help is much appreciated. Thanks, Slyte
  9. When you don't follow correct programming practices the future could look grim for your site. Let's say they come out with another very popular internet browser that does not recognize what you are doing because it sticks strictly to compliant code. Then all of the users that are using this browser will not have full functionality while visiting your site. to ".$_GET['page']." Ahh, I understand now. Looks like I'll be making a lot of new changes then.
  10. Thank you for the feedback, So It would be a good idea to go through every page i've created and quote all html attributes and change all $_GET to ".$_GET['page']." One thing, though, Im just curious, how does it make a difference? Could it sometimes not process correctly because of this?
  11. I've figured it out, it doesn't have to do with the page my sessions are stored and blah blah, i simply removed the include file at the top of the forums page, and replaced that include with 2 main includes i need, and it worked, so it has to do with something somewhere in here: <? $_GET['logout'] = 1; include("lib.php"); $player = check_user($secret_key, $db); include("refresh.php"); ?> <div id=overDiv style="position:absolute; visibility:hidden; z-index:1000;"></div> <table width="450" border="0" align="center" cellpadding="0" cellspacing="1" class="submit"> <tr> <td colspan="2"><strong class="style21"><u><center><? $url = $_SERVER['REQUEST_URI']; echo "<a href=$url>$title</a>"; $time = time(); $update = $db->execute("update players set page='$title', last_active=$time where id=$player->id"); ?> </u></strong></td> </tr> <tr> <td colspan="2"> </td> </tr> </table> <center> Question: 'firstly your html attributes should ideally be quoted, like' do you have to do that, whats the difference?
  12. Hello, I am having a pretty unusual problem. I have coded fully working forums that have been working for months, but here recently I have re-coded the way my sessions work. Now, when i load the forums, click a category, then click reply, it automatically ends my session. I removed 1 segment of code at a time to find out what is causing it, and unfortunately, it's a textarea. Here is that part of the code: echo "<table><tr><td class=light>"; echo "<form action=forums.php?$gid&id=$_GET[id]&topicid=$_GET[topicid] method=post>"; echo "<table><tr>"; echo "<td class=light>"; echo "Message:<br><br><br>"; echo "</td>"; echo "<td class=light>"; echo "<textarea name=replymsg id=reply rows=5 cols=52></textarea>"; When removing that last line, it works fine with no problem, else it completely ends the session. How is this happening? All help would be much appreciated. Thanks, Slyte!
  13. That's how I thought it might work, thanks!
  14. I am trying to figure out how I would record the most members online at once. I know how to display how many are online, but keeping a record? All help is much appreciated Thanks, Slyte!
  15. Hello, I am making a new mmorpg game and I was curious if it is possible to use commas in textboxes, and then when submitting the data, strip the commas and submit. This way, if a player has... $1,000,000 and they want to deposit it in their bank, they could simply enter 1,000,000 and not 1000000. I hope this explains it, and help is much appreciated. Thanks, Slyte
  16. I am trying to include a PHP file with: include("page.php?get=data"); this does not work. PHP recommends you use URL wrapping instead, but that is not an option for me because if my host disables URL wrapping I’ll be left with broken scripts. Not to mention it takes longer to process. Is there another way? Help is greatly appreciated , thanks!
  17. When I try to do this, it tells me: Firefox has detected that the server is redirecting the request for this address in a way that will never complete. Heres what I put: $url_parts = parse_url($_SERVER['REQUEST_URI']); if($url_parts['path'] != 'logged_in.php') { header('Location: index.php'); exit(); }
  18. What I want to do is re-direct a user if their url on my site isn't "enter url here" I want to do this because the whole page is an iframe and i don't want them to be able to leave the iframe. I'm pretty unsure on how to do this, so help would be greatly appeciated Thanks!
  19. Not exactly. I want to get what place a player is in, like if the results are: Player A - level 100 Player B - level 95 You - level 92 Player C - level 76 Then display: Level: 92 (3rd place)
  20. Im not sure what you mean, to explain it better i just want to basically display what place a player is on on the high scores.
  21. I am trying to get what position a player is in for something, for example: Player - Level: 100 (6th) Gold: 1,394,289 (109th) My players are stored in a table named 'players'; this is where all of their information is kept. I've seen it before, but Im having a hard time figuring out how to do it. All help is appreciated, thanks
  22. How does eval() work? Im having a hard time understanding it.
×
×
  • 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.