(Difference between revisions)
Return to current revision
-
Creates a timer.
-
-
== Declaration ==
<code cpp>
VAULTSCRIPT vaultmp::Timer (*CreateTimer)(vaultmp::TimerFunc, vaultmp::Interval);
-
+
[h="2"] Declaration [/h]
[highlight=cpp]
VAULTSCRIPT VAULTSPACE Timer (*VAULTAPI(CreateTimer))(VAULTSPACE RawFunction(), VAULTSPACE Interval) _CPP(noexcept);
[/highlight]
[highlight=c]
-
native CreateTimer(const func{}, interval);
-
-
</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()
-
+
[/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()
-
{
// Timer function
-
+
return static_cast<Result>(0);
-
}
-
-
void VAULTSCRIPT exec()
-
+
Void VAULTSCRIPT exec() noexcept
-
{
-
-
CreateTimer(&MyTimer, 5000);
-
+
CreateTimer(MyTimer, static_cast<Interval>(5000));
-
}
-
-
</code>
== Usage example (PAWN) ==
<code c>
-
+
[/highlight]
[h="2"] Usage example (PAWN) [/h]
[highlight=c]
-
forward MyTimer();
-
-
-
public MyTimer()
{
// Timer function
-
+
return 0;
-
}
-
-
-
main()
{
CreateTimer("MyTimer", 5000);
}
-
-
</code>
-
+
[/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]