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

CreateTimerEx

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

    == Declaration ==
    <code cpp>
    VAULTSCRIPT vaultmp::Timer (*CreateTimerEx)(vaultmp::Function, vaultmp::Interval, std::string, ...);
  3. +
    [h="2"] Declaration [/h]
    [highlight=cpp]
    VAULTSCRIPT VAULTSPACE Timer (*VAULTAPI(CreateTimerEx))(VAULTSPACE RawFunction(), VAULTSPACE Interval, VAULTSPACE cRawString, ...) _CPP(noexcept);
    [/highlight]
    [highlight=c]
  4.  
    native CreateTimerEx(const func{}, interval, const def{}, {Fixed,Float,_}:...);
  5. -
    </code>
    == Parameters ==

    '''[[Function|vaultmp::Function]]''' (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

    '''def''' - the parameter list of the function. This is a string containing a sequence of:
    *i - Integer (4 byte)
    *l - Long integer (8 byte)
    *f - Floating-point (8 byte)
    *s - String (const char*)

    '''...''' - the arguments. Must match the previously defined definition.

    == Return value ==

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

    == Usage example (C++) ==

    <code cpp>
    Result VAULTSCRIPT MyTimer(unsigned int a, unsigned int b, const char* c)
  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
    [b][wiki]cRawString[/wiki][/b] - the parameter list of the function. This is a string containing a sequence of:
    [list][*]i - Integer (4 byte)
    [*]l - Long integer (8 byte)
    [*]f - Floating-point (8 byte)
    [*]p - Pointer (4 byte)
    [*]s - String (const char*)[/LIST]
    [b]...[/b] - the arguments. Must match the previously defined definition.
    [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(int a, int b, const char* c)
  7.  
    {
    // Timer function
  8. +
    return static_cast<Result>(0);
  9.  
    }
  10. -

    void VAULTSCRIPT exec()
  11. +
    Void VAULTSCRIPT exec() noexcept
  12.  
    {
  13. -
    CreateTimerEx(reinterpret_cast<Function>(&MyTimer), 5000, "iis", 1, 2, "www.vaultmp.com");
  14. +
    // C++ template version (type-safe, deduces type string)
    CreateTimerEx(MyTimer, static_cast<Interval>(5000), 1, 2, "www.vaultmp.com");
  15.  
    }
  16. -
    </code>

    == Usage example (PAWN) ==

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

  20.  
    public MyTimer(a, b, const c{})
    {
    // Timer function
  21. +
    return 0;
  22.  
    }
  23. -

  24.  
    main()
    {
    CreateTimerEx("MyTimer", 5000, "iis", 1, 2, "www.vaultmp.com");
    }
  25. -
    </code>

    == Related pages ==

    *[[CreateTimer]]
    *[[KillTimer]]

    [[Category:VaultMP interface]]
    [[Category:Scripting functions]]
    [[Category:Misc functions]]
  26. +
    [/highlight]
    [h="2"] Related pages [/h]
    [list][*][wiki]CreateTimer[/wiki]
    [*][wiki]KillTimer[/wiki]
    [/LIST]
    [category]VaultMP interface[/category]
    [category]Scripting functions[/category]
    [category]Misc functions[/category]