KashBFD Posted February 6, 2012 Author Share Posted February 6, 2012 Replied in PM Quote Link to comment Share on other sites More sharing options...
KashBFD Posted February 7, 2012 Author Share Posted February 7, 2012 Anybody help? Quote Link to comment Share on other sites More sharing options...
sniko Posted February 7, 2012 Share Posted February 7, 2012 1. Use code tags, encase code in [*php][*/php] ~(remove *) 2. "$crap" In my view, should be initiated first as 0 (Referring to $crap != 0) and then deleted from memory once it's played its role in the program (unset()) 3. Try having the following IF statement somewhere... <?php $time = time(); $get = mysql_query("SELECT `bullets` FROM `site_stats` WHERE `bullets`< $time"); if(mysql_num_rows($get)) { //Continue with code, add bullets } Other than step 3 I can't see why it needs a user request to initiate the update. Hmmm, on the other hand, I see you have something like that. (Psst. Select what you want from the table, tend not to use the wildcard *) I guess the only question to ask now, is, are the records updating? Quote Link to comment Share on other sites More sharing options...
KashBFD Posted February 7, 2012 Author Share Posted February 7, 2012 Thanks a lot bro, im going to try it now ... thanks. Quote Link to comment Share on other sites More sharing options...
Phagocytosis Posted February 7, 2012 Share Posted February 7, 2012 I got a question for whom it may concern. I have been trying my best to get the errors and bugs out of my current set of scripts. However one of many that i cant get my head around is my Bullet Factory script. See it works ok as in holds its stock, produces bullets, money works.. but atm it is set on 2000 bullets every hour, and when the time is up for some reason it wont update the bf's stock until someone is on the bf php page. I later managed to figure the function that is making the update of the bullets possible is ; $new_time=time()+3600; $up=mysql_fetch_object(mysql_query("SELECT * FROM site_stats WHERE id='1'")); $a=mysql_query("SELECT * FROM bf WHERE location='$fetch->location'"); while($b=mysql_fetch_object($a)){ $user=mysql_fetch_object(mysql_query("SELECT * FROM users WHERE username='$b->owner'")); $minus=$user->money - 1000; if ($user->money <= $minus){ mysql_query("UPDATE bf SET owner='0', producing='0' WHERE id='$b->id'"); $crap=1; } if ($up->bullets < time() && $b->producing == "Yes" && $crap != "1"){ mysql_query("UPDATE bf SET stock=stock+2000"); mysql_query("UPDATE site_stats SET bullets='$new_time' WHERE id='1'"); mysql_query("UPDATE users SET money='$minus' WHERE username='$b->owner'"); } } . I tryed to copy and paste it in my functions.php page that is linked to most my scripts but nothing, so atm i have it placed in the footer.php... but still the issue remains someone has to be playing in order for the bf to refill. I will paste the whole scripts below , is there any suggestions..? I also managed to have a look in php my admin at the db to see wether it updates the times and it does but says 2006. Also im not experianced enough to notice the error.. FUNCTIONS; <?php session_start(); include_once"includes/db_connect.php"; include_once"includes/functions.php"; logincheck(); $username=$_SESSION['username']; $query=mysql_query("SELECT * FROM users WHERE username='$username'"); $fetch=mysql_fetch_object($query); $query_bf=mysql_query("SELECT * FROM bf WHERE location='$fetch->location'"); $fetch_bf=mysql_fetch_object($query_bf); if (strtolower($fetch_bf->owner) == (strtolower($fetch->username))){ require_once"bulletCP.php"; exit(); } $new_time=time()+3600; $up=mysql_fetch_object(mysql_query("SELECT * FROM site_stats WHERE id='1'")); $a=mysql_query("SELECT * FROM bf WHERE location='$fetch->location'"); while($b=mysql_fetch_object($a)){ $user=mysql_fetch_object(mysql_query("SELECT * FROM users WHERE username='$b->owner'")); $minus=$user->money - 1000; if ($user->money <= $minus){ mysql_query("UPDATE bf SET owner='0', producing='0' WHERE id='$b->id'"); $crap=1; } if ($up->bullets < time() && $b->producing == "Yes" && $crap != "1"){ mysql_query("UPDATE bf SET stock=stock+2000"); mysql_query("UPDATE site_stats SET bullets='$new_time' WHERE id='1'"); mysql_query("UPDATE users SET money='$minus' WHERE username='$b->owner'"); } } if (strip_tags($_POST['check']) && (strip_tags($_POST['amount']))){ $amount=intval(strip_tags($_POST['amount'])); if ($amount == 0 || !$amount || ereg('[^0-9]',$amount)){ print "You cant buy that amount."; }elseif ($amount != 0 || $amount || !ereg('[^0-9]',$amount)){ $costs = $fetch_bf->price * $amount; if ($costs > $fetch->money){ echo "You do not have enough money"; } elseif ($costs <= $fetch->money){ $nmoney=$fetch->money - $costs; if ($fetch_bf->stock < $amount){ echo "Not that many bullets in the store."; } elseif ($amount <= $fetch_bf->stock){ $nbullets=$fetch->bullets + $amount; $nstock = $fetch_bf->stock - $amount; ///IF THERE IS NOOOOO OWNER if ($fetch_bf->owner == "0"){ mysql_query("UPDATE users SET bullets='$nbullets', money='$nmoney' WHERE username='$username'"); mysql_query("UPDATE bf SET stock='$nstock', profit='$costs' WHERE location='$fetch->location'"); echo "Bullets successfully bought."; ////IF THERE IS A OWNER }elseif ($fetch_bf->owner != "0"){ $fetch_owner=mysql_fetch_object(mysql_query("SELECT * FROM users WHERE username='$fetch_bf->owner'")); $new_owner=$fetch_owner->money + $costs; mysql_query("UPDATE users SET bullets='$nbullets', money='$nmoney' WHERE username='$username'"); mysql_query("UPDATE users SET money='$new_owner' WHERE username='$fetch_bf->owner'"); mysql_query("UPDATE bf SET stock='$nstock', profit='$costs' WHERE location='$fetch->location'"); echo "Bullets Successfully Bought."; } }} } } ?> and script displaying <?php if ($fetch_bf->producing == "Yes"){ echo "".maketime($up->bullets)." until Bullets next Stock."; }else{ echo "Not Producing"; } ?> I was browsing the forum and came across this post.. I must say that this code is exactly the same one as the one in the Way of The Mafia script (the functions page), that script also updates bullet factories every hour and uses the same code to do so. Of course, there is nothing wrong with using code from other scripts if allowed, was just curious.. Quote Link to comment Share on other sites More sharing options...
KashBFD Posted February 7, 2012 Author Share Posted February 7, 2012 Lmao thats prob because they have a copy of my scripts that were stolen and sold on many times over for a period of 3-4 years.. however thanks for replying because ill try placing in the functions now. Your also stating that the whole of the quoted .php script is placed in the functions? Quote Link to comment Share on other sites More sharing options...
Phagocytosis Posted February 7, 2012 Share Posted February 7, 2012 Lmao thats prob because they have a copy of my scripts that were stolen and sold on many times over for a period of 3-4 years.. however thanks for replying because ill try placing in the functions now. Your also stating that the whole of the quoted .php script is placed in the functions? I think I've come across your script in the past but don't remember that code being in the functions file. Anyway, strange. Good luck with your game. :) Quote Link to comment Share on other sites More sharing options...
KashBFD Posted February 7, 2012 Author Share Posted February 7, 2012 Yeah its most likely you will off, however no worrys like i said you dont know till you ask so thanks for replying. http://www.thm.x10.mx have a look only on free server atm, and still going through stages.. patience is a virtue.. taking my sweet time this time. Quote Link to comment Share on other sites More sharing options...
KashBFD Posted February 7, 2012 Author Share Posted February 7, 2012 Still no louck on bf situation.. anyone else with suggestions???????? Its killing me... Quote Link to comment Share on other sites More sharing options...
Uridium Posted February 7, 2012 Share Posted February 7, 2012 Still no louck on bf situation.. anyone else with suggestions???????? Its killing me... whats killing you ? Quote Link to comment Share on other sites More sharing options...
KashBFD Posted February 8, 2012 Author Share Posted February 8, 2012 Not being able to find out why this is occuring.. !!!! LOL.. Should i put a screenshot of the db up , maybe that will help someone point me in the right direction. Quote Link to comment Share on other sites More sharing options...
KashBFD Posted February 8, 2012 Author Share Posted February 8, 2012 Here are 3 screenshots of the db first is the bf then the structure to the bf, however the red circle's are to show where i tried to enter the date in a attempt to fix it, but nothing. the site_stats entry.. Someone shed some light please.. Quote Link to comment Share on other sites More sharing options...
Uridium Posted February 8, 2012 Share Posted February 8, 2012 still working out what BF means Quote Link to comment Share on other sites More sharing options...
KashBFD Posted February 8, 2012 Author Share Posted February 8, 2012 Its a .php script in the game, Bullet Factory, it produces bullets every certain time, and the players can buy bullets from there, also own them. Every thing else works fine they even produce bulelts, show a time but when the time is up a user is required to view the bf page in order for the stock to update.. i jus checked the db an the bullets in site_stats is updated .. please help. Quote Link to comment Share on other sites More sharing options...
Damagedcity.com Posted February 8, 2012 Share Posted February 8, 2012 I could help u a bit .. pm me Quote Link to comment Share on other sites More sharing options...
sniko Posted February 9, 2012 Share Posted February 9, 2012 Store the time in a INT(11) and just store the timestamp IE. "1328819347" 1 Quote Link to comment Share on other sites More sharing options...
KashBFD Posted February 19, 2012 Author Share Posted February 19, 2012 Right sorry for long reply i just been getting other things fixed and trying to still do it myself with out a cron but i think its the only solution. Anyway there is a in game bullet factory that produces bullets for example every hour.. every hour 2000 bullets will be added to its stock amount.. anyway this all works fine from what i can see .. however when the time is up for the next restock a players needs to go onto the bf.php page in the game for it to update the timers and the stock.. i managed to make a file that if i just type into the domain will make this happen and it is below .... I tryed making it into a cron from the cpanel.. my command was.. /home/thmx10mx/public_html/cron.php i dont even know if thats right... <?php session_start(); include_once"includes/db_connect.php"; include_once"includes/functions.php"; $username=$_SESSION['username']; $query=mysql_query("SELECT * FROM users WHERE username='$username'"); $fetch=mysql_fetch_object($query); $query_bf=mysql_query("SELECT * FROM bf WHERE location='$fetch->location'"); $fetch_bf=mysql_fetch_object($query_bf); $new_time=time()+150; $up=mysql_fetch_object(mysql_query("SELECT * FROM bf")); $a=mysql_query("SELECT * FROM bf WHERE location='$fetch->location'"); while($b=mysql_fetch_object($a)){ $user=mysql_fetch_object(mysql_query("SELECT * FROM users WHERE username='$b->owner'")); $minus=$user->money - 1000; if ($user->money <= $minus){ mysql_query("UPDATE bf SET owner='0', producing='0' WHERE id='$b->id'"); $crap=1; } if ($fetch_bf->producing == "Yes" && $up->next_restock < time() && $crap != "1"){ mysql_query("UPDATE bf SET stock=stock+2000"); mysql_query("UPDATE bf SET next_restock='$new_time' WHERE id='1'"); mysql_query("UPDATE users SET money='$minus' WHERE username='$b->owner'"); } } ?> I really hope someone can help me with some guidance.. its been on the agenda for nearly 2 weeks.. and is really bugging me.. thanks. Quote Link to comment Share on other sites More sharing options...
bluegman991 Posted February 19, 2012 Share Posted February 19, 2012 (edited) [noparse]<?php session_start(); include_once "includes/db_connect.php"; include_once "includes/functions.php"; $username = $_SESSION['username']; $query = mysql_query("SELECT * FROM users WHERE username='$username'"); $fetch = mysql_fetch_object($query); $query_bf = mysql_query("SELECT * FROM bf WHERE location='$fetch->location'"); $fetch_bf = mysql_fetch_object($query_bf); $new_time = time() + 150; $up = mysql_fetch_object(mysql_query("SELECT * FROM bf")); $a = mysql_query("SELECT * FROM bf WHERE location='$fetch->location'"); while ($b = mysql_fetch_object($a)) { $user = mysql_fetch_object(mysql_query("SELECT * FROM users WHERE username='$b->owner'")); $minus = $user->money - 1000; if ($user->money <= $minus) { mysql_query("UPDATE bf SET owner='0', producing='0' WHERE id='$b->id'"); $crap = 1; } if ($fetch_bf->producing == "Yes" && $up->next_restock < time() && $crap != "1") { mysql_query("UPDATE bf SET stock=stock+2000"); mysql_query("UPDATE bf SET next_restock='$new_time' WHERE id='1'"); mysql_query("UPDATE users SET money='$minus' WHERE username='$b->owner'"); } } ?>[/noparse] Code was killing my eyes. Had to run it through a beautifier. Now that I can read it. It looks like this is what is updating everything. So, it seems to me, that all you need to do is have the page called, by a cron handler. I haven't used or setup a cron using cpanel in years so i forgot which order you have to input things. So get me a print screen of your cron page, and I can help you with that. Or i'm sure someone else will help you if they know. If you have already set it up and it's not working, then... For the cron url try using "curl path/to/file" instead of just "path/to/file". Also make sure you have the numbers in the right places for the cron setup form, because you could have it set for something like 5 hours or 5 days instead of 5 minutes. Edited February 19, 2012 by bluegman991 Quote Link to comment Share on other sites More sharing options...
sniko Posted February 19, 2012 Share Posted February 19, 2012 Alternatively, store the production setting in the database, and do something along the following; $get = $db->query("SELECT <primary_key> FROM <table> WHERE <production_column>='Yes'"); while($r = $db->fetch_row($get)) { $db->query("UPDATE <table> SET <bullet_column>=<bullet_column>+<value> WHERE <primary_key>={$r['<primary_key>']}"); } unset($r); mysql_free_result($get); Quote Link to comment Share on other sites More sharing options...
KashBFD Posted March 12, 2012 Author Share Posted March 12, 2012 The game is currently online and has been over to a temp host with a new domain in order for some beta testing with users and players that can help. You dont have to visit but it would be nice for some advice for now.. i am working on a story line.. just getting the game flow.. big improvements coming very very soon, may even be a diff engine.. http://www.TriggerHappy-Mafia.com Thanks Kash P.S all the testers or players that are playing until the big reset will be given something in return to show the token of appreciation. e.g. Props, Bullets, Points, Cash if they decide to continue to play... Quote Link to comment Share on other sites More sharing options...
SilverStar Posted March 12, 2012 Share Posted March 12, 2012 You're game is vulnerable to MySQL injection, just letting you know.. Quote Link to comment Share on other sites More sharing options...
lucky3809 Posted March 12, 2012 Share Posted March 12, 2012 scroll bars ruins the game...IMO. Quote Link to comment Share on other sites More sharing options...
KashBFD Posted March 12, 2012 Author Share Posted March 12, 2012 Thanks for commenting, but please like i said there big improvements coming along, just need feedback from players.. on input.. or coders input 2. Thanks. Quote Link to comment Share on other sites More sharing options...
Linton Posted April 20, 2012 Share Posted April 20, 2012 There probably better than YOUR latest back-ups :L awncer to that his game would and will sh1t over any game you cold ever make mate so SUSHHHHHH Quote Link to comment Share on other sites More sharing options...
mixmaster Posted April 20, 2012 Share Posted April 20, 2012 awncer to that his game would and will sh1t over any game you cold ever make mate so SUSHHHHHH Urm ok :p and it's shhhhh not sushhhhh Quote Link to comment Share on other sites More sharing options...
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.