Jump to content
MakeWebGames

boionfire81

Members
  • Posts

    532
  • Joined

  • Last visited

  • Days Won

    6

Everything posted by boionfire81

  1. The distinct I think might be more of what I need. Each member can hold several different stocks. A row is created for each user and their individual stocks. Then there is a column that sets the amount of shares they are willing to sell and how much they are willing to sell for. I need to select the lowest price of each stock. What I have now is simply displaying every single row in the table being queried.   $q=$db->query("SELECT DISTINCT `stockID`, `stockNAME`, `stockPRICE` FROM `shares` WHERE `stockSELL`> 0 ORDER BY `stockPRICE` ASC"); while($r=$db->fetch_row($q)) {
  2. I need to select 1 row for each stockID with the result being the lowest price. $q=$db->query("SELECT `stockID`, `stockNAME`, `stockPRICE` FROM `shares` WHERE `stockSELL`> 0 GROUP BY `stockID` ORDER BY `stockPRICE` ASC"); while($r=$db->fetch_row($q)) {   The where stockSELL does fine. But if there are 2 people selling the stock it list every result for that. >.< I never used group, so this is probably where the error is.
  3. lol. My bad man, I'm just now making it back to this thread. But thanks! Will let you know if it works out.
  4. Yeah, I'mma code it like I remod'd the invade a house mod. Steal the stuff, not the cash :) But yeah, I probably need to think more about the "jury" thing. I was trying to figure out a way to have a court process. Just hadn't gotten there yet ;)
  5. Ok, js, or ajax, or whatever, is far not my strong suit. So, I've used this in replacement to fit mine (js not changed any)   $buyprice=money_formatter($r['itmbuyprice']); ?> <input type='text' name='qty' value='1' onkeyup="tot(<?=$r['itmid']?>,<?=$r['itmbuyprice']?>,this.value);" onfocus="clearText(this);" onblur="returnText(this);"><input type='submit' id="res<?=$r['itmid']?>" value='<?=$buyprice?>'></form> <?   Button displays the price, but does not update to the new price after input.
  6. boionfire81

    Time

    So yeah, this might just be going to far in depth. But unique, creative, and user-responsive design is what I am aiming for. So here's the question. How can I determine the "time/day" through php from only mysqli input to show given information based on such. (i.e. not geolocation, but strict database). A complete list of locations, timezones, and time offsets is already done. (Just need to shrink from 2 tables to 1). I have no clue with timing. What I want to do 4 things 1) An exact time (mostly for fluff actually). 2) Determine day/night time. (mostly design, but some store closing, bar open stuff) 3) Determine the day of the week (Simply to give a unique "clubbing" experience) 4) Determine the season (Used for my farming mod) I imagine exact date/time would be a simple select `offset` from locations where location = $ir['located']. And then a $truetime= time() - `offset` I could be right or wrong on that. Just guessing from what I've learned so far. Now using the above settings. Me = no clue!  
  7. Yeah, I still don't know the exact difference between mt_rand and rand. Also currently trying to find the difference between require and require_once.
  8. Ok, so I thought I'd post this here, and let everyone see how it's coming along and add comments if you want. This is probably the biggest remod I've done yet. So give it time to finish. But in the mean time.... yeah :)   $mwepdamage = ($r1['weapon'] * $mdata['strength'] / 100); if($area['stat'] === 'Agility') { $mdhitboost = (($mdata['agility'] * $area['chance']) - ($odata['speed'] * (100 - $area['chance']))); $odhitboost = (($odata['agility'] * $area['chance']) - ($mdata['speed'] * (100 - $area['chance']))); } if($area['stat'] === 'Speed') { $mdhitboost = (($mdata['speed'] * $area['chance']) - ($odata['agility'] * (100 - $area['chance']))); $odhitboost = (($odata['speed'] * $area['chance']) - ($mdata['agility'] * (100 - $area['chance']))); } $where = rand(1,5); $owepdamage = ($r2['weapon'] * $mdata['strength'] / 100); if($where == 1) { $mdefense = ($mdata['guard'] * $mdata['head'] / 100); $odefense = ($odata['guard'] * $odata['head'] / 100); } else if($where == 2) { $odefense = ($odata['guard'] * $odata['torso'] / 100); $mdefense = ($mdata['guard'] * $mdata['torso'] / 100); $place = rand(1,3); if($place == 1) { $spot = 'left side'; } else if($place == 2) { $spot = 'right side'; } else { $spot = 'stomach'; } } else if($where == 3) { $odefense = ($odata['guard'] * $odata['hands'] / 100); $mdefense = ($mdata['guard'] * $mdata['hands'] / 100); $place = rand(1,2); if($place == 1) { $spot = 'left hand'; } else { $spot = 'right hand'; } } else if($where == 4) { $odefense = ($odata['guard'] * $odata['legs'] /100); $mdefense = ($mdata['guard'] * $mdata['legs'] /100); $place = rand(1,2); if($place == 1) { $spot = 'left leg'; } else { $spot = 'right leg'; } } else { $odense = ($odata['guard'] * $odata['feet'] / 100); $mdense = ($mdata['guard'] * $mdata['feet'] / 100); $place = rand(1,2); if($place == 1) { $spot = 'left foot'; } else { $spot = 'right foot'; } }   That's just deciding the damage vs defense and random hit location/side. Weapon hit phrase like "sliced" or "clubbed" are actually defined in the sql for a more creative touch. The "area" portion is just one of the unique features I have on my game. But in the end it only applies a small portion in the attack page. Still to decide first hit, to start the hp updates, and develop armor damage/weapon breaks. Not really sure where to go with the hp thing here. Just because I hate one hitter quitters. Much nicer to torture right? lol. Just can't decide how to turn this around to atleast 2-3 hits. Overall I think this will turn out to be a nice attack page. All be it, a massive amount of work in progress. (Please hold all 'security' comments until it actually near finish!)
  9. OK, I'm now starting to get into the code of it all on a per instance/feature basis. Here is the example for brewery. Index check if exist/ready $b=$db->query("SELECT * FROM `brewery` WHERE `userid`={$ir['userid']}"); if(!$db->num_rows($b)) { echo "What type of brew would you like to begin?<br><a href='?action=beer'>Beer</a> | <a href='?action=whiskey'>Whiskey</a> | <a href='?action=wine'>Wine</a>"; } else { $brew=$db->fetch_row($b); $brews=$db->fetch_row($db->query("SELECT `itmname` FROM `items` WHERE `itmid`={$brew['item']}")); if($brew['time'] < ".time ().") { echo "Your {$brews['itmname']} is ready!"; item_add($brew['userid'],$brew['item'],$brew['qty']); $db->query("DELETE FROM `brewery` WHERE `time` < time()"); } else { echo "Your {$brews['itmname']} are still brewing. Come back in ".time_format($brew['time'])." to finish the brew."; } }   Begin brew $inv=$db->query("SELECT `qty` FROM `inventory` WHERE `userid`={$ir['userid']} AND `itemid`=206"); $invc=$db->num_rows($inv); if ($invc = 0) { echo "You need supplies before you can brew beer."; } else { $db->query("INSERT INTO `brewery` VALUES ({$ir['userid']},".(time() + 3600).",46,12)"); item_remove($ir['userid'],206,1); echo "You have begun the brew. Come back in an hour to collect your beer"; }   As of right now it does detect and wait for completion. However, the insert is incorrect. Instead of 1 hour, it is 14 hours? 60sec. x 60 mins. = 3600 right? For some reason I could not use timestamp for mysqli, had to use just time.
  10. Well the angle I'm using is the wait table has a timestamp. Whenever globals are run it checks the wait table for timestamps expired. Obviously if no one is online it doesn't matter for someone's release or not. But all other crons are still run normally. Allowing energy etc to update regardless. Minimizing the wait table columns and rows to speed up that one query.
  11. oh damn ouch! No, just have a hell slow comp. Had to replace my dell quick and ended up with an asus >.<
  12. At this moment yes. But the table structure is being redone ALOT. I was ticked off when I saw 140 columns in the user table. Literally slowed my comp down just to browse the structure. And since my game is developing far off the gangster games into a gangster/tycoon/detective game. I'm really wanting to change up the table structure. With fight stats in one, user cash flow in another, and the wait times in another. While I will have a user/account table to store ids etc, basically everything is branching out. The only constant update will need to be the wait table. Deleting un-needed rows will help speed up that one constant. As per the rest they can be run from within the areas themselves. Ideally I think one table per action/feature with an update/remove when used is going to be the best solution in the end.  
  13. Yeah but that's the delete time. The insert time is more like $db->query("INSERT VALUES({$ir['userid']},(time() + 999), 'in jail')");   But just doing that I do see one mistake. The accesslevel should actually be in the wait table I think. Will also add reason to the wait table. Plus I use two additional files with my game. access.php and available.php. These files are what locks the pages if the user is busy. By setting an accesslevel I can easy modify to allow access to specific pages only. And instead of querying a 100+ column user table everytime something happens somewhere. I can delete about a dozen columns, and only query the wait table (with 5 columns) when needed. For example access.php, jail.php, and hospital.php. The remaining queries would be based on where the access.php file is included. Which still cuts back on query time as the columns are much less, and rows will be deleted when not applicable. Opinions? Do you think this is a reasonable solution to the overloaded user table? And/Or speed of queries?  
  14. Well for one it wont actually be a cron job. More like an update in the globs. And I don't see the error? This table only has 3 rows, userid (to tie in with other iznit), time (to deduce their wait time remaining), and a why(ENUM) to simply print out an easy reason to why they are having to wait rather than querying the user table with what seems like 100+ rows. Removing a good 10 rows from the user table and replacing with 1 `accesslevel`.
  15. ok, so basically to trunicate my wait table is simply   $db->query(DELETE FROM `wait` WHERE `time` < time()");   I'm trunicating for query speeds. As this query will eventually be run ALOT. The less columns and rows the better you know. Plus I'm trying to reduce my users table as much as possible.
  16. Well this is just me trying to put two and two together. By inserting a unix timestamp + number of seconds the wait time is will enable a java countdown on the jail/hosp page to show the exact amount of time remaining. By having a single query run in globals there should be a way to update the release if time =
  17. Staff if this is the wrong forum, please move to proper category. My question is this. How can I use unix timestamps to control and display a precise(down to the second) of a time remaining until the time wait is over? I know   UNIX_TIMESTAMP()   will insert the current date/time. But I'm thinking there has to be a way to use this to keep things updated to the second in timestamp crons (including a constant cron for the 'very active'/'much needed' real time countdowns. If I insert a specific time format, use a typical java countdown, with a constant timestamp cron to update and delete should be all? That's what I'm guessing. Not exactly sure how to go about it though. Any ideas? [uSER=64684]Dayo[/uSER] I know you know this :)
  18. mind if I try to port to McCodes v2?
  19. Thanks! That had me stumped, lol!
  20. Ok, is anyone willing to take on the project? My knowledge of all forms js is 0%
  21. Ok, no clue about these graph things, but I have a lot of places I would like to use this at. But When I go to iteminfo it displays the "image not found" thingy. When I click view image it says: A critical error has occurred, and page execution has stopped. Below are the details: PHP Warning: array_slice() expects parameter 1 to be array, string given (2) What is array_slice? O.o
  22. Ok, so I want to implement a "cellphone" type thing. Basically, I don't even know what program language(s) could even do this. Something that will "pop up"/flash in a "screen" area like a cell phone alert. Will need help learning how to use it too cause, I can't even think of a language that can do a "live screen change area". Message me if your interested. Might need a co-op on this? So just lemme know guys.
  23. So, running every single page through phpcodechecker.com and my gym page is giving this: PHP Syntax Check: Parse error: syntax error, unexpected '>' in your code on line 1   if($ir['strank'] [100] <=> [51])   I really do not see the error?
×
×
  • Create New...