Jump to content
MakeWebGames

KyleMassacre

Members
  • Posts

    2,921
  • Joined

  • Last visited

  • Days Won

    48

Everything posted by KyleMassacre

  1. Nice work but I noticed in your functions that you are calling the global $h??? I know you said you have been programming for a short time and this module/alteration seems to show you have been doing it longer than 2 months. But let me give you an easy way to remember what globals you need to call when needing globals: For some reason in PHP when you create a method or a function sometimes they require "globals". What global does is, it will basically look for that variable that is somewhere outside your function or method. It could be inside the same script or inside an include. In your case, you are calling the $h object which instantiates the "header" class so you can use the endpage() method, which is basically like a clean kill of your HTML or like a footer if that makes sense. But your are actually not using the h object inside your functions so the global is not required. And future reference: Common globals would be $db, $h, and $userid. The only time you need to call those as globals is inside functions or methods, and if you are actually going to use them within the function. I hope this makes sense and if not sorry for confusing you more and feel free to ask and I'll try to make it clearer to you
  2. [ATTACH=CONFIG]1407[/ATTACH] Just to to show I'm not going insane haha
  3. Awesome plugin [MENTION=50433]ColdBlooded[/MENTION]
  4. Just so people are aware or maybe it's my phone but there is in fact an underscore "_" in the $end_date var or "end date" as it looks to me Never Mind The line it's sitting in for the bbcode parser is just a tad bit thin height wise :o
  5. Ohh sorry about that. That was just my netbeans reformatting :p
  6. No matter what you think of the default mysql*_ class you should still use it just to be consistent with the engine. Some people dont know how to create class objects, methods, etc. The more "talented" people can rip your stuff apart and use their own way of db communications. So for the people that like to keep everything consistent I went ahead and converted it for ya: <?php include "globals.php"; // // BANKING SETTINGS // // percesntage increase $investment_rate = 0.3; // duration in dats $investment_duration = 7; // select any investments in the bank $investment_query = sprintf('SELECT * FROM `investment_bank` WHERE `user_id` = \'%u\';', $userid); $investment = $db->query($investment_query); $has_investment = $db->num_rows($investment); /* * Handle withdrawing funds */ if (isset($_GET['withdraw'])) { if ($has_investment) { $i = $db->fetch_row($investment); $now = new DateTime(); $d = date_create($i['finished']); if ($d < $now) { // user has funds ready to withdraw $delete_sql = sprintf( "DELETE from `investment_bank` WHERE `user_id` = %u;", $userid ); if ($db->query($delete_sql)) { // deleted the reccord, now add the funds back to the user $update_user_sql = sprintf( 'UPDATE `users` SET `money` = `money` + %u WHERE `userid` = %u', $i['money'], $userid ); if ($db->query($update_user_sql)) { $messages->success('You have taken you money out the bank, you may now re-invest it!'); } else { $messages->error('There was an error, please contact an admin'); } } else { $messages->error('There was an error, please contact an admin'); } } else { $messages->error('You cannot access your funds yet'); } } else { $messages->error('You don\'t have any funds invested'); } header('Location: investmentbank.php'); } /* * Handle the Form POST */ if (isset($_POST['investment'])) { if ($has_investment) { $messages->error('You already have an investment and cannot add another!'); } else { // form has been submitted $investment_ammount = (int) $_POST['investment']; if ($investment_ammount > $ir['money']) { // player tried to invest more than they have $messages->error('You cannot invest more money than you have'); } else { // create some dates $date = new DateTime('now'); $end_date = new DateInterval(sprintf('P ', $investment_duration)); // calculated the correct end date $date->add($end_date); // construct the insert query $new_investment_sql = sprintf( "INSERT INTO `investment_bank` VALUES (NULL, %u, %u, '%s');", $userid, $investment_ammount + ($investment_ammount * $investment_rate), $date->format('Y-m-d H:i:s') ); if ($result = $db->query($new_investment_sql)) { // log message // deduct the user's money $db->query(sprintf("UPDATE `users` SET `money` = %u WHERE `userid` = %u", $investment_ammount, $userid)); $messages->success('You invested $' . number_format($investment_ammount) . ' in the investment bank and it will be available to collect in ' . $investment_duration . ' weeks'); } else { $messages->error('You encountered an error, please try again'); } } } // send player to the blank investment page header('Location: investmentbank.php'); } ?> <h2>Investment Banking</h2> <?php if ($has_investment): ?> <?php $i = $db->fetch_row($investment); $now = new DateTime(); $d = date_create($i['finished']); ?> <?php if ($now > $d): ?> <p>You have <?php echo money_formatter($i['money']); ?> and your investment has finished.</p> <p><a class="button" href="?withdraw">> withdraw funds</a></p> <?php else: ?> <p>You have $<?php echo money_formatter($i['money']); ?> invested until <?php echo date_format($d, 'Y-m-d'); ?>, come back then and you can withdraw the funds.</p> <?php endif; ?> <?php else: ?> <p>You do not have an investment yet.</p> <p>You can deposit money for <?php echo $investment_duration; ?> weeks and gain <?php echo $investment_rate * 100; ?>% extra</p> <hr /> <p>How much do you wish to invest?</p> <form action="" method="POST"> <input id="investment-ammount" type="number" name="investment" placeholder="$100,000" min="0" max="<?php echo $ir['money']; ?>" step="100" /> <button>Invest</button> </form> <?php endif; ?> <style type="text/css"> #investment-ammount { width: 10em; } .messages { list-style: none; } .messages li { background: #f5f5f5; border: 1px solid #ccc; margin: 1em 3em 1em 0; padding: 1em; } .messages .message-error { color: #900; } .messages .message-success { color: #090; } </style> <?php $h->endpage(); ?>   Or for the people that really want to use this the way it is: Add to globals.php/globals_nonauth.php $mysqli = new mysqli($_CONFIG['hostname'], $_CONFIG['username'], $_CONFIG['password'], $_CONFIG['database']);
  7. You could try and possibly incorporate the way the crime formula is (which now that I'm typing this wrux pretty much said this). It this way you can make use of all your stats and maybe even add some more stats to use
  8. I dont let it get to me. Yeah it sucks but oh well
  9. I would be curious to see what you mean exactly??? from what I can see with this is that it's similar to what you have done with your MCC API that you created with your `canAccess()` method (sorry if it's the incorrect name). Something like this: public function canAccess($col) { global $db; $sql = "select {$col} from <insert table name here> where userid = {$this->id}"; $r = $db->query($sql); if($db->fetch_row($r) == "yes") { return true; } else { return false; } }
  10. You are a kind feller sniko for these releases. It shows true community dedication to release mods like this for free especially seeing first hand the amount of care you do put into your work. --Off Topic-- @Dom: is that sarcasm I sense? I can't really tell
  11. This is pretty similar to the stafflog_add() function (I think it's called) so you can in reality use that instead and change it so that the user_level != 2 or userid != 1 and add it to the staff logs at the top of the file. It may be a bit less annoying that way so that your event log isn't filled up with stuff of staff members just loading a page. Or you can create another function and just call that function on only important staff pages just incase they think they are sneaky but just remember to escape/sanitize your $_SERVER vars because people can add some nasty stuff to steal info from you when you view your event log/staff log , etc.
  12. You can use the stats in your crimes to add a variety. You don't only need to use will for crimes, some crimes people commit in real life require some kind of brains so IQ would probably be good to use for a crime like that. Make a play on your story with crimes and use the stats
  13. I can agree with Dom here. It needs to be regulated much like tobacco and alcohol because I don't care what people say, it does affect your reflexes so getting in a car stoned off your arse would be bad. @Peter: Yeah your right about the cost of the drug tests but people who generally smoke weed would have a greater chance of failing the test which means no assistance at all so I'm willing to have my taxes pay for people to take a drug test to get assistance. This would "weed" *I make a funny?* out a lot of people getting on average (just for fun) we'll say $1,000/mo. whereas a drug test probably costs $200-300 dollars from a clinic? @The Coder: Yes it can. Though the feeling of being stoned has a different feeling compared to drunk it has the same effects and hinders your judgement and decision making abilities. Granted actually smoking weed doesn't do anything that bad to your body driving while under the influence can ;)
  14. What's the line error?
  15. I myself am pro marihuana. I don't smoke it or use it in any way. Here in the states this is a big deal right now whether or not to legalize it both in state and federal. And I agree with !Angel about it affecting different people differently and have seen both sides of the spectrum with it. I have seen people just become so dependent on it and can't function correctly without it (oxymoron?). And also I have seen people who smoke weed day in and day out but it doesn't control their lives. I have a buddy who went all throughout High School stoned, got into a prestigious Uni, and graduated with honors with a degree in English, all while stoned. The only issue I see is for the negatively affected people that tend to wanna get government assistance because that comes from my tax dollars and hopefully we pass the law that says in order to get assistance you must take drug tests. But that's about it.
  16. Yep. Alain handed it over to me
  17. I haven't really had the time to do any updates or adding to it at all.
  18. You would be surprised. I had someone ripoff a template from me before and even hotlinked my CSS and image files.... Lazy Bugger
  19. @Cordell: You do realize that most of us here are developers and not people that are looking for a "New Game" to play so there is really no reason to advertise other peoples games here hence the name Make Web Games
  20. Probably because the file doesn't exist where it is trying to find it from. But since this is Redux there is a file called globals_nonauth.php, that's the file I think you should be requiring
  21. Try: echo '<a href="'.gen_url("viewuser",false).'?u='.$f['user'].'">'.getUsername($f['user']).'</a> <i>['.date('H:i', $f['time']).']</i> - '.htmlentities(stripslashes($f['message'])).' im on my phone getting my haircut so hopefully that's right
  22. Alright thanks for the tips. I haven't actually even done anything in the .NET world since this application haha but I'll keep all this in mind
  23. I don't see why it wouldn't. Try it out and let us know, if you have problems with it I'm sure we can figure it out
  24. Am I reading this right? Do players only get to rate once a day?
  25. ewww crons? Maybe i should fork this and see what i can do ay?
×
×
  • Create New...