mirror of
https://github.com/Jackzmc/sourcemod-plugins.git
synced 2025-05-06 03:03:21 +00:00
Remove reservation when 4+ joining
This commit is contained in:
parent
8e4d9f3c4d
commit
bac6f4ea65
2 changed files with 37 additions and 37 deletions
Binary file not shown.
|
@ -13,9 +13,10 @@
|
||||||
#define L4D_MAXHUMANS_LOBBY_VERSUS 8
|
#define L4D_MAXHUMANS_LOBBY_VERSUS 8
|
||||||
#define L4D_MAXHUMANS_LOBBY_OTHER 4
|
#define L4D_MAXHUMANS_LOBBY_OTHER 4
|
||||||
|
|
||||||
new Handle:cvarGameMode = INVALID_HANDLE;
|
ConVar cvarGameMode;
|
||||||
|
ConVar cvarUnreserve;
|
||||||
|
|
||||||
public Plugin:myinfo =
|
public Plugin myinfo =
|
||||||
{
|
{
|
||||||
name = "L4D1/2 Remove Lobby Reservation",
|
name = "L4D1/2 Remove Lobby Reservation",
|
||||||
author = "Downtown1",
|
author = "Downtown1",
|
||||||
|
@ -24,7 +25,6 @@ public Plugin:myinfo =
|
||||||
url = "http://forums.alliedmods.net/showthread.php?t=87759"
|
url = "http://forums.alliedmods.net/showthread.php?t=87759"
|
||||||
}
|
}
|
||||||
|
|
||||||
new Handle:cvarUnreserve = INVALID_HANDLE;
|
|
||||||
|
|
||||||
public OnPluginStart()
|
public OnPluginStart()
|
||||||
{
|
{
|
||||||
|
@ -35,51 +35,51 @@ public OnPluginStart()
|
||||||
cvarUnreserve = CreateConVar("l4d_unreserve_full", "1", "Automatically unreserve server after a full lobby joins", FCVAR_SPONLY|FCVAR_NOTIFY);
|
cvarUnreserve = CreateConVar("l4d_unreserve_full", "1", "Automatically unreserve server after a full lobby joins", FCVAR_SPONLY|FCVAR_NOTIFY);
|
||||||
CreateConVar("l4d_unreserve_version", UNRESERVE_VERSION, "Version of the Lobby Unreserve plugin.", FCVAR_SPONLY|FCVAR_NOTIFY);
|
CreateConVar("l4d_unreserve_version", UNRESERVE_VERSION, "Version of the Lobby Unreserve plugin.", FCVAR_SPONLY|FCVAR_NOTIFY);
|
||||||
|
|
||||||
|
HookEvent("game_init", Event_GameStart);
|
||||||
|
|
||||||
|
|
||||||
cvarGameMode = FindConVar("mp_gamemode");
|
cvarGameMode = FindConVar("mp_gamemode");
|
||||||
}
|
}
|
||||||
|
|
||||||
bool:IsScavengeMode()
|
void Event_GameStart(Event event, const char[] name, bool dontBroadcast) {
|
||||||
{
|
CreateTimer(20.0, Timer_CheckPlayers);
|
||||||
decl String:sGameMode[32];
|
|
||||||
GetConVarString(cvarGameMode, sGameMode, sizeof(sGameMode));
|
|
||||||
if (StrContains(sGameMode, "scavenge") > -1)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool:IsVersusMode()
|
Action Timer_CheckPlayers(Handle h) {
|
||||||
{
|
if(AreAllPlayersConnecting()) {
|
||||||
decl String:sGameMode[32];
|
PrintToServer("4 Players connecting, unreserving");
|
||||||
GetConVarString(cvarGameMode, sGameMode, sizeof(sGameMode));
|
L4D_LobbyUnreserve();
|
||||||
if (StrContains(sGameMode, "versus") > -1)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
return Plugin_Continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
IsServerLobbyFull()
|
bool AreAllPlayersConnecting() {
|
||||||
|
int count = 0;
|
||||||
|
for(int i = 1; i <= MaxClients; i++) {
|
||||||
|
if(IsClientConnected(i) && !IsFakeClient(i)) {
|
||||||
|
if(!IsClientInGame(i)) return false;
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return count >= 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool IsServerLobbyFull()
|
||||||
{
|
{
|
||||||
new humans = GetHumanCount();
|
int humans = GetHumanCount();
|
||||||
|
|
||||||
DebugPrintToAll("IsServerLobbyFull : humans = %d", humans);
|
DebugPrintToAll("IsServerLobbyFull : humans = %d", humans);
|
||||||
|
|
||||||
if(IsVersusMode() || IsScavengeMode())
|
char sGameMode[32];
|
||||||
|
cvarGameMode.GetString(sGameMode, sizeof(sGameMode));
|
||||||
|
if(StrEqual(sGameMode, "versus") || StrEqual(sGameMode, "scavenge"))
|
||||||
{
|
{
|
||||||
return humans >= L4D_MAXHUMANS_LOBBY_VERSUS;
|
return humans >= L4D_MAXHUMANS_LOBBY_VERSUS;
|
||||||
}
|
}
|
||||||
return humans >= L4D_MAXHUMANS_LOBBY_OTHER;
|
return humans >= L4D_MAXHUMANS_LOBBY_OTHER;
|
||||||
}
|
}
|
||||||
|
|
||||||
public OnClientPutInServer(client)
|
public OnClientPutInServer(int client)
|
||||||
{
|
{
|
||||||
DebugPrintToAll("Client put in server %N", client);
|
DebugPrintToAll("Client put in server %N", client);
|
||||||
|
|
||||||
|
@ -90,7 +90,7 @@ public OnClientPutInServer(client)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Action:Command_Unreserve(client, args)
|
Action Command_Unreserve(int client, int args)
|
||||||
{
|
{
|
||||||
/*if(!L4D_LobbyIsReserved())
|
/*if(!L4D_LobbyIsReserved())
|
||||||
{
|
{
|
||||||
|
@ -105,16 +105,16 @@ public Action:Command_Unreserve(client, args)
|
||||||
|
|
||||||
|
|
||||||
//client is in-game and not a bot
|
//client is in-game and not a bot
|
||||||
stock bool:IsClientInGameHuman(client)
|
stock bool IsClientInGameHuman(int client)
|
||||||
{
|
{
|
||||||
return IsClientInGame(client) && !IsFakeClient(client);
|
return IsClientInGame(client) && !IsFakeClient(client);
|
||||||
}
|
}
|
||||||
|
|
||||||
stock GetHumanCount()
|
stock int GetHumanCount()
|
||||||
{
|
{
|
||||||
new humans = 0;
|
int humans = 0;
|
||||||
|
|
||||||
new i;
|
int i;
|
||||||
for(i = 1; i < L4D_MAXCLIENTS_PLUS1; i++)
|
for(i = 1; i < L4D_MAXCLIENTS_PLUS1; i++)
|
||||||
{
|
{
|
||||||
if(IsClientInGameHuman(i))
|
if(IsClientInGameHuman(i))
|
||||||
|
@ -126,10 +126,10 @@ stock GetHumanCount()
|
||||||
return humans;
|
return humans;
|
||||||
}
|
}
|
||||||
|
|
||||||
DebugPrintToAll(const String:format[], any:...)
|
void DebugPrintToAll(const char[] format, any...)
|
||||||
{
|
{
|
||||||
#if UNRESERVE_DEBUG || UNRESERVE_DEBUG_LOG
|
#if UNRESERVE_DEBUG || UNRESERVE_DEBUG_LOG
|
||||||
decl String:buffer[192];
|
char buffer[192];
|
||||||
|
|
||||||
VFormat(buffer, sizeof(buffer), format, 2);
|
VFormat(buffer, sizeof(buffer), format, 2);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue