Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Adding Date to TE


Ricksan
 Share

Recommended Posts

HI all

I added Days, Months yaers, and Seasons to TE.
I made a ini file call time to save and load the time and date so that time dose not start over ever time the server starts up.
How off ten should I write the time and date to the ini file?
and were in the code is a good spot to put it, would it be in it's own sub?

This is what I have dine so far.

```
Private Sub Form_Load()
Dim fileName As String
fileName = App.Path & "\Time.ini"
Years = GetVar(fileName, "Time", "Year")
Months = GetVar(fileName, "Time", "Month")
Days = GetVar(fileName, "Time", "Day")
Hours = GetVar(fileName, "Time", "Hour")
Minutes = GetVar(fileName, "Time", "Min")
Seconds = GetVar(fileName, "Time", "Sec")
Gamespeed = GetVar(fileName, "Time", "Gamespeed")
'Hours = Rand(1, 24)
'Minutes = Rand(0, 59)
'Seconds = Rand(0, 59)
'Gamespeed = 1
Wierd = 0
End Sub

```
```
Private Sub Timer1_Timer()

Dim AMorPM As String
Dim TempSeconds As Integer
Dim PrintSeconds As String
Dim PrintSeconds2 As String
Dim PrintMinutes As String
Dim PrintMinutes2 As String
Dim PrintHours As Integer

Seconds = Seconds + Gamespeed

If Seconds > 59 Then
    Minutes = Minutes + 1
    Seconds = Seconds - 60
End If
If Minutes > 59 Then
    Hours = Hours + 1
    Minutes = 0
End If
If Hours > 24 Then
    Days = Days + 1
    Hours = 0
End If
If Days > 31 Then
    Months = Months + 1
    Days = 1
End If
If Months > 14 Then
    Years = Years + 1
    Months = 1
End If

If Hours > 12 Then
    AMorPM = "PM"
    PrintHours = Hours - 12
Else
    AMorPM = "AM"
    PrintHours = Hours
End If
If Months >= 1 And Months < 5 Then
    Seasons = Winter
End If
If Months >= 5 And Months < 8 Then
    Season = Spring
End If
If Months >= 8 And Months < 12 Then
    Season = Summer
End If
If Months >= 12 And Months < 15 Then
    Season = Fall
End If
If Hours = 24 Then
    AMorPM = "AM"
End If

If Hours = 1 Or Hours = 4 Or Hours = 8 Or Hours = 12 Or Hours = 16 Or Hours = 20 Or Hours = 23 Then
    Call PutVar(App.Path & "\Time.ini", "Time", "Min", Minutes)
    Call PutVar(App.Path & "\Time.ini", "Time", "Hour", Hours)
    Call PutVar(App.Path & "\Time.ini", "Time", "Day", Days)
    Call PutVar(App.Path & "\Time.ini", "Time", "Month", Months)
    Call PutVar(App.Path & "\Time.ini", "Time", "Year", Years)
    Call PutVar(App.Path & "\Time.ini", "Time", "Season", Seasons)
End If

TempSeconds = Seconds

If Seconds > 9 Then
    PrintSeconds = TempSeconds
Else
    PrintSeconds = "0" & Seconds
End If

If Seconds > 50 Then
    PrintSeconds2 = "0" & 60 - TempSeconds
Else
    PrintSeconds2 = 60 - TempSeconds
End If

If Minutes > 9 Then
    PrintMinutes = Minutes
Else
    PrintMinutes = "0" & Minutes
End If

If Minutes > 50 Then
    PrintMinutes2 = "0" & 60 - Minutes
Else
    PrintMinutes2 = 60 - Minutes
End If

Label8.Caption = "Current Time is " & PrintHours & ":" & PrintMinutes & ":" & PrintSeconds & " " & AMorPM

If Hours > 20 And GameTime = TIME_DAY Then
    GameTime = TIME_NIGHT
    Call SendTimeToAll
    End If
If Hours < 21 And Hours > 6 And GameTime = TIME_NIGHT Then
    GameTime = TIME_DAY
    Call SendTimeToAll
    End If
If Hours < 7 And GameTime = TIME_DAY Then
    GameTime = TIME_NIGHT
    Call SendTimeToAll
    End If

If Hours < 21 And Hours > 6 Then
    Label10.Caption = "Time until night:"
    Label11.Caption = 21 - Hours - 1 & ":" & PrintMinutes2 & ":" & PrintSeconds2
Else
    Label10.Caption = "Time until day:"
    If Hours < 7 Then
    Label11.Caption = 7 - Hours - 1 & ":" & PrintMinutes2 & ":" & PrintSeconds2
    Else
    Label11.Caption = 24 - Hours - 1 + 7 & ":" & PrintMinutes2 & ":" & PrintSeconds2
    End If
End If

If Hours > 11 Then
    GameClock = Hours - 12 & ":" & PrintMinutes & ":" & PrintSeconds & " " & AMorPM
Else
    GameClock = Hours & ":" & PrintMinutes & ":" & PrintSeconds & " " & AMorPM
End If

Call SendGameClockToAll

End Sub

```
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...