-
-
Notifications
You must be signed in to change notification settings - Fork 6
Shared API
Nick edited this page May 18, 2025
·
5 revisions
GameModeManager provides a shared API for other plugins to manage game modes. Add a reference to GameModeManager.Shared to your project to get started!
Important
You must have GameModeManager.Shared
installed to csgo/addons/counterstrikesharp/shared/
.
GameModeAPI
// Included libraries
using GameModeManager.Shared.Models;
// Declare namespace
namespace GameModeManager.Shared;
// Define interfaces
public interface IGameState
{
List<IMap> Maps { get; }
List<IMode> Modes { get; }
IMap CurrentMap { get; }
IMode WarmupMode { get; }
IMode CurrentMode { get; }
List<ISetting> Settings { get; }
List<IMapGroup> MapGroups { get; }
bool WarmupScheduled { get; }
}
public interface IGameModeControl
{
void TriggerRotation();
void ChangeMode(IMode mode);
void ChangeMap(IMap map, int delay);
}
public interface IWarmupControl
{
bool ScheduleWarmup(IMode mode);
}
public interface IGameModeApi
{
IGameState State { get; }
IGameModeControl Control { get; }
IWarmupControl Warmup { get; }
}
RTVApi
// Included libraries
using GameModeManager.Shared.Models;
// Declare namespace
namespace GameModeManager.Shared;
// Define interface
public interface IRTVState
{
IMap? NextMap { get; }
int Duration { get; }
bool Enabled { get; }
IMode? NextMode { get; }
bool EndOfMapVote { get; }
bool IncludeExtend { get; }
int KillsBeforeEnd { get; }
int RoundsBeforeEnd { get; }
bool EofVoteHappened { get; }
int SecondsBeforeEnd { get; }
bool NominationEnabled { get; }
bool EofVoteHappening { get; }
bool ChangeImmediately { get; }
int MaxNominationWinners { get; }
}
public interface IRTVControl
{
void Enable();
void Disable();
IRTVControl SetDuration(int duration);
IRTVControl SetRoundsBeforeEnd(int rounds);
IRTVControl SetKillsBeforeEnd(int kills);
IRTVControl SetSecondsBeforeEnd(int seconds);
IRTVControl SetEndOfMapVote(bool endOfMapVote);
IRTVControl SetIncludeExtend(bool includeExtend);
IRTVControl SetChangeImmediately(bool changeImmediately);
}
public interface IRTVNomination
{
bool NominationEnabled { get; }
int MaxNominationWinners { get; }
IRTVNomination SetNominationEnabled(bool nominationEnabled);
IRTVNomination SetMaxNominationWinners(int maxNominationWinners);
}
public interface IRTVApi
{
IRTVState State { get; }
IRTVControl Control { get; }
IRTVNomination Nomination { get; }
}
TimeLimitApi
// Declare namespace
namespace GameModeManager.Shared;
// Define interface
public interface ITimeLimitState
{
int MaxWins { get; }
float TimeLimit { get; }
bool Custom { get; }
bool Enabled { get; }
bool Scheduled { get; }
decimal TimePlayed { get; }
int RemainingWins { get; }
bool UnlimitedTime { get; }
bool UnlimitedRounds { get; }
decimal TimeRemaining { get; }
}
public interface ITimeLimitControl
{
void Enforce();
void Disable();
void CustomLimit(int time);
}
public interface ITimeLimitMessaging
{
string TimeLeftMessage();
}
public interface ITimeLimitApi
{
ITimeLimitState State { get; }
ITimeLimitControl Control { get; }
ITimeLimitMessaging Messaging { get; }
}
Project Reference
<ItemGroup>
<Reference Include="GameModeManager.Shared">
<HintPath>..\GameModeManagger.Shared\GameModeManagger.Shared.dll</HintPath>
</Reference>
</ItemGroup>
Plugin.cs
// Included libraries
using GameModeManager.Shared;
using CounterStrikeSharp.API.Core.Capabilities;
// Declare namespace
namespace Plugin;
public class Plugin : BasePlugin
{
public PluginCapability<IRTVApi> RTVApi { get; } = new("rtv:api");
public PluginCapability<IGameModeApi> GameModeApi { get; } = new("game_mode:api");
public PluginCapability<ITimeLimitApi> TimeLimitApi { get; } = new("time_limit:api");
List<IMap> Maps = GameModeApi.Get().State.Maps;
List<IMode> Modes = GameModeApi.Get().State.Modes;
private IMap Map = Maps.FirstOrDefault(m => m.Name.Equals("de_dust2", StringComparison.OrdinalIgnoreCase));
private IMode Mode = Modes.FirstOrDefault().FirstOrDefault(m => m.Name.Equals("Scoutzknivez", StringComparison.OrdinalIgnoreCase));
GameModeApi.Get().Control.ChangeMap(Map);
GameModeApi.Get().Control.ChangeMode(Mode);
int Seconds = 120;
RTVApi.Get().Control.SetDuration(Seconds);
TimeLimitApi.Get().Control.Enforce();
TimeLimitApi.Get().Control.CustomLimit (Seconds);
TimeLimitApi.Get().Control.Disable();
private string Message = TimeLimitApi.Get().Messaging.TimeLimitMessage();
}