This site has been archived and made available for preservation purposes. No edits can be made.

CreateTimer

(Difference between revisions)
Return to current revision
Current Revision 08-14-2012, 08:44 PM
  1.  
    Creates a timer.
  2. -

    == Declaration ==
    <code cpp>
    VAULTSCRIPT vaultmp::Timer (*CreateTimer)(vaultmp::TimerFunc, vaultmp::Interval);
  3. +
    [h="2"] Declaration [/h]
    [highlight=cpp]
    VAULTSCRIPT VAULTSPACE Timer (*VAULTAPI(CreateTimer))(VAULTSPACE RawFunction(), VAULTSPACE Interval) _CPP(noexcept);
    [/highlight]
    [highlight=c]
  4.  
    native CreateTimer(const func{}, interval);
  5. -
    </code>
    == Parameters ==

    '''[[TimerFunc|vaultmp::TimerFunc]]''' (C++ only) - the function of the timer

    '''func''' (PAWN only) - the name of the timer's function

    '''[[Interval|vaultmp::Interval]]''' - the timer interval in milliseconds

    == Return value ==

    Returns a [[Timer|vaultmp::Timer]] referring to the newly created timer.

    == Usage example (C++) ==

    <code cpp>
    void MyTimer()
  6. +
    [/highlight]
    [h="2"] Parameters [/h]
    [b][wiki="Function"]Function[/wiki][/b] - the function of the timer
    [b][wiki="Interval"]Interval[/wiki][/b] - the timer interval in milliseconds
    [h="2"] Return value [/h]
    Returns a [wiki="Timer"]Timer[/wiki] referring to the newly created timer.
    [h="2"] Usage example (C++) [/h]
    [highlight=cpp]
    Result VAULTSCRIPT MyTimer()
  7.  
    {
    // Timer function
  8. +
    return static_cast<Result>(0);
  9.  
    }
  10. -

    void VAULTSCRIPT exec()
  11. +
    Void VAULTSCRIPT exec() noexcept
  12.  
    {
  13. -
    CreateTimer(&MyTimer, 5000);
  14. +
    CreateTimer(MyTimer, static_cast<Interval>(5000));
  15.  
    }
  16. -
    </code>

    == Usage example (PAWN) ==

    <code c>
  17. +
    [/highlight]
    [h="2"] Usage example (PAWN) [/h]
    [highlight=c]
  18.  
    forward MyTimer();
  19. -

  20.  
    public MyTimer()
    {
    // Timer function
  21. +
    return 0;
  22.  
    }
  23. -

  24.  
    main()
    {
    CreateTimer("MyTimer", 5000);
    }
  25. -
    </code>
  26. +
    [/highlight]
    [h="2"] Related pages [/h]
    [list][*][wiki]CreateTimerEx[/wiki]
    [*][wiki]KillTimer[/wiki]
    [/LIST]
    [category]VaultMP interface[/category]
    [category]Scripting functions[/category]
    [category]Misc functions[/category]