Skip to content

Commit

Permalink
Include console messages in Get5_OnPlayerSay
Browse files Browse the repository at this point in the history
  • Loading branch information
nickdnk committed Mar 1, 2023
1 parent b778e5c commit 339d628
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 22 deletions.
8 changes: 4 additions & 4 deletions documentation/docs/event_schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1033,7 +1033,7 @@ components:
minimum: 0
description: |
The in-game user ID of the player. This uniquely identifies the player within a server and is
auto-incremented for each connecting player. 0 for GOTV/Console but >0 for all players or bots. If the same
auto-incremented for each connecting player. 0 for Console but >0 for all players, bots or GOTV. If the same
player reconnects, they will be given a new ID. `steamid` uniquely identifies the player outside the server.
example: 4
steamid:
Expand All @@ -1042,14 +1042,14 @@ components:
description: |
The SteamID64 of the player. `GetSteamId()` and `SetSteamId()`
in SourceMod. This will be `BOT-%d` if the player is a bot, where `%d` is the user ID (`user_id`).
The string will be empty for Console and GOTV (although we *should* never see this in practice).
The string will be empty for Console and GOTV.
side:
$ref: "#/components/schemas/Get5Side"
name:
type: string
description: |
The in-game name of the player. If the player is a bot, this will be "BOT Gary" etc. `GetName()` and
`SetName()` in SourceMod.
The in-game name of the player. If the player is a bot, this will be "BOT Gary" etc. If console, this value
is `Console` and if GOTV, this value is `GOTV`. `GetName()` and `SetName()` in SourceMod.
example: s1mple
is_bot:
type: boolean
Expand Down
24 changes: 9 additions & 15 deletions scripting/get5.sp
Original file line number Diff line number Diff line change
Expand Up @@ -770,29 +770,23 @@ public void OnClientPostAdminCheck(int client) {
}

public Action OnClientSayCommand(int client, const char[] command, const char[] sArgs) {
if (g_GameState == Get5State_Veto && g_MuteAllChatDuringMapSelectionCvar.BoolValue && StrEqual(command, "say")) {
if (client != g_VetoCaptains[Get5Team_1] && client != g_VetoCaptains[Get5Team_2]) {
if (client > 0 && g_GameState == Get5State_Veto && g_MuteAllChatDuringMapSelectionCvar.BoolValue &&
StrEqual(command, "say") && client != g_VetoCaptains[Get5Team_1] && client != g_VetoCaptains[Get5Team_2]) {
Get5_Message(client, "%t", "MapSelectionTeamChatOnly");
return Plugin_Stop;
}
}
return Plugin_Continue;
}

public void OnClientSayCommand_Post(int client, const char[] command, const char[] sArgs) {
if (g_GameState != Get5State_None && (StrEqual(command, "say") || StrEqual(command, "say_team"))) {
if (IsValidClient(client)) {
Get5PlayerSayEvent event = new Get5PlayerSayEvent(g_MatchID, g_MapNumber, g_RoundNumber, GetRoundTime(),
GetPlayerObject(client), command, sArgs);

LogDebug("Calling Get5_OnPlayerSay()");

Call_StartForward(g_OnPlayerSay);
Call_PushCell(event);
Call_Finish();

EventLogger_LogAndDeleteEvent(event);
}
Get5PlayerSayEvent event = new Get5PlayerSayEvent(g_MatchID, g_MapNumber, g_RoundNumber, GetRoundTime(),
GetPlayerObject(client), command, sArgs);
LogDebug("Calling Get5_OnPlayerSay()");
Call_StartForward(g_OnPlayerSay);
Call_PushCell(event);
Call_Finish();
EventLogger_LogAndDeleteEvent(event);
}
CheckForChatAlias(client, sArgs);
}
Expand Down
6 changes: 3 additions & 3 deletions scripting/get5/stats.sp
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,10 @@ Get5Player GetPlayerObject(int client) {
return new Get5Player(0, "", view_as<Get5Side>(CS_TEAM_NONE), "Console", false);
}

int userId = GetClientUserId(client);

if (IsClientSourceTV(client)) {
return new Get5Player(0, "", view_as<Get5Side>(CS_TEAM_NONE), "GOTV", false);
return new Get5Player(userId, "", view_as<Get5Side>(CS_TEAM_NONE), "GOTV", false);
}

// In cases where users disconnect (Get5PlayerDisconnectedEvent) without being on a team, they
Expand All @@ -136,8 +138,6 @@ Get5Player GetPlayerObject(int client) {
char name[MAX_NAME_LENGTH];
GetClientName(client, name, sizeof(name));

int userId = GetClientUserId(client);

if (IsAuthedPlayer(client)) {
char auth[AUTH_LENGTH];
GetAuth(client, auth, sizeof(auth));
Expand Down

0 comments on commit 339d628

Please sign in to comment.