09-03-2007, 12:25 AM
Dificulty: 1/5(just C & P, do a little reading and understanding)
Yes, this is an actual time system, not using the player's system clocks to take time, but making the server have an independent timer for itself. To give it a personal timing system.
Everyone knows MS comes with a cheap Day/Night system(no gfx for it, 60 second days) And I'm sure some people have added Day/Night(Still no actual time system, just a timer that triggers day and night)
Well here, this just goes in the GameAI sub server-side.
Don't forget to add in all the noted Variables! TimeHours, TimeDay and TimeMinute. A Byte is good enough for each of them. Publicly declare them somewhere. AMPM, declare it as a String, Publicly as you did the others.
All it does is keep track of time, change day/night when appropriate(according to Pokemon) and change the day when it's appropriate. That doesn't actually display it, though I'm sure it isn't that hard...
What is does is keep time on a 24 hr clock, and also changes day systems too. I don't care how you handle the day system, or if you take it out completely. It's just, for Pokemon, time is important, expecially time of day, and day of the week(GSC, anyone? Lapris on Fridays? FTW!) Anyways, there's one more peice of code you might want.
Server crashes? No problem. It restores time from the last known minute value, hour value, day value, and time of day value. This isn't necesary if you want your server to start up with 0 default value for all those values.
This goes in Sub InitServer.
This is what I did for my day system. Instead of storing them as text, I stored them as numbers(faster handling) and had a function match each number to a day. Here it is(not the actual one I use)
Not too hard, is it? Now go on, implement this for yourselves!
Yes, this is an actual time system, not using the player's system clocks to take time, but making the server have an independent timer for itself. To give it a personal timing system.
Everyone knows MS comes with a cheap Day/Night system(no gfx for it, 60 second days) And I'm sure some people have added Day/Night(Still no actual time system, just a timer that triggers day and night)
Well here, this just goes in the GameAI sub server-side.
Code:
' time sequencing
If TimeSeconds >= 60 Then
TimeMinutes = TimeMinutes + 1
TimeSeconds = 0
Call PutVar(FileName, "Time", "Minute", Trim$(TimeMinutes))
End If
If TimeMinutes >= 60 Then
TimeHours = TimeHours + 1
TimeMinutes = 0
Call PutVar(FileName, "Time", "Minute", Trim$(TimeMinutes))
Call PutVar(FileName, "Time", "Hour", Trim$(TimeHours))
End If
If TimeHours = 6 And GameTime = TIME_DAY And AMPM = "PM" Then
GameTime = TIME_NIGHT
PutVar FileName, "Time", "Hour", Trim$(TimeHours)
PutVar FileName, "Time", "ToD", Trim$(GameTime)
For i = 1 To MAX_PLAYERS
If IsPlaying(i) = True Then
PlayerMsg i, "It is now night.", Blue
End If
Next i
End If
If TimeHours = 4 And GameTime = TIME_NIGHT And AMPM = "AM" Then
GameTime = TIME_DAY
For i = 1 To MAX_PLAYERS
If IsPlaying(i) = True Then
PlayerMsg i, "It is now day.", Yellow
End If
Next i
PutVar FileName, "Time", "Day", Trim$(TimeDay)
PutVar FileName, "Time", "Hour", Trim$(TimeHours)
PutVar FileName, "Time", "ToD", Trim$(GameTime)
End If
If TimeHours >= 12 And AMPM = "AM" And GameTime = TIME_DAY Then
AMPM = "PM"
PutVar FileName, "Time", "Hour", Trim$(TimeHours)
PutVar FileName, "Time", "Day", Trim$(TimeDay)
PutVar FileName, "Time", "Hour", Trim$(TimeHours)
PutVar FileName, "Time", "AM/PM", Trim$(AMPM)
If GameTime TIME_DAY Then
GameTime = TIME_DAY
End If
End If
If TimeHours >= 12 And AMPM = "PM" And GameTime = TIME_NIGHT Then
TimeDay = TimeDay + 1
AMPM = "AM"
PutVar FileName, "Time", "Day", Trim$(TimeDay)
PutVar FileName, "Time", "ToD", Trim$(GameTime)
PutVar FileName, "Time", "Hour", Trim$(TimeHours)
PutVar FileName, "Time", "AM/PM", Trim$(AMPM)
If GameTime TIME_NIGHT Then
GameTime = TIME_NIGHT
End If
End If
If TimeHours >= 13 Then TimeHours = 1
If TimeDay >= 8 Then TimeDay = 1
All it does is keep track of time, change day/night when appropriate(according to Pokemon) and change the day when it's appropriate. That doesn't actually display it, though I'm sure it isn't that hard...
What is does is keep time on a 24 hr clock, and also changes day systems too. I don't care how you handle the day system, or if you take it out completely. It's just, for Pokemon, time is important, expecially time of day, and day of the week(GSC, anyone? Lapris on Fridays? FTW!) Anyways, there's one more peice of code you might want.
Code:
' Init atmosphere
GameTime = GetVar(FileName, "Time", "ToD")
TimeSeconds = 0
TimeMinutes = STR(GetVar(FileName, "Time", "Minute"))
TimeHours = STR(GetVar(FileName, "Time", "Hour"))
TimeDay = STR(GetVar(FileName, "Time", "Day"))
AMPM = GetVar(FileName, "Time", "AM/PM")
Server crashes? No problem. It restores time from the last known minute value, hour value, day value, and time of day value. This isn't necesary if you want your server to start up with 0 default value for all those values.
This goes in Sub InitServer.
This is what I did for my day system. Instead of storing them as text, I stored them as numbers(faster handling) and had a function match each number to a day. Here it is(not the actual one I use)
Code:
Public Function TimeDay(Byval Day As Byte) As String
Select Case Day
Case 1
TimeDay = "Sunday"
Case 2
TimeDay = "Monday"
Case 3
TimeDay = "Tuesday"
Case 4
TimeDay = "Wenesday"
Case 5
TimeDay = "Thursday"
Case 6
TimeDay = "Friday"
Case 7
TimeDay = "Saturday"
End Select
Not too hard, is it? Now go on, implement this for yourselves!