Singletons
PlayerList
Injects the same PlayerList instance as the one available with the name of Players when extending the CitizenFX.Core.BaseScript class.
public class Main : BaseScript
{
private readonly PlayerList _players;
public Main()
{
// Obviously assigning it is pointless when you're creating your own resource, it's just an example
this._players = this.Players;
}
}Usage in an addon:
using CitizenFX.Core;
using FivePD.Server.API;
using FivePD.Server.Interfaces;
namespace MyAwesomeAddon;
public class MyAwesomeExtension : IExtension
{
private readonly PlayerList _players;
public MyAwesomeExtension(PlayerList players)
{
this._players = players;
}
public Task OnStarted()
{
return Task.FromResult(0);
}
public Task OnStopped()
{
return Task.FromResult(0);
}
}