TimedEvent

Status
Not open for further replies.

balu92

Moderator
Moderator
Jul 11, 2014
338
75
28
33
TimedEvents changed in pluton. From now on TimedEvent "Callback"s will always have a parameter and that's the timer itself. And I'm introducing the parallel timed events:
Python:
def On_PlayerConnected(self, player):
    myDict = Plugin.CreateDict()
    myDict["joined"] = player
    Plugin.CreateParallelTimer("delayedJoin", 5000, myDict).Start()

def delayedJoinCallback(self, timer):
    if timer.Args["joined"].Name == "Illuminati":
        timer.Args["joined"].Kick("for good")
        timer.Kill()
Parallel timed events can run simultaneously with the same name and with different data. You can put player in the dictionary or steamid, whatever you want. Plugin.CreateDict() will give you a Dictionary<string, object>, by default it's capacity is 10, you can call it with CreateDict(int capacity) if you have to.
If you want to get only one timer of all with the same name, for example if you want to kill the timers that ran ten times:
Python:
for timer in Plugin.GetParallelTimer("delayedJoin"):
    if timer.ElapsedCount == 10:
        Debug.Log("timer ran 10 times already")
        timer.Kill()
if you wish to kill all parallel timer with the same name:
Plugin.KillParrallelTimer("delayedJoin")

GetTimer("delayedJoin") won't give back timer if the timer was defined to be a parallel timer

KillTimer("delayedJoin") won't kill any of your parallel timer

KillTimers() will do that tho.

a ParallelTimer always needs a dictionary for the data
 
Last edited:
  • Useful
Reactions: DreTaX

PreFiX

New Member
Trusted Member
Member
Aug 8, 2014
14
1
3
so official Language of Fougerite is Python? Gosssh... It going to be pain in ass to convert all plugins without having any knowledge of language.
 

DreTaX

Probably knows the answer...
Administrator
Jun 29, 2014
4,065
4,486
113
At your house.
github.com

balu92

Moderator
Moderator
Jul 11, 2014
338
75
28
33
We will add js officialy as soon as we can add it in a form where you guys can work with it normaly. When you won't need to use duct tape, magic and some chemical X to get a simple for loop to work. ;)
 

xEnt

Retired Staff
Retired Staff
Sep 6, 2014
48
17
8
honestly its not hard at all to use the new JS, everything i done in my plugins so far is exactly the same, other than having an issue with a foreach loop instead i just used for, loop through the index's of the collection). no big deal
 

Skully

Plugin Developer
Plugin Developer
Sep 8, 2014
91
7
8
Something is failing when starting timer... Used:
Code:
Plugin.CreateTimer("delayedTimer", 10000, data).Start()
AND
Plugin.CreateParallelTimer("delayedTimer", 10000, data).Start()
What is wrong with Timers and I have the same problem with Web.GET and Web.POST
 

DreTaX

Probably knows the answer...
Administrator
Jun 29, 2014
4,065
4,486
113
At your house.
github.com
Something is failing when starting timer... Used:
Code:
Plugin.CreateTimer("delayedTimer", 10000, data).Start()
AND
Plugin.CreateParallelTimer("delayedTimer", 10000, data).Start()
What is wrong with Timers and I have the same problem with Web.GET and Web.POST
Same here. I want to check the error now. Do you have it?
 

Skully

Plugin Developer
Plugin Developer
Sep 8, 2014
91
7
8
I am looking to make auto drop plugin what calls server command event.run... But something is messing up and wont go to callback... Got it starting the timer, but now I am trying all ways what I can! Will reply if I will have the answer!

This is how it starts:
Python:
ini = self.DroperIniSettings()
time = int(ini.GetSetting("Settings", "EventEveryMin")) * 1000
Plugin.CreateTimer("delayedDrop", time).Start()
Debug.Log("Timer was started")
Now it shows message without failing but wont do callback
 

Skully

Plugin Developer
Plugin Developer
Sep 8, 2014
91
7
8
You maybe got any luck with callback? I really give up on this... tryed even with 1ms timer and got lagging server (remaking him self) but no callback executing!
 

balu92

Moderator
Moderator
Jul 11, 2014
338
75
28
33
I made several timer running simultaneously each with a random number between 2000 and 5000 in ms, like there was 8-10 running printing msg in Debug.Log() without any lag.
 

Skully

Plugin Developer
Plugin Developer
Sep 8, 2014
91
7
8
I made several timer running simultaneously each with a random number between 2000 and 5000 in ms, like there was 8-10 running printing msg in Debug.Log() without any lag.
I am not saying nothing about lag! I did it with 1ms... but my point is that I cant get it to do Callback... Maybe I need to import something? Maybe You can give some simple (maybe same Debug,Log() that does it) code?
 
Status
Not open for further replies.