[C#] Custom Timer - Server & Client 2.1

   (3 reviews)

About This File

With this script you can easily create custom timer.
The file is fully commented and should be easy to understand.

The file in Shared is required - and then use either the file in Server or in Client depending on where you are using it.

You have to use the constructor to create the timer.

Examples:

Examples: 

// Yes, the method can be private //
private void testTimerFunc(Client player, string text)
{
    NAPI.Chat.SendChatMessageToPlayer(player, "[TIMER] " + text);
}

void testTimerFunc()
{
    NAPI.Chat.SendChatMessageToAll("[TIMER2] Hello");
}

[Command("ttimer")]
public void timerTesting(Client player)
{
    // Lamda for parameter //
    new Timer(() => testTimerFunc(player, "hi"), 1000, 1);
    // Normal without parameters //
    new Timer(testTimerFunc, 1000, 1);
    // Without existing method //
    var timer = new Timer(() => { NAPI.Chat.SendChatMessageToPlayer(player, "[TIMER3] Bonus is da best"); }, 1000, 0);
    // Kill the timer //
    timer.Kill();
}

 


What's New in Version 2.0   See changelog

Released

Added shared Timer for clientside & serverside C#.

You need to use the code TimerInit.cs in clientside and/or serverside to initialize and run the timer - else it won't work.
 

  • Like 4
  • Mask 1



User Feedback

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest

hubba

   1 of 1 member found this review helpful 1 / 1 member

very nice file, 

  • Like 1

Share this review


Link to review
Kozanoglu

   1 of 2 members found this review helpful 1 / 2 members

I like it. It looks like MTA method.

  • Like 1
  • Confused 1

Share this review


Link to review
ragempdev

   1 of 2 members found this review helpful 1 / 2 members

++rep

  • Like 1

Share this review


Link to review