change stuff with objects

This commit is contained in:
2021-04-13 17:57:33 +02:00
parent 2a82f72f14
commit 61da1edcb9
15 changed files with 200 additions and 108 deletions

View File

@@ -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);