Skip to content

Commit

Permalink
Release 1.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
dronelektron committed Aug 28, 2022
2 parents ff68fcc + 43bb81f commit e3c6d9e
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 26 deletions.
8 changes: 2 additions & 6 deletions scripting/block-spectators.sp
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@

#include "morecolors"

#pragma semicolon 1
#pragma newdecls required

#include "bs/console-command"
#include "bs/console-variable"
#include "bs/message"
#include "bs/use-case"
Expand All @@ -20,17 +16,17 @@ public Plugin myinfo = {
name = "Block spectators",
author = "Dron-elektron",
description = "Allows you to block the spectators team at the end of the round or earlier",
version = "1.0.1",
version = "1.0.2",
url = "https://github.com/dronelektron/block-spectators"
};

public void OnPluginStart() {
Command_Create();
Variable_Create();
HookEvent("dod_round_start", Event_RoundStart);
HookEvent("dod_round_active", Event_RoundActive);
HookEvent("dod_round_win", Event_RoundWin);
HookEvent("dod_timer_time_added", Event_TimerTimeAdded);
AddCommandListener(CommandListener_JoinTeam, "jointeam");
LoadTranslations("block-spectators.phrases");
AutoExecConfig(true, "block-spectators");
}
Expand Down
6 changes: 0 additions & 6 deletions scripting/include/bs/console-command.inc

This file was deleted.

18 changes: 6 additions & 12 deletions scripting/modules/console-command.sp
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
public Action CommandListener_JoinTeam(int client, const char[] command, int argc) {
char teamStr[TEAM_ARG_MAX_SIZE];

GetCmdArg(1, teamStr, sizeof(teamStr));

int team = StringToInt(teamStr);

if (UseCase_IsSpectatorsBlocked() && team == TEAM_SPECTATOR) {
MessagePrint_SpectatorsIsBlocked(client);
void Command_Create() {
AddCommandListener(CommandListener_JoinTeam, "jointeam");
}

return Plugin_Stop;
}
public Action CommandListener_JoinTeam(int client, const char[] command, int argc) {
int team = GetCmdArgInt(1);

return Plugin_Continue;
return UseCase_OnClientJoinTeam(client, team) ? Plugin_Continue : Plugin_Stop;
}
14 changes: 12 additions & 2 deletions scripting/modules/use-case.sp
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,18 @@ static float g_blockTimerEndTime = 0.0;
static bool g_isSpectatorsBlocked = false;
static bool g_isRoundTimerExists = ROUND_TIMER_EXISTS_DEFAULT_VALUE;

bool UseCase_IsSpectatorsBlocked() {
return g_isSpectatorsBlocked;
bool UseCase_OnClientJoinTeam(int client, int team) {
bool isBlocked = true;

isBlocked &= g_isSpectatorsBlocked;
isBlocked &= team == TEAM_SPECTATOR;
isBlocked &= IsPlayerAlive(client);

if (isBlocked) {
MessagePrint_SpectatorsIsBlocked(client);
}

return !isBlocked;
}

void UseCase_SetRoundTimerExists(bool exists) {
Expand Down

0 comments on commit e3c6d9e

Please sign in to comment.