Agon Posted June 17, 2009 Posted June 17, 2009 Hello everyone. I have an odd problem today. Here's the snips of the code I'm having an issue with. Dealing with random.php $IQ=rand(1,2); mysql_query("UPDATE users SET IQ=IQ+$IQ WHERE userid=$userid"); Ok, here's my problem. It pays some users IQ and others it does not. I don't understand why it would work for some players but not all. Also, it used to pay every player and now it does not. I don't think the bug has anything to do with the query. I think it has something more to do with Mccodes Lite. Anyone have any ideas on this? Thanks. Quote
AbsentCrisis Posted June 17, 2009 Posted June 17, 2009 Re: Mccodes Lite Userstats IQ Bug Try that its more secure most probs wont fix your problem. Show all the code so I can take a look at it. $iq_rand = mt_rand(1,2); $sql = sprintf("UPDATE `users` SET `IQ` = IQ + %u WHERE (userid = %u)", $iq_rand, $userid); mysql_query($sql); Quote
ShizzleNizzle Posted June 17, 2009 Posted June 17, 2009 Re: Mccodes Lite Userstats IQ Bug Try that its more secure most probs wont fix your problem. Show all the code so I can take a look at it. $iq_rand = mt_rand(1,2); $sql = sprintf("UPDATE `users` SET `IQ` = IQ + %u WHERE (userid = %u)", $iq_rand, $userid); $db->query($sql); If he's using MC Lite then that wont work. Its mysql_query in LITE. (correct me if im wrong) Quote
AbsentCrisis Posted June 17, 2009 Posted June 17, 2009 Re: Mccodes Lite Userstats IQ Bug Updated post and I think it would still work its just a diiferent style of a query. Quote
CrazyT Posted June 17, 2009 Posted June 17, 2009 Re: Mccodes Lite Userstats IQ Bug Hello everyone. I have an odd problem today. Here's the snips of the code I'm having an issue with. Dealing with random.php $IQ=rand(1,2); mysql_query("UPDATE users SET IQ=IQ+$IQ WHERE userid=$userid"); Ok, here's my problem. It pays some users IQ and others it does not. I don't understand why it would work for some players but not all. Also, it used to pay every player and now it does not. I don't think the bug has anything to do with the query. I think it has something more to do with Mccodes Lite. Anyone have any ideas on this? Thanks. mysql_query('UPDATE `userstats` SET `IQ` = (`IQ` + '. mt_rand(1,20) .') WHERE `userid` = '. $ir['userid']); IQ is in userstats not users. Quote
Agon Posted June 17, 2009 Author Posted June 17, 2009 Re: Mccodes Lite Userstats IQ Bug Let me reword this a little bit. It's writing to the database for some users but not others. I don't think it has to do with the query. I will take your advice on using a more secure query though. Thanks. It is something beyond my grasp. Maybe a user limit is set somewhere in another .php file? Possibly globalfunc.php or header.php? Quote
AbsentCrisis Posted June 17, 2009 Posted June 17, 2009 Re: Mccodes Lite Userstats IQ Bug Add me on msn so I can talk/help you [email protected] Quote
Agon Posted June 17, 2009 Author Posted June 17, 2009 Re: Mccodes Lite Userstats IQ Bug I don't have MSN, any other way? I prefer not to install MSN on my box. But I can if I have to. Could you maybe meet me in my in game chatroom or IRC chat? I'm a linux user and a fan of open source, MSN goes against my personal beliefs. Quote
Lithium Posted June 17, 2009 Posted June 17, 2009 Re: Mccodes Lite Userstats IQ Bug @ Agon $conn = mysql_query("UPDATE users SET IQ=IQ+$IQ WHERE userid=$userid",$c); This will be enough to run over to every user Quote
Haunted Dawg Posted June 17, 2009 Posted June 17, 2009 Re: Mccodes Lite Userstats IQ Bug Try changing $userid to $ir['userid'] :) Quote
Agon Posted June 17, 2009 Author Posted June 17, 2009 Re: Mccodes Lite Userstats IQ Bug HauntedDawg, would I have to change every single query on every single page? WOW I guess I should consider if it's worth the time to edit 97 .php files with new queries or just upgrade to V1 or V2 Quote
Haunted Dawg Posted June 17, 2009 Posted June 17, 2009 Re: Mccodes Lite Userstats IQ Bug Not necesary, but there is a quick way. Did that sort out your problem? If so, just add to header.php under <?php session_start(); ob_start(); $userid = abs(@intval($_SESSION['userid'])); Quote
Agon Posted June 17, 2009 Author Posted June 17, 2009 Re: Mccodes Lite Userstats IQ Bug Hmmm, nope, did not work. Quote
Agon Posted June 17, 2009 Author Posted June 17, 2009 Re: Mccodes Lite Userstats IQ Bug I'm trying to do this without pasting miles of code for others to sort through. Kind of my responsibility to decipher the problem. But I can if I have to. Quote
Agon Posted June 17, 2009 Author Posted June 17, 2009 Re: Mccodes Lite Userstats IQ Bug What is so confusing to me, it's worked for four months, and now does not. I also just hit 50 users in the database. I think it has something to do with the amount of users, as if the query is confused on which table to write to all of a sudden. Bizarre and confusing to me, but I will figure it out. I've gone to far to give up now. Quote
Lithium Posted June 17, 2009 Posted June 17, 2009 Re: Mccodes Lite Userstats IQ Bug prolly the best option to do, as you might have something there that somehow locks the query, no idea what as every single post in here, your included should've work without any issues. Also taking your first post, there is no bug with Lite on that matter. I am using Lite as well, though an extremelly moded version Quote
Haunted Dawg Posted June 17, 2009 Posted June 17, 2009 Re: Mccodes Lite Userstats IQ Bug Post up your code, you be guaranteed a fix will be up. Quote
Agon Posted June 17, 2009 Author Posted June 17, 2009 Re: Mccodes Lite Userstats IQ Bug my version of random.php <?php session_start(); require "global_func.php"; if($_SESSION['loggedin']==0) { header("Location: login.php");exit; } $userid=$_SESSION['userid']; require "header.php"; $h = new headers; $h->startheaders(); include "mysql.php"; global $c; $is=mysql_query("SELECT u.*,us.* FROM users u LEFT JOIN userstats us ON u.userid=us.userid WHERE u.userid=$userid",$c) or die(mysql_error()); $ir=mysql_fetch_array($is); check_level(); $fm=money_formatter($ir['money']); $cm=money_formatter($ir['crystals'],''); $lv=date('F j, Y, g:i a',$ir['laston']); $h->userdata($ir,$lv,$fm,$cm); $h->menuarea(); if($ir['energy'] < (($ir['maxenergy'])*0.10)) { die("You do not have enough energy to go slackin. [url='explore.php']Back[/url]"); } else { if($ir['hosp'] >0) { die("You cannot go slackin while you are in the hospital."); } if($ir['jail'] >0) { die("You cannot go slackin while you are in the jail."); } else { $what=$_POST['what']; print "<form action='random.php' method=POST> You decide to wander around looking for slack stuff. It will cost 5% of your energy per try. <select name='what'> <option value='firstoption'>Slack Stuff</option></select> <input type='submit' value='Search'></form>"; $search=rand(1,24); /*--- Number of searches 1 - 19 ---*/ $money=rand(1,60); /*--- Value of money to be found min 1 max 60 ---*/ $money2=(30); /*--- extra money table ---*/ $crys=rand(0,0); /*--- crystals min 0 max 0 --- */ $hosp=rand(1,20); /*--- hosp time between 1 mins and 20 mins ---*/ $jail=rand(1,20); /*--- Jail time between 1 mins and 20 mins ---*/ $will=rand(3,15); /*--- slack between 1 and 10 ---*/ $energy=rand(1,2); /*--- extra energy table 1% - 2% energy gain or loss---*/ $IQ=rand(1,2); /*---IQ 1 to 2 points ---*/ $hp=rand(1,10); /*--- Hitpoints 1 - 10 ---*/ $brave=rand(1,3); /*--- Mojo 1 - 3 points ---*/ $eng=(($ir['maxenergy'])*0.05); /*--- 5% energy per search ---*/ if ($what =="firstoption") { if ($search =="1") { print "You see a beautifull sunrise, you find $will slack. You take a deep breath and feel good today, you gain $energy energy."; mysql_query("UPDATE users SET will=will+$will,energy=energy+$energy,energy=energy-$eng WHERE userid=$userid"); } elseif ($search =="2") { print "You wander off to the wrong side of town, some gangstas mistake you for an enemy gang member. They shoot at you, but you manage to get away. You lose some slack from the event."; mysql_query("UPDATE users SET will=will-$will,energy=energy-$eng WHERE userid=$userid"); } elseif ($search =="3") { print "The hotty from next door decides to take you out for coffee! You gain $energy energy, $will slack and $brave mojo."; mysql_query("UPDATE users SET will=will+$will,brave=brave+$brave,energy=energy+$eng WHERE userid=$userid"); } elseif ($search =="4") { print "You end up in the better side of town. Yaknow, where the city bus don't go. You find $$money dollars! Congrats!"; mysql_query("UPDATE users SET money=money+$money,energy=energy-$eng WHERE userid=$userid"); } elseif ($search =="5") { print "You find $money dollars while looking through backpacks at the gym! You scumbag!"; mysql_query("UPDATE users SET money=money+$money,energy=energy-$eng WHERE userid=$userid"); } elseif ($search =="6") { print "You see somthing shiny! It's $money bucks! You gain slack and mojo for your easy score."; mysql_query("UPDATE users SET will=will+$will,brave=brave+$brave,money=money+$money,energy=energy-$eng WHERE userid=$userid"); } elseif ($search =="7") { print "You help a little old lady accross the street. You gain slack and mojo. She gives you some change. It's $money dollars!"; mysql_query("UPDATE users SET will=will+$will,brave=brave+$brave,money=money+$money,energy=energy-$eng WHERE userid=$userid"); } elseif ($search =="8") { print "You head to the arcade. A pal of yours is there. You end up tripping some acid with them. You gain slack and mojo. They give you a couple bucks for the cab ride home. It's $money dollars."; mysql_query("UPDATE users SET will=will+$will,brave=brave+$brave,money=money+$money,energy=energy-$eng WHERE userid=$userid"); } elseif ($search =="9") { print "You head college district. You run into a cute massage therapist in training. They give you a free massage. You feel refreshed and healthier. You gain slack."; mysql_query("UPDATE users SET hp=hp+$hp,will=will+$will,energy=energy-$eng WHERE userid=$userid"); } elseif ($search =="10") { print "You head to the college district. You run into a Discordian Minister. He rants something about FNORD and raw hotdogs. You gain slack from hearing the rant. He talks you into giving him $30."; mysql_query("UPDATE users SET money=money-$money2,will=will+$will,energy=energy-$eng WHERE userid=$userid"); } elseif ($search =="11") { print "You go to the club district to find some fun. Instead you find your whiny buddy who is drunk and babbling about his problems. You get stuck baby sitting them. You lose slack, mojo, and energy."; mysql_query("UPDATE users SET energy=energy-$energy,brave=brave-$brave,will=will-$will,energy=energy-$eng WHERE userid=$userid"); } elseif ($search =="12") { print "You go to the club district to find some fun. You run into some pretty girlies to spend the night with. You find $money dollars and feel a little smarter. You gain some slack. You gain $IQ IQ."; mysql_query("UPDATE users SET IQ=IQ+$IQ,money=money+$money,will=will+$will,energy=energy-$eng WHERE userid=$userid"); } elseif ($search =="13") { print "You wander down an alley. You hustle some kids playing craps on their smoke break. You win $money smackers and feel a little smarter. You gain some slack. You gain $IQ IQ."; mysql_query("UPDATE users SET IQ=IQ+$IQ,money=money+$money,will=will+$will,energy=energy-$eng WHERE userid=$userid"); } elseif ($search =="14") { print "You see a pretty rainbow. You spot a leprechaun. You take him hostage and ransom some gold from his leprechaun pals. They bring you the money. You feel a little smarter."; mysql_query("UPDATE users SET IQ=IQ+$IQ,money=money+$money,money=money+$money2,energy=energy-$eng WHERE userid=$userid"); mysql_query("UPDATE userstats SET IQ=IQ+$IQ WHERE userid=$userid"); } elseif ($search =="15") { print "An alien saucer lands. An Alien hops out and hands you money. The Alien sends you $will Slack and $IQ IQ through telepathy."; mysql_query("UPDATE users SET IQ=IQ+$IQ,will=will+$will,money=money+$money,money=money+$money2,energy=energy-$eng WHERE userid=$userid"); } elseif ($search =="17") { print "A fuck buddy calls you up. They take you out on a date, and fuck your brains out. You love it! You get double the Slack, and double the Mojo."; mysql_query("UPDATE users SET will=will+$will,will=will+$will,brave=brave+$brave,brave=brave+$brave,energy=energy-$eng WHERE userid=$userid"); } elseif ($search =="18") { print "You head to the local swimming pool. You see a super babe. You stub your toe, and break it! The babe laughs at you as you head to the hospital. You lose extra slack for being a fool."; mysql_query("UPDATE users SET will=will-$will,will=will-$will,hosp=hosp+$hosp,energy=energy-$eng WHERE userid=$userid"); mysql_query("UPDATE users SET hospreason='Stubbed toe' WHERE userid = $userid"); } elseif ($search =="19") { print "BAM! You've been penny rolled in the back of the head! You try to decipher the laughter of your enemy. You can't figure out who it is. You go to the hospital to get sewn up. You lose $will slack for not paying attention."; mysql_query("UPDATE users SET will=will-$will,hosp=hosp+$hosp,energy=energy-$eng WHERE userid=$userid"); mysql_query("UPDATE users SET hospreason='Boot to the Head' WHERE userid = $userid"); } elseif ($search =="20") { print "You run into a sexy hooker! She offers to give you a blowjob around the corner. You unzip, and get ready to go. Her three brothers are there to beat the crap out of you. They rob you for $ $money. You end up in the hospital. You lose $will slack for not paying attention."; mysql_query("UPDATE users SET money=money-$money,will=will-$will,hosp=hosp+$hosp,energy=energy-$eng WHERE userid=$userid"); mysql_query("UPDATE users SET hospreason='Mugged' WHERE userid = $userid"); } elseif ($search =="21") { print "You head to the shopping mall to pick some pockets. You decide to pick undercover grandma's pocket. She whoops the living shit out of you with her ninja moves. She hauls you off to jail, you lose $will slack."; mysql_query("UPDATE users SET hp=hp-$hp,will=will-$will,jail=jail+$jail,energy=energy-$eng WHERE userid=$userid"); mysql_query("UPDATE users SET jail_reason='Picking pockets at the mall' WHERE userid = $userid"); } elseif ($search =="22") { print "You wander out in to the woods. You find some mushrooms on the ground and eat them. You trip out and think you're a salmon. So does the bear that is mauling you and eating you. The paramedics tell hunting jokes on the way to the hospital."; mysql_query("UPDATE users SET hp=hp-$hp,will=will-$will,hosp=hosp+$hosp,energy=energy-$eng WHERE userid=$userid"); mysql_query("UPDATE users SET hospreason='Mauled by a Bear' WHERE userid = $userid"); } elseif ($search =="23") { print "You go to the excremeditation chamber to read your favorite book. It's the Book of The Subgenius. You feel alot less pink in this conspiracy world. You take an excellent dump. In the bowl you find the image of Dobbs in your poo. You mail your picture into the local newspaper. The headline reads Dobbs Sighted in local toilet. You gain triple the slack!!!"; mysql_query("UPDATE users SET will=will+$will,will=will+$will,will=will+$will,energy=energy-$eng WHERE userid=$userid"); } elseif ($search =="24") { print "You go to the excremeditation chamber to read your favorite book. It's the Book of The Subgenius. You feel alot less pink in this conspiracy world. You take an excellent dump. In the bowl you find the image of Dobbs in your poo. You mail your picture into the local newspaper. The headline reads Nutty Terrorist Takes Photos of Feces. They call homeland security and have you arrested."; mysql_query("UPDATE users SET will=will-$will,jail=jail+$jail,energy=energy-$eng WHERE userid=$userid"); mysql_query("UPDATE users SET jail_reason='Poo Terrorist' WHERE userid = $userid"); } exit; } } } ?> <?php include("footer.php"); ?> Quote
Agon Posted June 17, 2009 Author Posted June 17, 2009 Re: Mccodes Lite Userstats IQ Bug my header.php <?php /* MCCodes Lite header.php Rev 1.0.1 Copyright (C) 2006 Dabomstew This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ class headers { function startheaders() { include "hideurl.js"; global $ir; echo <<<EOF <html> <head> <title>Peace Wars</title> <style> body { font-family:helvetica, arial, geneva, sans-serif;font-size:16;color:#ededed; scrollbar-base-color: #616161; scrollbar-arrow-color: #ededed; scrollbar-DarkShadow-Color: #000000; } a:visited,a:active,a:hover,a:link { color: #ededed;text-decoration: decorate; } table,tr,td { font-family:helvetica, arial, geneva, sans-serif;font-size: 14; } img { border:none; } textarea { font-family:helvetica, arial, geneva, sans-serif;font-size:16;color: black; } </style> </head> EOF; } function userdata($ir,$lv,$fm,$dosessh=1) { global $c,$userid; $ip = $_SERVER['REMOTE_ADDR']; mysql_query("UPDATE users SET laston=unix_timestamp(),lastip='$ip' WHERE userid=$userid",$c); session_start(); ob_start(); $userid = abs(@intval($_SESSION['userid'])); if(!$ir['email']) { die ("<body>Your account may be broken. Please mail [email][email protected][/email] stating your username and player ID."); } if($dosessh && $_SESSION['attacking']) { print "You lose some of your EXP for not completing the fight."; mysql_query("UPDATE users SET exp=exp-1 WHERE userid=$userid",$c); $_SESSION['attacking']=0; } $enperc=(int) ($ir['energy']/$ir['maxenergy']*100); $oxperc=(int) ($ir['oxygen']); $wiperc=(int) ($ir['will']/$ir['maxwill']*100); $experc=(int) ( $ir['exp']/$ir['exp_needed']*100); $brperc=(int) ($ir['brave']/$ir['maxbrave']*100); $hpperc=(int) ($ir['hp']/$ir['maxhp']*100); $enopp=100-$enperc; $oxopp=100-$oxperc; $wiopp=100-$wiperc; $exopp=100-$experc; $bropp=100-$brperc; $hpopp=100-$hpperc; $d=""; $u=$ir['username']; print "<body bgcolor='#616161' background='background3.png'> <table width=100%> <td> [url='http://www.google.com/search?hl=en&q=how+to+be+a+better+employee&aq=f&oq='][img=peacewarslogo.gif][/url] <td align = right> [b]Name:[/b] {$u} [{$ir['userid']}] [b]Money:[/b] {$fm} [b]Level:[/b] {$ir['level']} [b]Credits:[/b] {$ir['crystals']} [[url='logout.php']Logout[/url]]</td> <td> <td align = right> [b]Energy:[/b] [b]{$ir['energy']}/{$ir['maxenergy']}[/b] <img src=bargreen.gif width=$enperc height=6><img src=barred.gif width=$enopp height=6> [b]Oxygen:[/b] {$oxperc}% [b][/b] <img src=bargreen.gif width=$oxperc height=6><img src=barred.gif width=$oxopp height=6> [b]Slack:[/b] [b]{$ir['will']}/{$ir['maxwill']}[/b] <img src=bargreen.gif width=$wiperc height=6><img src=barred.gif width=$wiopp height=6> [b]Mojo:[/b] [b]{$ir['brave']}/{$ir['maxbrave']}[/b] <img src=bargreen.gif width=$brperc height=6><img src=barred.gif width=$bropp height=6> [b]EXP:[/b] {$experc}% <img src=bargreen.gif width=$experc height=6><img src=barred.gif width=$exopp height=6> [b]Health:[/b] [b]{$ir['hp']}/{$ir['maxhp']}[/b] <img src=bargreen.gif width=$hpperc height=6><img src=barred.gif width=$hpopp height=6></td></tr></table></div> <table> <tr><td>[url="index.php><img"][/url]</td><td>[url="explore.php><img"][/url]</td><td>[url="jail.php><img"][/url]</td><td>[url="hosp.php><img"][/url]</td><td>[url="criminal.php><img"][/url]</td><td>[url="random.php><img"][/url]</td><td>[url="gym.php><img"][/url]</td><td>[url="inventory.php><img"][/url]</td><td>[url="http://widget.mibbit.com/?settings=63437a7c0d672deb095d323bffc31d6f&server=irc.taphouse.org&channel=%23peace-wars&noServerNotices=true&noServerMotd=true"]<img src=chatbutton.jpg>[/url]</td><td>[url="forums.php><img"][/url]</td><td>[url="search.php><img"][/url]</td></tr> </table> "; print "<table width=100%><tr><td width=20% valign='top'> "; if($ir['fedjail']) { $q=mysql_query("SELECT * FROM fedjail WHERE fed_userid=$userid",$c); $r=mysql_fetch_array($q); die("[b]<font color=red size=+1>You have been put in the Your Peace Wars Federal Jail for {$r['fed_days']} day(s). Reason: {$r['fed_reason']}</font>[/b]</body></html>"); } if(file_exists('ipbans/'.$ip)) { die("[b]<font color=red size=+1>Your IP has been banned, there is no way around this.</font>[/b]</body></html>"); } } function menuarea() { include "mainmenu.php"; global $ir,$c; print "</td><td valign='top'> "; } function endpage() { print "</td> <td width=20% valign='right' align=top> "; print "</td> </tr></table></body> </html>"; } } ?> Quote
Agon Posted June 17, 2009 Author Posted June 17, 2009 Re: Mccodes Lite Userstats IQ Bug global_func.php <?php /* MCCodes Lite global_func.php Rev 1.0.1 Copyright (C) 2006 Dabomstew This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ function money_formatter($muny,$symb='$') { $moneys=""; $muny= (string) $muny; if (strlen($muny) <= 3) { return $symb.$muny; } $dun=0; for($i=strlen($muny);$i>0;$i-=1) { if ($dun % 3 == 0 && $dun > 0) { $moneys=",".$moneys; } $dun+=1; $moneys=$muny[$i-1].$moneys; } return $symb.$moneys; } function itemtype_dropdown($connection,$ddname="item_type",$selected=-1) { $ret="<select name='$ddname' type='dropdown'>"; $q=mysql_query("SELECT * FROM itemtypes ORDER BY itmtypename ASC",$connection); if($selected == -1) { $first=0; } else { $first=1; } while($r=mysql_fetch_array($q)) { $ret.="\n<option value='{$r['itmtypeid']}'"; if ($selected == $r['itmtypeid'] || $first == 0) { $ret.=" selected='selected'";$first=1; } $ret.=">{$r['itmtypename']}</option>"; } $ret.="\n</select>"; return $ret; } function item_dropdown($connection,$ddname="item",$selected=-1) { $ret="<select name='$ddname' type='dropdown'>"; $q=mysql_query("SELECT * FROM items ORDER BY itmname ASC",$connection); if($selected == -1) { $first=0; } else { $first=1; } while($r=mysql_fetch_array($q)) { $ret.="\n<option value='{$r['itmid']}'"; if ($selected == $r['itmid'] || $first == 0) { $ret.=" selected='selected'";$first=1; } $ret.=">{$r['itmname']}</option>"; } $ret.="\n</select>"; return $ret; } function location_dropdown($connection,$ddname="location",$selected=-1) { $ret="<select name='$ddname' type='dropdown'>"; $q=mysql_query("SELECT * FROM cities ORDER BY cityname ASC",$connection); if($selected == -1) { $first=0; } else { $first=1; } while($r=mysql_fetch_array($q)) { $ret.="\n<option value='{$r['cityid']}'"; if ($selected == $r['cityid'] || $first == 0) { $ret.=" selected='selected'";$first=1; } $ret.= ">{$r['cityname']}</option>"; } $ret.="\n</select>"; return $ret; } function shop_dropdown($connection,$ddname="shop",$selected=-1) { $ret="<select name='$ddname' type='dropdown'>"; $q=mysql_query("SELECT * FROM shops ORDER BY shopNAME ASC",$connection); if($selected == -1) { $first=0; } else { $first=1; } while($r=mysql_fetch_array($q)) { $ret.="\n<option value='{$r['shopID']}'"; if ($selected == $r['shopID'] || $first == 0) { $ret.=" selected='selected'";$first=1; } $ret.= ">{$r['shopNAME']}</option>"; } $ret.="\n</select>"; return $ret; } function user_dropdown($connection,$ddname="user",$selected=-1) { $ret="<select name='$ddname' type='dropdown'>"; $q=mysql_query("SELECT * FROM users ORDER BY username ASC",$connection); if($selected == -1) { $first=0; } else { $first=1; } while($r=mysql_fetch_array($q)) { $ret.="\n<option value='{$r['userid']}'"; if ($selected == $r['userid'] || $first == 0) { $ret.=" selected='selected'";$first=1; } $ret.= ">{$r['username']}</option>"; } $ret.="\n</select>"; return $ret; } function fed_user_dropdown($connection,$ddname="user",$selected=-1) { $ret="<select name='$ddname' type='dropdown'>"; $q=mysql_query("SELECT * FROM users WHERE fedjail=1 ORDER BY username ASC",$connection); if($selected == -1) { $first=0; } else { $first=1; } while($r=mysql_fetch_array($q)) { $ret.="\n<option value='{$r['userid']}'"; if ($selected == $r['userid'] || $first == 0) { $ret.=" selected='selected'";$first=1; } $ret.= ">{$r['username']}</option>"; } $ret.="\n</select>"; return $ret; } function event_add($userid,$text,$connection) { $text=mysql_escape($text); mysql_query("INSERT INTO events VALUES('',$userid,UNIX_TIMESTAMP(),0,'$text')",$connection) or die(mysql_error()." "."INSERT INTO events VALUES('',$userid,UNIX_TIMESTAMP(),0,'$text')"); return 1; } function mysql_escape($str) { return str_replace("'","''",$str); } function check_level() { global $ir,$c,$userid; $ir['exp_needed']=(int) (($ir['level']+1)*($ir['level']+1)*($ir['level']+1)*2.2); while($ir['exp'] >= $ir['exp_needed'] and $ir['level'] < 950) { $expu=$ir['exp']-$ir['exp_needed']; $ir['level']+=1; $ir['exp']=$expu; $ir['energy']+=2; $ir['brave']+=2; $ir['maxenergy']+=2; $ir['maxbrave']+=2; $ir['hp']+=50; $ir['maxhp']+=50; $ir['exp_needed']=(int) (($ir['level']+1)*($ir['level']+1)*($ir['level']+1)*2.2); mysql_query("UPDATE users SET level=level+1,exp=$expu,energy=energy+2,brave=brave+2,maxenergy=maxenergy+2,maxbrave=maxbrave+2, hp=hp+50,maxhp=maxhp+50 where userid=$userid",$c); } } function get_rank($stat, $mykey) { global $ir,$userid,$c; $q=mysql_query("SELECT count(*) FROM userstats us LEFT JOIN users u ON us.userid=u.userid WHERE us.$mykey > $stat AND us.userid != $userid AND u.user_level != 0", $c) ; return mysql_result($q,0,0)+1; } function make_bigint($str, $positive=1) { $str = (string) $str; $ret = ""; for($i=0;$i<strlen($str);$i++) { if((ord($str[$i]) > 47 && ord($str[$i]) < 58) or ($str[$i]=="-" && $positive == 0)) { $ret.=$str[$i]; } } if(strlen($ret) == 0) { return "0"; } return $ret; } ?> Quote
Agon Posted June 17, 2009 Author Posted June 17, 2009 Re: Mccodes Lite Userstats IQ Bug Another unusual thing, now it lets no user gain IQ. What bewilders me is how it worked fine, then halfway worked, and now doesn't work at all. Quote
Lithium Posted June 17, 2009 Posted June 17, 2009 Re: Mccodes Lite Userstats IQ Bug at a quick glance... you should declare these functions $money=rand(1,60); /*--- Value of money to be found min 1 max 60 ---*/ $money2=(30); /*--- extra money table ---*/ $crys=rand(0,0); /*--- crystals min 0 max 0 --- */ $hosp=rand(1,20); /*--- hosp time between 1 mins and 20 mins ---*/ $jail=rand(1,20); /*--- Jail time between 1 mins and 20 mins ---*/ $will=rand(3,15); /*--- slack between 1 and 10 ---*/ $energy=rand(1,2); /*--- extra energy table 1% - 2% energy gain or loss---*/ $IQ=rand(1,2); /*---IQ 1 to 2 points ---*/ $hp=rand(1,10); /*--- Hitpoints 1 - 10 ---*/ $brave=rand(1,3); /*--- Mojo 1 - 3 points ---*/ Only when updating the users on the mysql_query() Last elseif() (search 24) should be else() if($ir['hosp'] >0) can be if ($ir['hosp']) same applies to jail try using switch() and avoid all those if/elseif/else statements, As of the initial problem, as i said before and with the code at sight... there is no reason for it to not be working. Only after testing the code i could go deeper, though i'm prolly sure that by the time i am capable to test it, someone already has done the same :) Quote
Agon Posted June 17, 2009 Author Posted June 17, 2009 Re: Mccodes Lite Userstats IQ Bug Much thanks for the advice to clean up my code. Now my idea is that we've hit 51 users. And it could be a linux permissions problem. Not sure yet though. The art of de bugging! Quote
Haunted Dawg Posted June 17, 2009 Posted June 17, 2009 Re: Mccodes Lite Userstats IQ Bug I have a server and a website with 9094 user's, there is no problem with having 51 user's. Quote
codestryke Posted June 17, 2009 Posted June 17, 2009 Re: Mccodes Lite Userstats IQ Bug I don't think the bug has anything to do with the query. I think it has something more to do with Mccodes Lite. It's all about the query.. In lite IQ is stored in userstats, not the user table... Hence why IQ works #14 but doesn't work with #12, #13 and #15 Also on #14 you try to update it in user first then it updates userstats like it's suppose to.. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.