Skip to content

Commit

Permalink
Enable votekick to UNASSINED team players
Browse files Browse the repository at this point in the history
  • Loading branch information
leobrines committed May 2, 2020
1 parent b61930e commit fddee25
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 12 deletions.
2 changes: 1 addition & 1 deletion scripting/competitive.sma
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include <competitive/index>

#define PLUGIN "Competitive"
#define VERSION "0.11.14"
#define VERSION "0.11.15"
#define AUTHOR "Leopoldo Brines"

public plugin_init()
Expand Down
7 changes: 4 additions & 3 deletions scripting/include/competitive/menutils.inc
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,19 @@ stock menu_create_tsplayers (id, handler[], bool:showself=false) {
new players[MAX_PLAYERS], num, TeamName:team;
new playersf[MAX_PLAYERS], pindex;

get_players(players, num, "ch");
get_players(players, num, "h");

team = client_get_team(id);

for (new i = 0; i < num; i++) {
new p = players[i]
new TeamName:pteam = client_get_team(p);

if (!showself && p == id)
continue

if (team == pteam || pteam == TEAM_SPECTATOR) {
new TeamName:pteam = client_get_team(p);

if (team == pteam || pteam == TEAM_SPECTATOR || pteam == TEAM_UNASSIGNED) {
playersf[pindex] = p
pindex++
}
Expand Down
37 changes: 29 additions & 8 deletions scripting/include/competitive/votekick.inc
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,10 @@ stock votekick_finish (TeamName:team, menu) {
menu_destroy(menu);
menu_cancel_team(team);

if (votes[team][0] < MIN_VOTES) {
new minvotes = votekick_minvotes(team);
new votes_yes = votes[team][0]

if (votes_yes < minvotes) {
team_print(team, "%L", LANG_SERVER, "PUG_VOTING_INSUFFICIENT");
return;
}
Expand All @@ -160,6 +163,19 @@ stock votekick_finish (TeamName:team, menu) {
chat_print(0, "%L", LANG_SERVER, "PUG_VOTEKICK_KICKED", target_name[team]);
}

stock votekick_minvotes(TeamName:team) {
new target_user = target[team]
new TeamName:target_team = client_get_team(target_user)

if (target_team == team) {
return MIN_VOTES;
}

// here, target is spectator
return teammates_count[team]-1;
}


stock user_iskicked (id) {
static steamid[32];

Expand All @@ -174,17 +190,22 @@ stock user_iskicked (id) {
}

static user_kick (id) {
// Prevent spectators from being banned from the game
if (client_is_player(id))
votekick_banuser(id)

server_cmd("kick #%i ^"Votekick^"", get_user_userid(id));
}

static votekick_banuser(id) {
static steamid[32];
get_user_authid(id, steamid, sizeof(steamid) -1);

for (new i; i<sizeof players_kicked; i++) {
if (!equali(players_kicked[i], ""))
continue;

server_cmd("kick #%i ^"Votekick^"", get_user_userid(id));

format(players_kicked[i], charsmax(players_kicked[]), "%s", steamid);
break;
if (equali(players_kicked[i], "")) {
format(players_kicked[i], charsmax(players_kicked[]), "%s", steamid);
break;
}
}
}

Expand Down

0 comments on commit fddee25

Please sign in to comment.