cheatking Posted November 20, 2008 Author Share Posted November 20, 2008 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 IfEnd Sub``` Link to comment Share on other sites More sharing options...
RetroX Posted November 20, 2008 Share Posted November 20, 2008 I am not keen on setting vars to 0.1 minute has 60 seconds, but… are they 0 - 59 or 1 - 60You 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 ThenSecond 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 More sharing options...
cheatking Posted November 20, 2008 Author Share Posted November 20, 2008 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 IfEnd Sub```I get a type missmatch now. Link to comment Share on other sites More sharing options...
RetroX Posted November 20, 2008 Share Posted November 20, 2008 In the serverfile, frmServer holds a routine called Private Sub Timer1_Timer() that triggers the clock and the "TimedEvent".Try This:In the serverwindowtab: ControlPanelSet time toHoures: -doesnt matter-Minutes: 29Seconds: 0Gamespeed: 1Scripting ONWhen the time reaches x:30:05 it should trigger the script. Link to comment Share on other sites More sharing options...
cheatking Posted November 20, 2008 Author Share Posted November 20, 2008 Yea thats what I do to test it. It doesn't work. Link to comment Share on other sites More sharing options...
RetroX Posted November 20, 2008 Share Posted November 20, 2008 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 More sharing options...
cheatking Posted November 20, 2008 Author Share Posted November 20, 2008 I decided to hard code it. It works now :) Link to comment Share on other sites More sharing options...
RetroX Posted November 20, 2008 Share Posted November 20, 2008 Thats another sollution :cheesy:still wondering what the problem could be in the script :huh: Link to comment Share on other sites More sharing options...
cheatking Posted November 20, 2008 Author Share Posted November 20, 2008 Hmm… Now a different problem... It triggers a dosen times. Link to comment Share on other sites More sharing options...
RetroX Posted November 20, 2008 Share Posted November 20, 2008 Lol!It probably has multiple 'ticks' within the second. You can add an "allow" var. Like this:Dim AllowRunAllowRun = 1 '1: Yes, 0: NoIf Seconds = 5 Then If AllowRun = 1 Then … execute code .... AllowRun = 0 'so the next time within this second is may not run End IfEnd IfIf Seconds = 6 Then AllowRun = 1 'set the trigger to yes for the next runend If Link to comment Share on other sites More sharing options...
cheatking Posted November 20, 2008 Author Share Posted November 20, 2008 ``` 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 More sharing options...
RetroX Posted November 20, 2008 Share Posted November 20, 2008 It should. The only thing i can think of is the declaration of the vars. Mixup in Strings and Integers. To test you could try this:If Val(Minutes) = 30 ThenorIf Minutes = "30" Then_same for houres and seconds_ Link to comment Share on other sites More sharing options...
cheatking Posted November 20, 2008 Author Share Posted November 20, 2008 It works better in the server lol. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now