| 04-08-2006, 02:15 PM | #1 |
Anybody know what could be wrong with this code for gametime seconds? Its just setting the final string to "1" everytime, when it should become greater with every seconds. JASS:function GameTime takes nothing returns nothing local integer Seconds = GetStoredIntegerBJ("GameSeconds", "Main", udg_Game_Cache) local integer TenSeconds = GetStoredIntegerBJ("GameTenSeconds", "Main", udg_Game_Cache) local integer Minutes = GetStoredIntegerBJ("GameMinutes", "Main", udg_Game_Cache) local integer TenMinutes = GetStoredIntegerBJ("GameTenMinutes", "Main", udg_Game_Cache) local integer Hours = GetStoredIntegerBJ("GameHours", "Main", udg_Game_Cache) set Seconds = Seconds + 1 if(Seconds == 10) then set Seconds = 0 set TenSeconds = TenSeconds + 1 if(TenSeconds == 6) then set TenSeconds = 0 set Minutes = Minutes + 1 if(Minutes == 10) then set Minutes = 0 set TenMinutes = TenMinutes + 1 if(TenMinutes == 6) then set TenMinutes = 0 set Hours = Hours + 1 endif endif endif endif call StoreIntegerBJ( Seconds, "GameSeconds", "Main", udg_Game_Cache ) call StoreIntegerBJ( TenSeconds, "GameTenSeconds", "Main", udg_Game_Cache ) call StoreIntegerBJ( Minutes, "GameMinutes", "Main", udg_Game_Cache ) call StoreIntegerBJ( TenMinutes, "GameTenMinutes", "Main", udg_Game_Cache ) call StoreIntegerBJ( Hours, "GameHours", "Main", udg_Game_Cache ) set udg_Game_TimeString = I2S(Hours) + ":" + I2S(TenMinutes) + I2S(Minutes) + ":" + I2S(TenSeconds) + I2S(Seconds) if(Hours == 0) then set udg_Game_TimeString = I2S(TenMinutes) + I2S(Minutes) + ":" + I2S(TenSeconds) + I2S(Seconds) if(Hours == 0) and (TenMinutes == 0) then set udg_Game_TimeString = I2S(Minutes) + ":" + I2S(TenSeconds) + I2S(Seconds) if(Hours == 0) and (TenMinutes == 0) and (Minutes == 0) then set udg_Game_TimeString = I2S(TenSeconds) + I2S(Seconds) if(Hours == 0) and (TenMinutes == 0) and (Minutes == 0) and (TenSeconds == 0) then set udg_Game_TimeString = I2S(Seconds) endif endif endif endif endfunction Thx in advance |
| 04-08-2006, 05:01 PM | #2 |
You dont restore the seconds to the gamecache, thus making it 1 everytime cuz 0+1 stays 1 no matter what you do :). Btw, why dont you have seconds and tenseconds in 1 variable? and when it reaches 60 set mins +1 and seconds to 0. And btw, use JASS:GetStoredInteger(udg_Game_Cache, "Main", "GameSeconds") |
| 04-08-2006, 05:18 PM | #3 |
Well, i do restore the integers to the gamecache before the last set of If's, i wrote: JASS:call StoreIntegerBJ( Seconds, "GameSeconds", "Main", udg_Game_Cache ) call StoreIntegerBJ( TenSeconds, "GameTenSeconds", "Main", udg_Game_Cache ) call StoreIntegerBJ( Minutes, "GameMinutes", "Main", udg_Game_Cache ) call StoreIntegerBJ( TenMinutes, "GameTenMinutes", "Main", udg_Game_Cache ) call StoreIntegerBJ( Hours, "GameHours", "Main", udg_Game_Cache ) I use 10seconds and seconds because using them in 1 integer sometimes gets buggy, dunno why though. Just happens Anyway, il try what you said. |
| 04-08-2006, 05:51 PM | #4 |
Iv got it working now, the problem was i dident declare the global gamecache i had, lol stupiest mistake ever, thx anyways |
| 04-08-2006, 05:57 PM | #5 |
lol I actually only read half your code last time :$ thought it ended but there was a scrollbar I failed to notice. Good you got it working :) |
