Jump to content

setTimer not working for good


Miika

Recommended Posts

I make autoWeather mod. But it not working for good.

My script is:

-- Copyright SuomiGTA -- 
-- Tekijä: Miika822 -- 
-- Scriptin jälleenmyyminen EHDOTTOMASTI KIELLETTY! -- 
  
-- Ilmoitukset -- 
function onStart() 
    outputChatBox("Miikan sää script v 1.0 on käynnistetty onnistuneesti.", source, 255, 0, 0) 
    setTimer ( changeWeatherSunny, 1000, 1 ) 
end 
addEventHandler("onResourceStart", getRootElement(), onStart) 
  
function onJoin() 
    outputChatBox("Sään tarjoaa Miikan sää scripti.") 
end 
addEventHandler("onPlayerJoin", getRootElement(), onJoin) 
  
-- Scripti alkaa kunnolla -- 
  
function changeWeatherSunny() 
    setWeather ( 1 ) 
    outputChatBox("Sää vaihdettiin aurinkoiseksi säämodin johdosta!") 
    setTimer ( changeWeatherRainy, 300000, 1 )   
end 
  
function changeWeatherRainy() 
    setWeather ( 8 ) 
    outputChatBox("Sää vaihdettiin myrskyksi säämodin johdosta!") 
    setTimer ( changeWeatherSandstrom, 300000, 1 )   
end 
  
function changeWeatherSandstrom() 
    setWeather ( 19 ) 
    outputChatBox("DARUDE SANDSTORM!  -Säämodi") 
    setTimer ( changeWeatherPink, 600000, 1 )    
end 
  
function changeWeatherPink() 
    setWeather ( 118 ) 
    outputChatBox("Pinkki taivas ja kristalli vesi!") 
    setTimer ( changeWeatherSunny, 300000, 1 ) 
end 
  

What is the problem?

Sorry my bad english... :)

Link to comment

In-game, typ the command: /debugscript 3 and you will see the answer. I guess a typos, otherwise put function 'onStart' under all other functions. (With it's event)

Also: As soon as any resource starts, your script is being started too. To avoid this, change 'getRootElement()' to 'getResourceRootElement()' in the event handler. (Only by event 'onResourceStart')

Link to comment

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...