Jump to content

[LE] how to make script loop every minutes


Recommended Posts

Uhh... I can give you a quick example.

MiscObject property Gold001 auto
Bool property bKeepUpdating = TRUE auto
{ Set to false when ready to stop polling. }

Actor Player
Event OnInit()
    Player = Game.GetPlayer()
   
    ; 30min
    RegisterForSingleUpdate(1800.0)
EndEvent


Event OnUpdate()
    Player.AddItem(Gold001, 1)

    if bKeepUpdating == TRUE
        RegisterForSingleUpdate(1800.0)
    endif
EndEvent

UpdateGameTime is probably better, but I don't feel like calculating time differences for things like fast traveling, sleeping, waiting, etc.

Edited by Rasikko
Link to comment
Share on other sites

thanks, i will try it right away,

 

based your script the player will get a gold coin every 30 minutes,

but how to stop it?

something like : give player 1 gold coin every 10 second for 1 minutes

 

You'd add a counter and an if statement:

 

 

MiscObject property Gold001 auto
int Property iMaxAdd = 0 auto
Bool property bKeepUpdating = TRUE auto
{ Set to false when ready to stop polling. }
 
int iAddedCount = 0
Actor Player

Event OnInit()
    Player = Game.GetPlayer()
   
    ; 30min
    RegisterForSingleUpdate(1800.0)
EndEvent


Event OnUpdate()
    if iAddedCount < iMaxAdd && bKeepUpdating
        iAddedCount += 1
        Player.AddItem(Gold001, 1)
        RegisterForSingleUpdate(1800.0)
    else
        bKeepUpdating = false    
    endif

EndEvent

 

You'd then set the max count via property to be whatever you like. I defaulted it to zero so it fails safe and doesn't execute if you forget to set it.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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