1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. GTA Network forum is now in archive mode.

Basic Scheduler

Discussion in 'Tools' started by fauconjona, Mar 7, 2017.

  1. fauconjona

    fauconjona Member

    Messages:
    6
    Likes Received:
    3
    Joined:
    Feb 18, 2017
    Hello everyone,

    I'm here to share my first tool :=) . It's a simple scheduler to execute specific tasks at specific times.

    The resource is available on my git hub: https://github.com/fauconjona/Scheduler

    With the scheduler you can:
    • Send a global message
    • Start/Stop/Restart a resource
    • Trigger a custom event
    • Execute a process (like "reboot.cmd")
    It's very simple to use:

    1. put the "scheduler" resource in your resource folder
    2. put "schedules.xml" into your GTANetwork-server root folder
    3. Configure the "schedules.xml":
    HTML:
    <schedules>
      <job type="message" value="This message was sent by Scheduler!" time="12:00" /><!-- Send a global message-->
      <job type="process" value="reboot.cmd" time="13:00:00" /><!-- Execute a process-->
      <job type="resource" value="speedometer" time="14:00" action="start" /><!-- Start a ressource-->
      <job type="resource" value="speedometer" time="14:15" action="stop" /><!-- Stop a ressource-->
      <job type="resource" value="speedometer" time="14:30" action="restart" /><!-- Restart a ressource-->
      <job type="event" value="myEvent" time="15:00" /><!-- Trigger a custom event-->
    </schedules>
    • type : Simply the type of the task
    • value : The value used by the task
    • time : Time to execute the task
    • action (optional): only for "resource" type, specify the action to do with the resource
    For custom event, add this in your C# file:

    Code:
    API.exported.scheduler.OnScheduleEvent += new ExportedEvent(Scheduler_OnScheduleEvent);
    
    //...
    
    private void Scheduler_OnScheduleEvent(object[] args)
    {
        API.consoleOutput("Event :" + (string)args[0]);
    }
    To finish, add
    in "settings.xml"

    I hope you like it,

    If you have any suggestion or problem, tell me on this thread.

    fauconjona
     
    Last edited: Mar 7, 2017
    Koex and MissMelissa like this.

Share This Page