Änderung Busfahrer/Pilot Bugs fix siehe Forenbeitrag
This commit is contained in:
38
ReallifeGamemode.Server/Util/PlayerTimer.cs
Normal file
38
ReallifeGamemode.Server/Util/PlayerTimer.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Timers;
|
||||
using GTANetworkAPI;
|
||||
|
||||
namespace ReallifeGamemode.Server.Util
|
||||
{
|
||||
public class PlayerTimer
|
||||
{
|
||||
private readonly Player player;
|
||||
private readonly Vehicle veh;
|
||||
private readonly Timer timer;
|
||||
|
||||
public delegate void PlayerTimerElapsed(Player player, Vehicle veh);
|
||||
public event PlayerTimerElapsed Elapsed;
|
||||
|
||||
public PlayerTimer(Player player, Vehicle veh = null, int milliseconds = 1000)
|
||||
{
|
||||
this.player = player;
|
||||
this.veh = veh;
|
||||
|
||||
this.timer = new Timer(milliseconds);
|
||||
this.timer.Elapsed += Timer_Elapsed;
|
||||
this.timer.Start();
|
||||
}
|
||||
|
||||
private void Timer_Elapsed(object sender, ElapsedEventArgs e)
|
||||
{
|
||||
Elapsed?.Invoke(player, veh);
|
||||
}
|
||||
|
||||
public void Stop()
|
||||
{
|
||||
this.timer.Stop();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user