Skip to content

Commit

Permalink
0.6.2c
Browse files Browse the repository at this point in the history
  • Loading branch information
jonteohr committed Sep 15, 2017
1 parent 78055e4 commit d12c8af
Show file tree
Hide file tree
Showing 7 changed files with 86 additions and 25 deletions.
34 changes: 20 additions & 14 deletions addons/sourcemod/scripting/BetterWarden/Add-Ons/voteday.sp
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,12 @@ public int BWMenuHandler(Menu menu, MenuAction action, int client, int param2) {
public bool IsValidVote(int client) {
if(!IsValidClient(client))
return false;
if(!g_bAllowVotes && WardenExists()) {
CPrintToChat(client, "%s %t", g_sPrefix, "Votes Not Allowed");
return false;
}
if(g_bIsGameActive)
return false;
if(g_iGameVote != -1) {
CPrintToChat(client, "%s %t", g_sPrefix, "Vote Already Active");
return false;
Expand Down Expand Up @@ -286,12 +292,12 @@ public bool VoteFinished() {
if(g_iVoteYes > g_iVoteNo) {
ExecWarday();
g_iGameVote = -1;
for(int i = 0; i <= sizeof(g_iVoted); i++) g_iVoted[i] = 0; // Reset votes
for(int i = 0; i < sizeof(g_iVoted); i++) g_iVoted[i] = 0;
return true;
} else {
CPrintToChatAll("%s %t", g_sPrefix, "Voted Down");
g_iGameVote = -1;
for(int i = 0; i <= sizeof(g_iVoted); i++) g_iVoted[i] = 0; // Reset votes
for(int i = 0; i < sizeof(g_iVoted); i++) g_iVoted[i] = 0;
return true;
}
}
Expand All @@ -300,77 +306,77 @@ public bool VoteFinished() {
int randomInt = GetRandomInt(1, 2); // Set the number of winners randomly
ExecHnS(randomInt);
g_iGameVote = -1;
for(int i = 0; i <= sizeof(g_iVoted); i++) g_iVoted[i] = 0; // Reset votes
for(int i = 0; i < sizeof(g_iVoted); i++) g_iVoted[i] = 0;
return true;
} else {
CPrintToChatAll("%s %t", g_sPrefix, "Voted Down");
g_iGameVote = -1;
for(int i = 0; i <= sizeof(g_iVoted); i++) g_iVoted[i] = 0; // Reset votes
for(int i = 0; i < sizeof(g_iVoted); i++) g_iVoted[i] = 0;
return true;
}
}
if(g_iGameVote == 2) {
if(g_iVoteYes > g_iVoteNo) {
ExecGravday();
g_iGameVote = -1;
for(int i = 0; i <= sizeof(g_iVoted); i++) g_iVoted[i] = 0; // Reset votes
for(int i = 0; i < sizeof(g_iVoted); i++) g_iVoted[i] = 0;
return true;
} else {
CPrintToChatAll("%s %t", g_sPrefix, "Voted Down");
g_iGameVote = -1;
for(int i = 0; i <= sizeof(g_iVoted); i++) g_iVoted[i] = 0; // Reset votes
for(int i = 0; i < sizeof(g_iVoted); i++) g_iVoted[i] = 0;
return true;
}
}
if(g_iGameVote == 3) {
if(g_iVoteYes > g_iVoteNo) {
ExecFreeday();
g_iGameVote = -1;
for(int i = 0; i <= sizeof(g_iVoted); i++) g_iVoted[i] = 0; // Reset votes
for(int i = 0; i < sizeof(g_iVoted); i++) g_iVoted[i] = 0;
return true;
} else {
CPrintToChatAll("%s %t", g_sPrefix, "Voted Down");
g_iGameVote = -1;
for(int i = 0; i <= sizeof(g_iVoted); i++) g_iVoted[i] = 0; // Reset votes
for(int i = 0; i < sizeof(g_iVoted); i++) g_iVoted[i] = 0;
return true;
}
}
if(g_iGameVote == 4) {
if(g_iVoteYes > g_iVoteNo) {
initWW();
g_iGameVote = -1;
for(int i = 0; i <= sizeof(g_iVoted); i++) g_iVoted[i] = 0; // Reset votes
for(int i = 0; i < sizeof(g_iVoted); i++) g_iVoted[i] = 0;
return true;
} else {
CPrintToChatAll("%s %t", g_sPrefix, "Voted Down");
g_iGameVote = -1;
for(int i = 0; i <= sizeof(g_iVoted); i++) g_iVoted[i] = 0; // Reset votes
for(int i = 0; i < sizeof(g_iVoted); i++) g_iVoted[i] = 0;
return true;
}
}
if(g_iGameVote == 5) {
if(g_iVoteYes > g_iVoteNo) {
initZombie();
g_iGameVote = -1;
for(int i = 0; i <= sizeof(g_iVoted); i++) g_iVoted[i] = 0; // Reset votes
for(int i = 0; i < sizeof(g_iVoted); i++) g_iVoted[i] = 0;
return true;
} else {
CPrintToChatAll("%s %t", g_sPrefix, "Voted Down");
g_iGameVote = -1;
for(int i = 0; i <= sizeof(g_iVoted); i++) g_iVoted[i] = 0; // Reset votes
for(int i = 0; i < sizeof(g_iVoted); i++) g_iVoted[i] = 0;
return true;
}
}
if(g_iGameVote == 6) {
if(g_iVoteYes > g_iVoteNo) {
initCatch();
g_iGameVote = -1;
for(int i = 0; i <= sizeof(g_iVoted); i++) g_iVoted[i] = 0; // Reset votes
for(int i = 0; i < sizeof(g_iVoted); i++) g_iVoted[i] = 0;
return true;
} else {
CPrintToChatAll("%s %t", g_sPrefix, "Voted Down");
g_iGameVote = -1;
for(int i = 0; i <= sizeof(g_iVoted); i++) g_iVoted[i] = 0; // Reset votes
for(int i = 0; i < sizeof(g_iVoted); i++) g_iVoted[i] = 0;
return true;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ public Action OnTakeDamageAlive(int victim, int &attacker, int &inflictor, float
public void OnRoundStart(Event event, const char[] name, bool dontBroadcast) {
abortGames();

g_bAllowVotes = false;

g_iAliveTs = 0;
g_iAliveTs = GetTeamAliveClientCount(CS_TEAM_T);
for(int client = 1; client <= MaxClients; client++) {
Expand Down
39 changes: 30 additions & 9 deletions addons/sourcemod/scripting/BetterWarden/WardenMenu/menus.sp
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,22 @@ public void openMenu(int client) {

menu.SetTitle(title);

if(gc_bEnableWeapons.IntValue == 1) {
if(gc_bEnableWeapons.IntValue == 1)
menu.AddItem(CHOICE1, "Choice 1"); // Weapons
}

menu.AddItem(CHOICE2, "Choice 2"); // Event Days

if(gc_bEnablePlayerFreeday.IntValue == 1) {
if(gc_bEnablePlayerFreeday.IntValue == 1)
menu.AddItem(CHOICE4, "Choice 4"); // Player Freeday
}

if(gc_bEnableDoors.IntValue == 1) {
if(gc_bEnableDoors.IntValue == 1)
menu.AddItem(CHOICE5, "Choice 5"); // Open Doors
}

if(gc_bNoblock.IntValue == 1) {
if(gc_bNoblock.IntValue == 1)
menu.AddItem(CHOICE3, "Choice 3"); // Noblock
}

if(g_bVotesLoaded)
menu.AddItem(CHOICE6, "Choice 6"); // Allow votes

menu.AddItem(CHOICE8, "Choice 8"); // Leave warden

Expand Down Expand Up @@ -84,6 +83,15 @@ public int WardenMenuHandler(Menu menu, MenuAction action, int client, int param
if(StrEqual(info, CHOICE5)) {
FakeClientCommand(client, "sm_open");
}
if(StrEqual(info, CHOICE6)) {
if(g_bAllowVotes) {
g_bAllowVotes = false;
CPrintToChatAll("%s %t", g_sPrefix, "Votes Closed");
} else {
g_bAllowVotes = true;
CPrintToChatAll("%s %t", g_sPrefix, "Votes Opened");
}
}
if(StrEqual(info, CHOICE8)) {
FakeClientCommand(client, "sm_rw");
}
Expand All @@ -108,9 +116,14 @@ public int WardenMenuHandler(Menu menu, MenuAction action, int client, int param
} else if(StrEqual(info, CHOICE3)) {
return ITEMDRAW_DEFAULT;
} else if(StrEqual(info, CHOICE4)) {
return ITEMDRAW_DEFAULT;
if(!IsHnsActive())
return ITEMDRAW_DEFAULT;
if(IsHnsActive())
return ITEMDRAW_DISABLED;
} else if(StrEqual(info, CHOICE5)) {
return ITEMDRAW_DEFAULT;
} else if(StrEqual(info, CHOICE6)) {
return ITEMDRAW_DEFAULT;
} else if(StrEqual(info, SEP)) {
return ITEMDRAW_DISABLED;
} else {
Expand Down Expand Up @@ -144,6 +157,14 @@ public int WardenMenuHandler(Menu menu, MenuAction action, int client, int param
Format(display, sizeof(display), "%t", "Toggle doors");
return RedrawMenuItem(display);
}
if(StrEqual(info, CHOICE6)) {
if(!g_bAllowVotes)
Format(display, sizeof(display), "%t", "Allow Votes");
if(g_bAllowVotes)
Format(display, sizeof(display), "%t", "Dis-Allow Votes");

return RedrawMenuItem(display);
}
if(StrEqual(info, CHOICE8)) {
Format(display, sizeof(display), "%t\n----------------", "Leave Warden");
return RedrawMenuItem(display);
Expand Down
2 changes: 1 addition & 1 deletion addons/sourcemod/scripting/include/betterwarden.inc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#endinput
#endif
#define bwardenincluded
#define VERSION "0.6.2"
#define VERSION "0.6.2c"

stock char g_sPrefix[] = "[{blue}Warden{default}] ";

Expand Down
1 change: 1 addition & 0 deletions addons/sourcemod/scripting/include/wardenmenu.inc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#define wardenmenuincluded

stock bool g_bIsGameActive;
stock bool g_bAllowVotes;

/**
* Called when a warden opens the warden menu. Also called when a player becomes a warden if sm_cmenu_auto_open is set to 1.
Expand Down
3 changes: 2 additions & 1 deletion addons/sourcemod/scripting/wardenmenu.sp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
bool g_bCatchLoaded;
bool g_bWWLoaded;
bool g_bZombieLoaded;
bool g_bVotesLoaded;

char g_sCMenuPrefix[] = "[{bluegrey}WardenMenu{default}] ";
char g_sBlipSound[PLATFORM_MAX_PATH];
Expand Down Expand Up @@ -187,7 +188,7 @@ public void OnAllPluginsLoaded() {
g_bCatchLoaded = LibraryExists("bwcatch");
g_bWWLoaded = LibraryExists("bwwildwest");
g_bZombieLoaded = LibraryExists("bwzombie");

g_bVotesLoaded = LibraryExists("bwvoteday");
}

public void abortGames() {
Expand Down
30 changes: 30 additions & 0 deletions addons/sourcemod/translations/BetterWarden.Votes.phrases.txt
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,34 @@
"en" "You started a vote!"
"sv" "Du startade en omröstning!"
}

"Votes Opened"
{
"en" "The warden has allowed voting for an event day!"
"sv" "Direktören har tillåtit omröstningar för en dag!"
}

"Votes Closed"
{
"en" "The warden has closed voting."
"sv" "Direktören har stängt av omröstningar."
}

"Allow Votes"
{
"en" "Allow Votes"
"sv" "Tillåt omröstningar"
}

"Dis-Allow Votes"
{
"en" "Dis-Allow Votes"
"sv" "Stäng av omröstningar"
}

"Votes Not Allowed"
{
"en" "Voting is not allowed currently!"
"sv" "Omröstningar är inte tillåtna just nu!"
}
}

0 comments on commit d12c8af

Please sign in to comment.