change stuff with objects
This commit is contained in:
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Timers;
|
||||
using GTANetworkAPI;
|
||||
using ReallifeGamemode.Server.Inventory.Interfaces;
|
||||
|
||||
namespace ReallifeGamemode.Server.Util
|
||||
{
|
||||
@@ -10,9 +11,12 @@ namespace ReallifeGamemode.Server.Util
|
||||
{
|
||||
private readonly Player player;
|
||||
private readonly Vehicle veh;
|
||||
private readonly IUsableItem usableItem;
|
||||
private readonly Timer timer;
|
||||
public readonly DateTime startTime;
|
||||
|
||||
public delegate void PlayerTimerElapsed(Player player, Vehicle veh);
|
||||
|
||||
public event PlayerTimerElapsed Elapsed;
|
||||
|
||||
public PlayerTimer(Player player, Vehicle veh = null, int milliseconds = 1000)
|
||||
@@ -25,6 +29,17 @@ namespace ReallifeGamemode.Server.Util
|
||||
this.timer.Start();
|
||||
}
|
||||
|
||||
public PlayerTimer(Player player, IUsableItem usableItem, int milliseconds = 1000)
|
||||
{
|
||||
this.player = player;
|
||||
this.usableItem = usableItem;
|
||||
this.startTime = DateTime.Now;
|
||||
|
||||
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);
|
||||
|
||||
Reference in New Issue
Block a user