nyjatt Posted April 17, 2011 Share Posted April 17, 2011 Hi I want to know how can I make it so that yu get 1 brave each minute no 1 every 5 minutes. And another question while I'm at it Ok well I want to add crimes that run under a time limit so if I make a section for gta: have 4 options there on what crime I can do ... choose 1 and commit the crime. If it pass or fails I have to wait x seconds to do it again and. Their is a ticker showing. I kind of know how to code the crime but the thing is how will I be able to add this to the game that's more of the question then how to code it. So to brief all that up how can I add a crime with a time ticker and how to reduce brave from 1 brave ea 5 mins to 1 ea minute. Quote Link to comment Share on other sites More sharing options...
Dayo Posted April 17, 2011 Share Posted April 17, 2011 add the code that is in the 5 min cron into the 1 min cron (but reduce the values from 5 to 1) dont understand what you mean by the 2nd bit ? :/ Quote Link to comment Share on other sites More sharing options...
nyjatt Posted April 17, 2011 Author Share Posted April 17, 2011 Thanks for the brave part im gonna try it out when I go on my computer. For the second part I mean like I want to add more categories for crime. (Not from the admin panel) like I want to add crimes that run on time then on brave. So yu have to wait like 30 seconds before you can do the crime again. Thanks in ahead Quote Link to comment Share on other sites More sharing options...
nyjatt Posted April 17, 2011 Author Share Posted April 17, 2011 Thanks for the brave part im gonna try it out when I go on my computer. For the second part I mean like I want to add more categories for crime. (Not from the admin panel) like I want to add crimes that run on time then on brave. So yu have to wait like 30 seconds before you can do the crime again. Thanks in ahead Quote Link to comment Share on other sites More sharing options...
bineye Posted April 17, 2011 Share Posted April 17, 2011 If you want a "time ticker", you'll need to code that in js or ajax. also for blocking the crimes for 30 secs, use a timestamp. Add time since last crime + 30 secs. Quote Link to comment Share on other sites More sharing options...
nyjatt Posted April 17, 2011 Author Share Posted April 17, 2011 ok so how would i add to the crimes to the game cause i cant figure that out and this is the code i have for the crimes is this well formatted and is it compatiable? <?php if ($_POST['Commit']){ $radiobutton=$_POST['radiobutton']; if ($radiobutton == "1"){ $crime_chance = rand(1,10); $crimetime1 = 10; $Crime_exp = rand(1,10); $Crime_money =rand(100,500); $timewait1=time()+ $crimetime1; $sql2="SELECT * from crimetimes WHERE name='$name'"; $result2=mysql_query($sql2); while($rows2=mysql_fetch_array($result2)){ // Start looping table row $timeleft1= $rows2['crime1']; $available1= $rows2['crime1a']; $last1 = $timeleft1 - time(); if ($available1 == 1) { echo "You need to wait be fore you can do this crime"; }elseif ($crime_chance == 2){ echo "You fail HAHAHAHA"; $result = mysql_query("UPDATE crimetimes SET crime1a='1', crime1='$timewait1' WHERE name='$name'") or die(mysql_error()); }else{ $result = mysql_query("UPDATE crimetimes SET crime1a='1', crime1='$timewait1' WHERE name='$name'") or die(mysql_error()); $result = mysql_query("UPDATE users SET exp=exp+'$Crime_exp', money=money+'$Crime_money' WHERE name='$name'") or die(mysql_error()); echo "You Stole from a child and received $$Crime_money"; } } } } $sql2="SELECT * from crimetimes WHERE name='$name'"; $result2=mysql_query($sql2); while($rows2=mysql_fetch_array($result2)){ // Start looping table row $timeleft1= $rows2['crime1']; $timeleft2= $rows2['crime2']; $timeleft3= $rows2['crime3']; $timeleft4= $rows2['crime4']; $timeleft5= $rows2['crime5']; $last1 = $timeleft1 - time(); $last2 = $timeleft2 - time(); $last3 = $timeleft3 - time(); $last4 = $timeleft4 - time(); $last5 = $timeleft5 - time(); } if($last1 <= 0){ $result = mysql_query("UPDATE crimetimes SET crime1a='0', crime1='' WHERE name='$name'") or die(mysql_error()); } if($last2 <= 0){ $result = mysql_query("UPDATE crimetimes SET crime2a='0', crime2='' WHERE name='$name'") or die(mysql_error()); } if($last3 <= 0){ $result = mysql_query("UPDATE crimetimes SET crime3a='0', crime3='' WHERE name='$name'") or die(mysql_error()); } if($last4 <= 0){ $result = mysql_query("UPDATE crimetimes SET crime4a='0', crime4='' WHERE name='$name'") or die(mysql_error()); } if($last5 <= 0){ $result = mysql_query("UPDATE crimetimes SET crime5a='0', crime5='' WHERE name='$name'") or die(mysql_error()); } ?> Quote Link to comment Share on other sites More sharing options...
sniko Posted April 17, 2011 Share Posted April 17, 2011 You may want to think about the server. With a lot of queries running every minute, your provider may suspend you as it puts strain on the server. -sniko Quote Link to comment Share on other sites More sharing options...
nyjatt Posted April 17, 2011 Author Share Posted April 17, 2011 ok ill look into that but how will i put this code into mccodes v2? like how will i make it work? i dont know how to explain it very well sorry. how can i make it compatible? Quote Link to comment Share on other sites More sharing options...
lucky3809 Posted April 17, 2011 Share Posted April 17, 2011 (edited) use this for your 1 minute crons... http://makewebgames.io/showthread.php/32642-any-version-Removal-of-1-minute-crons How i do those tricky time things is add a table call it TIME add ID,cTIME... Then when the person executes a crime have a query INSERT the userid and time into that table... Then use an if statement like ... if ($r['cTIME'] ==0){ //crime stuff }else { echo ' Sorry time is not up yet.'; } I then add the query to update that time in the 1 minute cron... Edited April 17, 2011 by lucky3809 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.