Skip to content

Commit

Permalink
join插件增加大厅自动删除的convar,slots_vote投票插件当投票人数超出大厅人数时,也会
Browse files Browse the repository at this point in the history
删除大厅
  • Loading branch information
fantasylidong committed Dec 4, 2022
1 parent 5b6e866 commit d6436ae
Show file tree
Hide file tree
Showing 10 changed files with 47 additions and 0 deletions.
Binary file modified addons/sourcemod/plugins/confoglcompmod.smx
Binary file not shown.
Binary file modified addons/sourcemod/plugins/extend/join.smx
Binary file not shown.
Binary file modified addons/sourcemod/plugins/optional/slots_vote.smx
Binary file not shown.
31 changes: 31 additions & 0 deletions addons/sourcemod/scripting/AnneHappy/join.sp
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,17 @@ ConVar
hCvarMotdUrl,
hCvarEnableAutoupdate,
hCvarEnableInf,
g_cvSvAllowLobbyCo,
hCvarEnableAutoRemoveLobby,
hCvarIPUrl;


public void OnPluginStart()
{
hCvarEnableInf = CreateConVar("join_enable_inf", "1", "是否可以开启加入特感", _, true, 0.0, true, 1.0);
hCvarEnableAutoRemoveLobby = CreateConVar("join_enable_autoremovelobby", "0", "大厅满了是否自动删除大厅", _, true, 0.0, true, 1.0);
hCvarEnableAutoupdate = CreateConVar("join_autoupdate", "1", "是否开启AnneHappy核心插件自动更新(不常更新插件包的建议关闭)", _, true, 0.0, true, 3.0);
g_cvSvAllowLobbyCo = FindConVar("sv_allow_lobby_connect_only");
hCvarMotdTitle = CreateConVar("sm_cfgmotd_title", "AnneHappy电信服");
hCvarMotdUrl = CreateConVar("sm_cfgmotd_url", "http://dl.trygek.com/l4d_stats/index.php"); // 以后更换为数据库控制
hCvarIPUrl = CreateConVar("sm_cfgip_url", "http://dl.trygek.com/index.php"); // 以后更换为数据库控制
Expand Down Expand Up @@ -270,6 +274,13 @@ public void OnClientPutInServer(int client)
//ServerCommand("sm_addbot2");
CreateTimer(3.0, Timer_CheckDetay, client, TIMER_FLAG_NO_MAPCHANGE);
}

if(IsServerLobbyFull() && hCvarEnableAutoRemoveLobby.IntValue)
{
if(L4D_LobbyIsReserved())
L4D_LobbyUnreserve();
SetAllowLobby(0);
}

}

Expand Down Expand Up @@ -536,3 +547,23 @@ stock bool IsPinned(int client)
return bIsPinned;
}

bool IsServerLobbyFull() {
return GetConnectedPlayer() >= numSlots();
}

int numSlots() {
return LoadFromAddress(L4D_GetPointer(POINTER_SERVER) + view_as<Address>(L4D_GetServerOS() ? 380 : 384), NumberType_Int32);
}

int GetConnectedPlayer() {
int count = 0;
for (int i = 1; i <= MaxClients; i++) {
if (IsClientConnected(i) && !IsFakeClient(i))
count++;
}
return count;
}

void SetAllowLobby(int value) {
g_cvSvAllowLobbyCo.IntValue = value;
}
11 changes: 11 additions & 0 deletions addons/sourcemod/scripting/slots_vote.sp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <builtinvotes>
#include <colors>
#include <sourcemod>
#include <left4dhooks>

#define L4D2Team_Spectator 1

Expand Down Expand Up @@ -44,6 +45,12 @@ public Action SlotsRequest(int client, int args)
}
else
{
if(Int > numSlots())
{
if(L4D_LobbyIsReserved())
L4D_LobbyUnreserve();
SetConVarInt(FindConVar("sv_allow_lobby_connect_only"), 0);
}
if(client == 0)
{
//CPrintToChatAll("{blue}[{default}Slots{blue}] {olive}管理员 {default}将服务器位置设为 {blue}%i {default}个", Int);
Expand Down Expand Up @@ -160,3 +167,7 @@ public void CVarChanged(Handle cvar, char[] oldValue, char[] newValue)
{
MaxSlots = GetConVarInt(hMaxSlots);
}

stock int numSlots() {
return LoadFromAddress(L4D_GetPointer(POINTER_SERVER) + view_as<Address>(L4D_GetServerOS() ? 380 : 384), NumberType_Int32);
}
1 change: 1 addition & 0 deletions cfg/cfgogl/allcharger/shared_settings.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ confogl_addcvar l4d2_MITSR_Amount 2
//confogl_addcvar sm_cfgip_url "http://sb.trygek.com:8880/index.php"
confogl_addcvar join_enable_inf 0
confogl_addcvar join_autoupdate 1 //是否开启AnneHappy核心插件自动更新(不常更新插件包的建议关闭)
confogl_addcvar join_enable_autoremovelobby 1 //大厅满了是否自动删除大厅

// [slots_vote.smx]
confogl_addcvar slots_max_slots 16 //slots开位允许的最大数值(整数)
Expand Down
1 change: 1 addition & 0 deletions cfg/cfgogl/alone/shared_settings.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ confogl_addcvar shop_enable 1
//confogl_addcvar sm_cfgip_url "http://sb.trygek.com:8880/index.php"
confogl_addcvar join_enable_inf 0
confogl_addcvar join_autoupdate 1 //是否开启AnneHappy核心插件自动更新(不常更新插件包的建议关闭)
confogl_addcvar join_enable_autoremovelobby 1 //大厅满了是否自动删除大厅

// [slots_vote.smx]
confogl_addcvar slots_max_slots 16 //slots开位允许的最大数值(整数)
Expand Down
1 change: 1 addition & 0 deletions cfg/cfgogl/annehappy/shared_settings.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ confogl_addcvar l4d2_spit_godframe_ticks 4
//confogl_addcvar sm_cfgip_url "http://sb.trygek.com:8880/index.php"
confogl_addcvar join_enable_inf 0
confogl_addcvar join_autoupdate 1 //是否开启AnneHappy核心插件自动更新(不常更新插件包的建议关闭)
confogl_addcvar join_enable_autoremovelobby 1 //大厅满了是否自动删除大厅

// [slots_vote.smx]
confogl_addcvar slots_max_slots 16 //slots开位允许的最大数值(整数)
Expand Down
1 change: 1 addition & 0 deletions cfg/cfgogl/hunters/shared_settings.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ confogl_addcvar l4d2_MITSR_Amount 2
//confogl_addcvar sm_cfgip_url "http://sb.trygek.com:8880/index.php"
confogl_addcvar join_enable_inf 0
confogl_addcvar join_autoupdate 1 //是否开启AnneHappy核心插件自动更新(不常更新插件包的建议关闭)
confogl_addcvar join_enable_autoremovelobby 1 //大厅满了是否自动删除大厅

// [slots_vote.smx]
confogl_addcvar slots_max_slots 16 //slots开位允许的最大数值(整数)
Expand Down
1 change: 1 addition & 0 deletions cfg/cfgogl/witchparty/shared_settings.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ confogl_addcvar l4d2_MITSR_Amount 2
//confogl_addcvar sm_cfgip_url "http://sb.trygek.com:8880/index.php"
confogl_addcvar join_enable_inf 0
confogl_addcvar join_autoupdate 1 //是否开启AnneHappy核心插件自动更新(不常更新插件包的建议关闭)
confogl_addcvar join_enable_autoremovelobby 1 //大厅满了是否自动删除大厅

// [slots_vote.smx]
confogl_addcvar slots_max_slots 16 //slots开位允许的最大数值(整数)
Expand Down

0 comments on commit d6436ae

Please sign in to comment.