Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
shobhit-pathak committed Feb 10, 2024
2 parents 8ec0927 + 60d8891 commit 475dda8
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 9 deletions.
62 changes: 59 additions & 3 deletions G5API.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ public class Get5Status
public required string PluginVersion { get; set; }

[JsonPropertyName("gamestate")]
public int GameState { get; set; }
public string GameState { get; set; }
}

public class G5WebAvailable
{
[JsonPropertyName("gamestate")]
public int GameState { get; init; }
public string GameState { get; init; }

[JsonPropertyName("available")]
public int Available { get; } = 1;
Expand All @@ -31,13 +31,69 @@ public partial class MatchZy
[ConsoleCommand("get5_status", "Returns get5 status")]
public void Get5StatusCommand(CCSPlayerController? player, CommandInfo command)
{
command.ReplyToCommand(JsonSerializer.Serialize(new Get5Status { PluginVersion = "0.15.0", GameState = 0 }));
// TODO: Add remaining Get5 status data as specified in https://splewis.github.io/get5/latest/commands/#get5_status
command.ReplyToCommand(JsonSerializer.Serialize(new Get5Status { PluginVersion = "0.15.0", GameState = getGet5Gamestate() }));
}

[ConsoleCommand("get5_web_available", "Returns get5 web available")]
public void Get5WebAvailable(CCSPlayerController? player, CommandInfo command)
{
command.ReplyToCommand(JsonSerializer.Serialize(new G5WebAvailable()));
}

private string getGet5Gamestate()
{
// Get state from MatchZy state phase data and map to get5 state
// Get5 states: pre_veto, veto, warmup, knife, waiting_for_knife_decision, going_live, live, pending_restore, post_game
// Please note, that Get5 have moved from integer based states to string based states, so the integer based states are not used.
//
// TODO: Missing "going_live" state, as this is not tracked. It has an event (GoingLiveEvent), but it is not read (only ever dispatched).
// Therefore, a "proxy" is used to determine if the match is going live (and no other state is "active")
string state = "none";

// The order of checks have been checked to work. Please be carefull if you change the order.
if (!isMatchSetup)
{
state = "none"; // If the match has not been set up, then the state is none
}
else if (isVeto)
{
state = "veto";
}
else if (isPreVeto)
{
state = "pre_veto";
}
else if (isKnifeRound)
{
state = "knife";
}
else if (isSideSelectionPhase)
{
state = "waiting_for_knife_decision";
}
else if (IsPostGamePhase())
{
state = "post_game";
}
else if (isMatchLive)
{
state = "live";
}
else if (isRoundRestoring)
{
state = "pending_restore";
}
else if (matchStarted)
{
state = "going_live";
}
else if (isWarmup)
{
state = "warmup";
}

return state;
}
}
}
12 changes: 6 additions & 6 deletions documentation/docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ There are two ways to create an admin for MatchZy; you can choose the most conve

Inside `csgo/cfg/MatchZy`, a file named `admins.json` should be present. If it is not there, it will be automatically created when the plugin is loaded. You can add Steam64 id of admins in that JSON file like mentioned in the below example:

```json
{
"76561198154367261": "",
"<another_steam_id>": ""
}
```
```json
{
"76561198154367261": "",
"<another_steam_id>": ""
}
```

### Configuring MatchZy Settings (ConVars)
Again, inside `csgo/cfg/MatchZy`, a file named `config.cfg` should be present. This file is executed whenever the plugin is loaded. If you make any changes in this file and want to reload the config, simply execute `exec MatchZy/config.cfg` command on the server.
Expand Down

0 comments on commit 475dda8

Please sign in to comment.