danp Posted August 16, 2009 Share Posted August 16, 2009 Alrighty, I'm trying to make a script for a game I'm helping with... the script should be able decrease the number in a rain (rains are when players have a chance to find special items) by 1 in the database every hour in a cron job, and display the remaining number of hours left in the chat (also in the database).. RainDay *MUST* equal 1 for the rain to take place, and RainHours needs to be between 1 to 24 for it to be correct...my script kind of works, except it usually sets the RainDay to 0 before the hours are down to 0, and it doesn't correctly display the number of hours left in chat, just shows a blank space as in "There are hours left in this rain!" etc... Any tips or tricks I should be aware of? I appreciate any and all suggestions. Below is the code I currently use. <?php include ("connect.php"); $Query = "SELECT * FROM `SpecialEvent`"; $Query2=mysql_query($Query) or die("Can't find what you're looking for. Try again."); $Special=mysql_fetch_array($Query2); if ($Special[RainDay]==0) {exit;} if ($Special[RainDayHours]==0) {exit;} if ($Special[RainDayHours] >= 1){ mysql_query("UPDATE SpecialEvent SET RainDayHours=RainDayHours-'1'")or die(mysql_error()); $Hours = mysql_query("SELECT 'RainDayHours' FROM 'SpecialEvent'"); mysql_query("insert into chat (chat) value('<font style=\"color: #00FFFF\">There are $Hours hours left in this rain!</font>')");}; $Hours = mysql_query("SELECT 'RainDayHours' FROM 'SpecialEvent'"); if ($Hours = 0){mysql_query("UPDATE SpecialEvent SET RainDay = '0'"); mysql_query("insert into chat (chat) value('<font style=\"color: #00FFFF\">The rain has ended..</font>')"); }exit; ?> I'm a nub, I know Link to comment https://forums.phpfreaks.com/topic/170571-logic-problem/ Share on other sites More sharing options...
danp Posted August 17, 2009 Author Share Posted August 17, 2009 Just noticed this was in the regex part of the forums. If a mod could help me relocate this to the PHP general help section I would appreciate it Link to comment https://forums.phpfreaks.com/topic/170571-logic-problem/#findComment-899697 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.