Skip to content

Commit

Permalink
filter out bots in trainingmsg and fix fishes not being reset on themes
Browse files Browse the repository at this point in the history
  • Loading branch information
arthurdead committed Mar 5, 2021
1 parent 7b7f61a commit 52da7f5
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 20 deletions.
2 changes: 2 additions & 0 deletions addons/sourcemod/scripting/themes.sp
Original file line number Diff line number Diff line change
Expand Up @@ -582,6 +582,8 @@ void InitConfig()
numUnknownChanceThemes = 0;
totalChance = 0.0;
selectionStyle = STYLE_RANDOM;

fishes = null;
}

/* LoadConfig()
Expand Down
86 changes: 66 additions & 20 deletions addons/sourcemod/scripting/trainingmsg.sp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ int tf_gamerules = -1;
int m_bIsInTrainingOffset = -1;
int m_bIsTrainingHUDVisibleOffset = -1;

ConVar tf_training_client_message = null;

public void OnPluginStart()
{
TrainingObjective = GetUserMessageId("TrainingObjective");
Expand All @@ -30,6 +32,8 @@ public void OnPluginStart()
AddCommandListener(command_menu, "menuopen");
AddCommandListener(command_menu, "menuclosed");

tf_training_client_message = FindConVar("tf_training_client_message");

HookEvent("player_spawn", player_spawn);
HookEvent("teamplay_round_start", teamplay_round_start);
}
Expand Down Expand Up @@ -68,6 +72,13 @@ public void OnMapStart()
}
}

public void OnMapEnd()
{
for(int i = 1; i <= MaxClients; ++i) {
DisableClient(i, true);
}
}

public void OnEntityCreated(int entity, const char[] classname)
{
if(StrEqual(classname, "tf_gamerules")) {
Expand Down Expand Up @@ -133,7 +144,12 @@ Action command_menu(int client, const char[] command, int args)

public void OnGameFrame()
{
if(num_enabled > 0) {
#if defined SET_PROP
if((num_enabled > 0) && (num_enabled != MaxClients))
#else
if(num_enabled > 0)
#endif
{
ChangeGameRulesState();
}
}
Expand Down Expand Up @@ -209,11 +225,16 @@ int DisableClient(int client, bool send_empty)
player_vgui_timer[client] = null;
}

if(send_empty && IsClientInGame(client)) {
int clients[1];
clients[0] = client;

SendUsrMsgHelper(clients, sizeof(clients), "", "");
if(send_empty) {
if(!IsClientInGame(client) ||
IsFakeClient(client) ||
IsClientSourceTV(client) ||
IsClientReplay(client)) {
} else {
int clients[1];
clients[0] = client;
SendUsrMsgHelper(clients, sizeof(clients), "", "");
}
}

if(msg_enabled[client]) {
Expand Down Expand Up @@ -312,10 +333,14 @@ int ChangeTitleAll(Handle plugin, int params)
int numClients = 0;
int[] clients = new int[MaxClients];
for(int i = 1; i <= MaxClients; ++i) {
if(IsClientInGame(i)) {
if((m_bIsInTraining && m_bIsTrainingHUDVisible) || msg_enabled[i]) {
clients[numClients++] = i;
}
if(!IsClientInGame(i) ||
IsFakeClient(i) ||
IsClientSourceTV(i) ||
IsClientReplay(i)) {
continue;
}
if((m_bIsInTraining && m_bIsTrainingHUDVisible) || msg_enabled[i]) {
clients[numClients++] = i;
}
}

Expand All @@ -339,10 +364,14 @@ int ChangeTextAll(Handle plugin, int params)
int numClients = 0;
int[] clients = new int[MaxClients];
for(int i = 1; i <= MaxClients; ++i) {
if(IsClientInGame(i)) {
if((m_bIsInTraining && m_bIsTrainingHUDVisible) || msg_enabled[i]) {
clients[numClients++] = i;
}
if(!IsClientInGame(i) ||
IsFakeClient(i) ||
IsClientSourceTV(i) ||
IsClientReplay(i)) {
continue;
}
if((m_bIsInTraining && m_bIsTrainingHUDVisible) || msg_enabled[i]) {
clients[numClients++] = i;
}
}

Expand Down Expand Up @@ -432,6 +461,12 @@ int SendToClients(Handle plugin, int params)
{
for(int i = 0; i < numClients; ++i) {
int client = clients[i];
if(!IsClientInGame(client) ||
IsFakeClient(client) ||
IsClientSourceTV(client) ||
IsClientReplay(client)) {
continue;
}
EnableClient(client);
}

Expand Down Expand Up @@ -460,14 +495,18 @@ int SendToAll(Handle plugin, int params)
int numClients = 0;
int[] clients = new int[MaxClients];
for(int i = 1; i <= MaxClients; ++i) {
if(IsClientInGame(i)) {
clients[numClients++] = i;
#if !defined SET_PROP
EnableClient(i);
#endif
}
#if defined SET_PROP
DisableClient(i, true);
#endif
if(!IsClientInGame(i) ||
IsFakeClient(i) ||
IsClientSourceTV(i) ||
IsClientReplay(i)) {
continue;
}
clients[numClients++] = i;
#if !defined SET_PROP
EnableClient(i);
#endif
}

Expand All @@ -480,6 +519,13 @@ int SendToClient(Handle plugin, int params)
{
int client = GetNativeCell(1);

if(!IsClientInGame(client) ||
IsFakeClient(client) ||
IsClientSourceTV(client) ||
IsClientReplay(client)) {
return 0;
}

int length = 0;
GetNativeStringLength(2, length);
length++;
Expand Down

0 comments on commit 52da7f5

Please sign in to comment.