Commit f12bbc0c authored by Neoony's avatar Neoony
Browse files

v0.4 - Adjusted Discord announce message slightly - Added option to...

v0.4 - Adjusted Discord announce message slightly - Added option to disable/enable bots for current map when half of l_minplayers type !botsoff / !botson - There must be at least half of l_minplayers in a team to be able to vote to disable bots - Bots will be reenabled if players in a team is less than half of l_minplayers - Added return Plugin_Handled to commands
parent 0b088956
Pipeline #10651 passed with stages
in 6 minutes and 49 seconds
......@@ -80,4 +80,11 @@
- Added chat command !charts to show steamcharts over MOTD
- Added message about joining discord upon player join
- Added message about joining discord every 5 minutes
- Added message about steamcharts every 7 minutes
\ No newline at end of file
- Added message about steamcharts every 7 minutes
**v0.4**
- Adjusted Discord announce message slightly
- Added option to disable/enable bots for current map when half of l_minplayers type !botsoff / !botson
- There must be at least half of l_minplayers in a team to be able to vote to disable bots
- Bots will be reenabled if players in a team is less than half of l_minplayers
- Added return Plugin_Handled to commands
\ No newline at end of file
# Lobby
**Create a vote to join a server on certain player count**
#**This plugin is not designed for public use**
# **This plugin is not designed for public use**
#Download latest version: [Download link](https://git.empiresmod.com/sourcemod/Lobby/-/jobs/artifacts/master/download?job=build)
# Download latest version: [Download link](https://git.empiresmod.com/sourcemod/Lobby/-/jobs/artifacts/master/download?job=build)
*Created by* **Neoony**
--
......@@ -21,7 +21,7 @@ https://forums.alliedmods.net/showthread.php?t=67640
**cURL** Extension:
https://forums.alliedmods.net/showthread.php?t=152216
+ SM 1.10.0 include files: https://github.com/JoinedSenses/SourceMod-IncludeLibrary/
+ SM 1.10.0 include files: https://github.com/JoinedSenses/SourceMod-IncludeLibrary/
**This is included with the plugin.**
--
......@@ -31,6 +31,12 @@ https://forums.alliedmods.net/showthread.php?t=152216
**"sm_charts"**
*"Show steamcharts"*
**"sm_botsoff"**
*"Vote to turn bots off"*
**"sm_botson"**
*"Vote to turn bots on"*
**Server Commands:**
**"l_query"**
......
......@@ -22,7 +22,7 @@
#include <socket>
#include <cURL>
#define PluginVer "v0.3.1"
#define PluginVer "v0.4"
public Plugin myinfo =
{
......@@ -48,7 +48,7 @@ VoteInfo[3];
//ConVars
//l_restrictvotestay
ConVar l_minplayers, l_minplayersext, l_votetimer, l_threshold, l_restrictvote, l_preferredservertimer, l_preferredservermp, l_backupserver, l_forceredirect, l_refreshservers, l_fastconnecttest, l_debug;
ConVar l_minplayers, l_minplayersext, l_votetimer, l_threshold, l_restrictvote, l_preferredservertimer, l_preferredservermp, l_backupserver, l_forceredirect, l_refreshservers, l_fastconnecttest, l_debug, ai_inhibit_spawners;
int PlayersNumber;
int votestarted = 0;
......@@ -152,6 +152,16 @@ char hostname[128];
bool VanillaLocal = false;
bool EuropiresLocal = false;
//Botsoff/on
int BotsOffClient[MAXPLAYERS+1];
int BotsOnClient[MAXPLAYERS+1];
int BotsOffHowMany = 0;
int BotsOnHowMany = 0;
Handle BotsVoteTimer = INVALID_HANDLE;
bool BotsVoteTimerOn = false;
public void OnPluginStart()
{
//LoadTranslations("common.phrases");
......@@ -176,6 +186,9 @@ public void OnPluginStart()
//Console commands
RegConsoleCmd("sm_discord", CCommand_discord, "Show discord invite link");
RegConsoleCmd("sm_charts", CCommand_charts, "Show steamcharts");
RegConsoleCmd("sm_botsoff", CCommand_botsoff, "Vote to turn bots off");
RegConsoleCmd("sm_botson", CCommand_botson, "Vote to turn bots on");
StartSQL();
......@@ -209,6 +222,8 @@ public void OnPluginStart()
ChartsTimer = CreateTimer(420.0, ChartsTmr, _, TIMER_REPEAT);
l_serverformat = CreateConVar( "l_serverformat", "%name - %map (%numplayers/%maxplayers)", "Dont change, this is here because of issues with strings and % sign." );
ai_inhibit_spawners = FindConVar("ai_inhibit_spawners");
//Hook events
HookEvent("game_end", Event_GameEnd);
......@@ -233,21 +248,183 @@ public void OnLibraryAdded(const char[] name)
}
}
public Action CCommand_botsoff(int client, int args)
{
if (GetConVarInt(ai_inhibit_spawners) == 1)
{
PrintToChat(client, "\x04[L] \x01Bots are currently \x07b30000disabled\x01");
}
if (PlayersNumber < GetConVarInt(l_minplayers) / 2 && (GetClientTeam(client) == 2 || GetClientTeam(client) == 3))
{
PrintToChat(client, "\x04[L] \x01\x07b30000Need\x01 at least \x07ff6600%i\x01 players in a team to \x07b30000disable\x01 bots", GetConVarInt(l_minplayers) / 2);
}
if (GetClientTeam(client) != 2 && GetClientTeam(client) != 3)
{
PrintToChat(client, "\x04[L] \x01You \x07b30000must\x01 be in a team to be \x07008000able\x01 to vote");
}
if (GetConVarInt(ai_inhibit_spawners) == 0 && PlayersNumber >= GetConVarInt(l_minplayers) / 2 && (GetClientTeam(client) == 2 || GetClientTeam(client) == 3))
{
if (BotsVoteTimerOn == false)
{
BotsVoteTimer = CreateTimer(30.0, BotsVoteTmr);
}
if (BotsVoteTimerOn == true)
{
//Clear timer
if (BotsVoteTimer != INVALID_HANDLE)
{
KillTimer(BotsVoteTimer);
BotsVoteTimer = INVALID_HANDLE;
}
BotsVoteTimer = CreateTimer(30.0, BotsVoteTmr);
}
if (BotsOffClient[client] == 1)
{
PrintToChat(client, "\x04[L] \x01You already voted to \x07b30000disable\x01 bots");
}
if (BotsOffClient[client] == 0)
{
BotsOffClient[client] = 1;
BotsOffHowMany++;
PrintToChatAll("\x04[L] \x01\x07ff6600%N\x01 voted to \x07b30000disable\x01 bots", client);
int BotsOffHowManyNeeded = GetConVarInt(l_minplayers) / 2 - BotsOffHowMany;
if (BotsOffHowManyNeeded > 0)
{
PrintToChatAll("\x04[L] \x01Need %i more to \x07b30000disable\x01 bots", BotsOffHowManyNeeded);
}
if (BotsOffHowMany >= GetConVarInt(l_minplayers) / 2)
{
SetConVarInt(ai_inhibit_spawners, 1, _, false);
PrintToChatAll("\x04[L] \x01Bots will now \x07b30000stop\x01 spawning");
BotsOffHowMany = 0;
for(int i=1; i<=MaxClients; i++)
{
BotsOffClient[i] = 0;
}
//Clear timer
if (BotsVoteTimer != INVALID_HANDLE)
{
KillTimer(BotsVoteTimer);
BotsVoteTimer = INVALID_HANDLE;
}
}
}
}
return Plugin_Handled;
}
public Action CCommand_botson(int client, int args)
{
if (GetConVarInt(ai_inhibit_spawners) == 0)
{
PrintToChat(client, "\x04[L] \x01Bots are currently \x07008000enabled\x01");
}
if (GetClientTeam(client) != 2 && GetClientTeam(client) != 3)
{
PrintToChat(client, "\x04[L] \x01You \x07b30000must\x01 be in a team to be \x07008000able\x01 to vote");
}
if (GetConVarInt(ai_inhibit_spawners) == 1 && (GetClientTeam(client) == 2 || GetClientTeam(client) == 3))
{
if (BotsVoteTimerOn == false)
{
BotsVoteTimer = CreateTimer(30.0, BotsVoteTmr);
}
if (BotsVoteTimerOn == true)
{
//Clear timer
if (BotsVoteTimer != INVALID_HANDLE)
{
KillTimer(BotsVoteTimer);
BotsVoteTimer = INVALID_HANDLE;
}
BotsVoteTimer = CreateTimer(30.0, BotsVoteTmr);
}
if (BotsOnClient[client] == 1)
{
PrintToChat(client, "\x04[L] \x01You already voted to \x07008000enable\x01 bots");
}
if (BotsOnClient[client] == 0)
{
BotsOnClient[client] = 1;
BotsOnHowMany++;
PrintToChatAll("\x04[L] \x01\x07ff6600%N\x01 voted to \x07008000enable\x01 bots", client);
int BotsOnHowManyNeeded = GetConVarInt(l_minplayers) / 2 - BotsOnHowMany;
if (BotsOnHowManyNeeded > 0)
{
PrintToChatAll("\x04[L] \x01Need %i more to \x07008000enable\x01 bots", BotsOnHowManyNeeded);
}
if (BotsOnHowMany >= GetConVarInt(l_minplayers) / 2)
{
SetConVarInt(ai_inhibit_spawners, 0, _, false);
PrintToChatAll("\x04[L] \x01Bots are now \x07008000enabled\x01");
BotsOnHowMany = 0;
for(int i=1; i<=MaxClients; i++)
{
BotsOnClient[i] = 0;
}
//Clear timer
if (BotsVoteTimer != INVALID_HANDLE)
{
KillTimer(BotsVoteTimer);
BotsVoteTimer = INVALID_HANDLE;
}
}
}
}
return Plugin_Handled;
}
public Action BotsVoteTmr(Handle timer)
{
BotsOffHowMany = 0;
for(int i=1; i<=MaxClients; i++)
{
BotsOffClient[i] = 0;
}
BotsOnHowMany = 0;
for(int i=1; i<=MaxClients; i++)
{
BotsOnClient[i] = 0;
}
PrintToChatAll("\x04[L] \x01Bots vote queue has been \x07b30000reset\x01");
//Clear timer
if (BotsVoteTimer != INVALID_HANDLE)
{
KillTimer(BotsVoteTimer);
BotsVoteTimer = INVALID_HANDLE;
}
}
public Action CCommand_discord(int client, int args)
{
PrintToChat(client, "https://discord.gg/UH6Sc6B");
ShowMOTDPanel(client, "Discord", "https://discord.gg/UH6Sc6B", 2);
return Plugin_Handled;
}
public Action CCommand_charts(int client, int args)
{
//PrintToChat(client, "https://steamcharts.com/app/17740");
ShowMOTDPanel(client, "Steamcharts", "https://steamcharts.com/app/17740", 2);
return Plugin_Handled;
}
public Action DiscordTmr(Handle timer)
{
PrintToChatAll("\x04[L] \x01Join Official \x077988d9Discord\x01 channel by typing \x077988d9!discord\x01, to find out when games are happening");
PrintToChatAll("\x04[L] \x01Join Official \x077988d9Discord\x01 channel by typing \x077988d9!discord\x01, to chat with community or to find out when games are happening");
//Clear timer
if (DiscordTimer != INVALID_HANDLE)
{
......@@ -332,6 +509,7 @@ public Action SCommand_LOneTimeForceRedirect(int args)
}
}
}
return Plugin_Handled;
}
public void ForceRedirectSingle(int Client)
......@@ -804,6 +982,26 @@ public OnMapEnd()
KillTimer(StartVoteCountTimer);
StartVoteCountTimer = INVALID_HANDLE;
}
//Clear bots vote
BotsOffHowMany = 0;
for(int i=1; i<=MaxClients; i++)
{
BotsOffClient[i] = 0;
}
BotsOnHowMany = 0;
for(int i=1; i<=MaxClients; i++)
{
BotsOnClient[i] = 0;
}
//Clear timer
if (BotsVoteTimer != INVALID_HANDLE)
{
KillTimer(BotsVoteTimer);
BotsVoteTimer = INVALID_HANDLE;
}
/*
//Clear timer
......@@ -880,6 +1078,26 @@ void Event_GameEnd(Handle event, const char[] name, bool dontBroadcast)
KillTimer(StartVoteTimer);
StartVoteTimer = INVALID_HANDLE;
}
//Clear bots vote
BotsOffHowMany = 0;
for(int i=1; i<=MaxClients; i++)
{
BotsOffClient[i] = 0;
}
BotsOnHowMany = 0;
for(int i=1; i<=MaxClients; i++)
{
BotsOnClient[i] = 0;
}
//Clear timer
if (BotsVoteTimer != INVALID_HANDLE)
{
KillTimer(BotsVoteTimer);
BotsVoteTimer = INVALID_HANDLE;
}
/*
//Clear timer
......@@ -952,6 +1170,26 @@ public void OnConfigsExecuted()
KillTimer(StartVoteTimeleftTimer);
StartVoteTimeleftTimer = INVALID_HANDLE;
}
//Clear bots vote
BotsOffHowMany = 0;
for(int i=1; i<=MaxClients; i++)
{
BotsOffClient[i] = 0;
}
BotsOnHowMany = 0;
for(int i=1; i<=MaxClients; i++)
{
BotsOnClient[i] = 0;
}
//Clear timer
if (BotsVoteTimer != INVALID_HANDLE)
{
KillTimer(BotsVoteTimer);
BotsVoteTimer = INVALID_HANDLE;
}
PlayerCountCheck = CreateTimer(5.0, PlayerCountChk, _, TIMER_REPEAT);
......@@ -1011,6 +1249,18 @@ public void OnClientDisconnect(int Client)
KillTimer(Timer3[Client]);
Timer3[Client] = INVALID_HANDLE;
}
if (BotsOffClient[Client] == 1)
{
BotsOffHowMany--;
PrintToServer("%i", BotsOffHowMany);
BotsOffClient[Client] = 0;
}
if (BotsOnClient[Client] == 1)
{
BotsOnHowMany--;
PrintToServer("%i", BotsOnHowMany);
BotsOnClient[Client] = 0;
}
}
//SQL
......@@ -1161,6 +1411,7 @@ public Action QueryServersData(int args)
public Action SCommand_LQuery(int args)
{
QueryNumberOfServers();
return Plugin_Handled;
}
public Action SCommand_LQueryx(int args)
......@@ -1172,6 +1423,7 @@ public Action SCommand_LQueryx(int args)
PrintToServer("[L][Database] players: %s", playersx[0]);
//Maxplayers
PrintToServer("[L][Database] maxplayers: %s", maxplayersx[0]);
return Plugin_Handled;
}
public void InfoOfServer(Handle hDriver, Handle hResult, const char[] sError, int ServerIndex)
......@@ -1254,6 +1506,15 @@ public Action PlayerCountChk(Handle timer)
public void PlayersNumberCheck()
{
PlayersNumber = GetTeamClientCount(2) + GetTeamClientCount(3);
//Reenable bots if less than half of l_minplayers is reached and bots are disabled
if (GetConVarInt(ai_inhibit_spawners) == 1 && PlayersNumber < GetConVarInt(l_minplayers) / 2)
{
SetConVarInt(ai_inhibit_spawners, 0, _, false);
PrintToChatAll("\x04[L] \x01\x07b30000Not enough\x01 players in a team to play without bots");
PrintToChatAll("\x04[L] \x01Bots are now \x07008000enabled\x01");
}
if (PlayersNumber >= GetConVarInt(l_minplayers) && votestarted == 0 && IsVoteInProgress() == false && PopulatedServerAlive == false && VoteRestricted == false && EndOfMap == false)
{
......@@ -1802,6 +2063,7 @@ public Action SCommand_StartVote(int args)
RestrictVoteHowLong = INVALID_HANDLE;
}
}
return Plugin_Handled;
}
//Preferred Server section
......@@ -2048,6 +2310,7 @@ public Action SCommand_LRSdump(int args)
PrintToServer("[L] Server[%i] FinalNumplayers : %i", SNumber, numPlayersS[SNumber]);
PrintToServer("[L] Server[%i] FinalMaxplayers : %i", SNumber, maxPlayersS[SNumber]);
}
return Plugin_Handled;
}
//Socket extension section
......
......@@ -4,14 +4,14 @@
{
"Version"
{
"Latest" "v0.3.1"
"Latest" "v0.4"
}
"Notes" "Added chat command !discord to join Discord over MOTD"
"Notes" "Added chat command !charts to show steamcharts over MOTD"
"Notes" "Added message about joining discord upon player join"
"Notes" "Added message about joining discord every 5 minutes"
"Notes" "Added message about steamcharts every 7 minutes"
"Notes" "Adjusted Discord announce message slightly"
"Notes" "Added option to disable/enable bots for current map when half of l_minplayers type !botsoff / !botson"
"Notes" "There must be at least half of l_minplayers in a team to be able to vote to disable bots"
"Notes" "Bots will be reenabled if players in a team is less than half of l_minplayers"
"Notes" "Added return Plugin_Handled to commands"
}
"Files"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment