Jump to content
MakeWebGames

Magictallguy

Administrators
  • Posts

    2,146
  • Joined

  • Last visited

  • Days Won

    149

Everything posted by Magictallguy

  1. My apologies, my internet has been cut off for a few days - got cut off from the world in the process. I can do it ;)
  2. Granted, but in this case, you're expecting an int/float, not a string ;)
  3. Plzn, plzno, kthx
  4. Recommending use of ctype_digit() over abs(intval($var)) + 0 for this instance.. $bounty = array_key_exists('bounty', $_GET) && ctype_digit($_GET['bounty']) ? $_GET['bounty'] : null;
  5. Error exists because you've added a WHERE clause. Remove it (and put the "boxes" part of the query in a new query, or change it so it doesn't needed the WHERE)
  6. Aye, perhaps it be a little overkill, I just like to cover as many bases as possible. For most, though: if(!isset($_GET['action'])) $_GET['action'] = null; should be enough (though I would recommend the use of array_key_exists() over isset() in these cases
  7. Perhaps, but this also filters in for SilLYCaSe actions. without strotlower() file.php?action=SomEThing = default with it file.php?action=SomEThing = whatever "something" is. Good for developers who make typos or catch the shift key too often (I have done both many times)
  8. *sigh* Please actually read the answers granted. Add: $_GET['action'] = array_key_exists('action', $_GET) && ctype_alpha($_GET['action']) ? strtolower(trim($_GET['action'])) : null; if you want it to be done properly in this case, or if(!isset($_GET['action'])) $_GET['action'] = ''; if not - above the switch($_GET['action'])
  9. ALTER TABLE `papercontent` ADD `page2_content` TEXT NOT NULL, ADD `page3_content` TEXT NOT NULL;
  10. bcoz ppl dun no cde lyk we do That, and newbies are exactly that. The amount of times I had buggy code on production servers was insane and beyond idiotic. Suppressed all errors to all but myself though, so that was easy enough
  11. Wow, gravedig and a half there. I'm not seeing any reference to "news" within my code (my old, fugly code at that) Where are you getting that E_NOTICE?
  12. What, in the absolute fuckhole, is this shit?! Moderators, please take this down - this is beyond offensive -.-
  13. If you feel like giving us the error message, we may be able to help you.
  14. My apologies for both the graveyard dig and the lateness of my response. I've done minor optimizations on the entire staff_chat.php file. I'll do some debugging shortly -- Edit: Debug complete (unfortunately, no test area, so I can't properly test it. Any issues, post back please :)
  15. In docrime.php, the $sucrate (or success rate) is determined, by default, using basic maths - algebra, to be exact. $find = ['LEVEL', 'CRIMEXP', 'EXP', 'WILL', 'IQ']; $repl = [$ir['level'], $ir['crimexp'], $ir['exp'], $ir['will'], $ir['IQ']]; $sucrate = str_replace($find, $repl, $r['crimePERCFORM']);   The default formula upon crime creation is ((WILL*0.8)/2.5)+(LEVEL/4) Remember that "BODMAS", BIDMAS", "PEMDAS", or however you remember it, all play in here - I was taught the "BIDMAS" method, though they all mean basically the same thing. Brackets Indices Division Multiplication Addition Subtraction (in that order) Now, for example, we'll use the "stats" that would be there as a brand new player (i.e. Will = 100, Level = 1, CrimeXP = 0, EXP = 0, IQ = 10) Break up the formula, brackets comes first. ((100 * 0.8) / 2.5) = 80 / 2.5 = 32 (1 / 4) = 0.25 32 + 0.25 = 32.25 So, that leaves us with 32.25. Now, because of the way that the docrime.php is setup, the closer to 100 the formula equals, the easier the crime (anything above 100 is treated as success anyway). With that logic, and with a newbie (to your game), there's at least 32.25% chance of successfully completing that crime. I say "at least" because there's also a rand() in there too, adding to the chances of success The output from the crime failure is simple. It's a 50% chance of just a fail or jail time. --------- You can easily add to that str_replace() logic at the top, adding more things like 'TOTAL_STATS', 'STRENGTH', 'MONEY', etc. (and obviously add the replacements too) to be able to use more modifiers.
  16. From what I can tell by reading the code CREATE TABLE `referrals` ( `refID` INT(11) NOT NULL PRIMARY KEY AUTO_INCREMENT, `refREFER` INT(11) NOT NULL DEFAULT 0, `refREFED` INT(11) NOT NULL DEFAULT 0, `refBONUS` INT(11) NOT NULL DEFAULT 0 ); CREATE TABLE `referrals_reward` ( `refID` INT(11) NOT NULL PRIMARY KEY AUTO_INCREMENT, `refLEVEL` INT(11) NOT NULL DEFAULT 0, `refBONUS` INT(11) NOT NULL DEFAULT 0, `refMONEY` INT(11) NOT NULL DEFAULT 0, `refCOINS` INT(11) NOT NULL DEFAULT 0 );
  17. Put the to-be-serialized data into separate columns. Make the PHP do the rest ;)
  18. That list is incomplete. But I believe I can run a pretty easy conversion - CSV -> SQL :)
  19. Needs completing, haven't got around to it yet - been far too busy with IRL stuff
  20. This isn't the place for updates.   Of course he does
  21. Don't add an E then :P
  22. Shoot me a link! If nothing else, I'm curious
  23. That doesn't exist in my code, no idea why you're getting that error O.o
  24. Added search by item type and item name <?php require_once __DIR__ . '/globals.php'; if(!function_exists('format')) { function format($str, $dec = 0) { // purely for my own laziness.. return is_numeric($str) ? number_format($str, $dec) : stripslashes(htmlspecialchars($str)); } } $where = ''; if(array_key_exists('type', $_GET)) { $_GET['type'] = ctype_digit($_GET['type']) ? $_GET['type'] : null; if(!empty($_GET['type'])) { $selectType = $db->query('SELECT `itmtypename` FROM `itemtypes` WHERE `itmtypeid` = '.$_GET['type']); if($db->num_rows($selectType)) $where .= ' WHERE `itmtypeid` = '.$_GET['type']; } } if(array_key_exists('item', $_GET)) { $_GET['item'] = is_string($_GET['item']) ? $db->escape($_GET['item']) : null; if(!empty($_GET['item'])) { $where .= !$where ? ' WHERE' : ' AND'; $where .= ' `itmname` LIKE("%'.$_GET['item'].'%")'; } } $select = $db->query('SELECT `itmname`, `itmdesc`, `itmbuyprice`, `itmsellprice`, `weapon`, `armor`, `itmtypename` FROM `items` LEFT JOIN `itemtypes` ON `items`.`itmtype` = `itemtypes`.`itmtypeid` '.$where.' ORDER BY `itmtype` ASC, `itmname` ASC'); $selectTypes = $db->query('SELECT `itmtypeid`, `itmtypename` FROM `itemtypes` ORDER BY `itmtypename` ASC'); ?><form method="get"> <table class="table" width="100%"> <tr> <th width="25%">Search by type</th> <td width="75%"><select name="type"> <option value="0">--- None ---</option><?php while($row = $db->fetch_row($selectTypes)) printf('<option value="%u"%s>%s</option>', $row['itmtypeid'], !empty($_GET['type']) && $_GET['type'] == $row['itmtypeid'] ? ' selected="selected"' : null, format($row['itmtypename'])); ?></select></td> </tr> <tr> <th>Search by item</th> <td><input type="text" name="item" placeholder="Partial or complete name" /></td> </tr> <tr> <td colspan="2" class="center"><input type="submit" value="Search" /></td> </tr> </table> </form><br /> <table class="table" width="100%"> <tr> <th>Item</th> <th>Description</th> <th>Type</th> <th>Buy/Sell</th> <th>Weapon/Armor</th> </tr><?php while($row = $db->fetch_row($select)) { ?><tr> <td><?php echo format($row['itmname']);?></td> <td><?php echo $row['itmdesc'] ? format($row['itmdesc']) : 'No description';?></td> <td><?php echo format($row['itmtypename']);?></td> <td><?php echo $row['itmbuyable'] ? ($row['itmbuyprice'] ? '$'.format($row['itmbuyprice']) : 'Free') : 'Can\'t be bought';?>/<?php echo $row['itmsellprice'] > 0 ? '$'.format($row['itmsellprice']) : 'Can\'t be sold';?></td> <td><?php echo format($row['weapon']),'/',format($row['armor']);?></td> </tr><?php } ?></table>  
  25. Not a bad idea, I've done something similar for my clients. It may not be as clean (visually), but using 1 query can also be ok <?php require_once __DIR__ . '/globals.php'; if(!function_exists('format')) { function format($str, $dec = 0) { // purely for my own laziness.. return is_numeric($str) ? number_format($str, $dec) : stripslashes(htmlspecialchars($str)); } } $select = $db->query('SELECT `itmname`, `itmdesc`, `itmbuyprice`, `itmsellprice`, `weapon`, `armor`, `itmtypename` FROM `items` LEFT JOIN `itemtypes` ON `items`.`itmtype` = `itemtypes`.`itmtypeid` ORDER BY `itmtype` ASC, `itmname` ASC'); ?><table class="table"> <tr> <th>Item</th> <th>Description</th> <th>Type</th> <th>Buy/Sell</th> <th>Weapon/Armor</th> </tr><?php while($row = $db->fetch_row($select)) { ?><tr> <td><?php echo format($row['itmname']);?></td> <td><?php echo $row['itmdesc'] ? format($row['itmdesc']) : 'No description';?></td> <td><?php echo format($row['itmtypename']);?></td> <td><?php echo $row['itmbuyable'] ? ($row['itmbuyprice'] ? '$'.format($row['itmbuyprice']) : 'Free') : 'Can\'t be bought';?>/<?php echo $row['itmsellprice'] > 0 ? '$'.format($row['itmsellprice']) : 'Can\'t be sold';?></td> <td><?php echo format($row['weapon']),'/',format($row['armor']);?></td> </tr><?php } ?></table> NOTE: This is untested and it ain't pretty either
×
×
  • Create New...