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

Timed Event script. [Solved]


cheatking
 Share

Recommended Posts

Can someone tell me why this isn't working please?
```
Sub TimedEvent(Hours, Minutes, Seconds)
    Dim MAPWEATHER
    Dim Weather
    If Minutes = 30 Then
        If Seconds = 0 Then
            Weather = Rand(1, 3)
            MAPWEATHER = 1
            Do While MAPWEATHER < 15
                Call SetWeather(MAPWEATHER, Weather, 10)
                MAPWEATHER + 1
            Loop
            Call PlayerMsg(Index, "Testing Weather", WHITE)
        End If
    End If
End Sub
```
Link to comment
Share on other sites

I am not keen on setting vars to 0.
1 minute has 60 seconds, but… are they 0 - 59 or 1 - 60
You can try figuring out if 0 or 1 is the starting second but the easiest is to simply use a bit higer value.

If Seconds = 5 Then

Second thing you could test:
below: Call SetWeather(MAPWEATHER, Weather, 10)
you can add: Call PlayerMsg(Index, "DEBUG: Weather should have changed to " & Weather  &  " on map: " & MAPWEATHER, WHITE)

this way you should read 15 time that the weather changed on the maps (and to what value).
Link to comment
Share on other sites

Ok this is the script now.
```
Sub TimedEvent(Hours, Minutes, Seconds)
Dim MAPWEATHER
Dim Weather
Dim Index
If Minutes = 30 Then
If Seconds = 5 Then
Weather = Rand(1, 3)
MAPWEATHER = 1
Do While MAPWEATHER < 15
Call SetWeather(MAPWEATHER, Weather, 10)
MAPWEATHER = MAPWEATHER + 1
Loop
Call PlayerMsg(Index, "DEBUG: Weather should have changed on map: " & MAPWEATHER, WHITE)
End If
End If
End Sub
```
I get a type missmatch now.
Link to comment
Share on other sites

In the serverfile, frmServer holds a routine called Private Sub Timer1_Timer() that triggers the clock and the "TimedEvent".

Try This:
In the serverwindow
tab: ControlPanel

Set time to
Houres: -doesnt matter-
Minutes: 29
Seconds: 0

Gamespeed: 1

Scripting ON

When the time reaches x:30:05 it should trigger the script.
Link to comment
Share on other sites

To see if the sub is working at all your could try the following:

right below:
    Sub TimedEvent(Hours, Minutes, Seconds)

add the following code:
    Dim Bugtracker
    Bugtracker = "H:" & Hours & " M:" & Minutes & " S:" & Seconds
    Call PlayerMsg(Index, "DEBUG: " & bugtracker , WHITE)

It should give you actual time based on the variables you need for your 'If … Then' statements.
Link to comment
Share on other sites

Lol!
It probably has multiple 'ticks' within the second. You can add an "allow" var. Like this:

Dim AllowRun
AllowRun = 1          '1: Yes,  0: No

If Seconds = 5 Then
        If AllowRun = 1 Then
              … execute code ....
              AllowRun = 0        'so the next time within this second is may not run
        End If
End If
If Seconds = 6 Then
        AllowRun = 1                'set the trigger to yes for the next run
end If
Link to comment
Share on other sites

```
    Dim Wth
    Dim Done
    If Minutes = 30 Then
        If Seconds = 30 Then
            Wth = Int(Rnd * 3)
            If Done = 0 Then
                Call SendData("weather" & SEP_CHAR & Wth & END_CHAR)
                Done = 1
            End If
            If Seconds = 31 Then
                Done = 0
            End If
        End If
    End If
```Am i cursed? Why don't it work?
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...