Commit 61174dd0 authored by Neoony's avatar Neoony
Browse files

-v0.4.1 -Added SteamWorks, to be able to detect server public ip -Some changes...

-v0.4.1 -Added SteamWorks, to be able to detect server public ip -Some changes for upcoming change of hosting -Small bugfix
parent f12bbc0c
Pipeline #10769 passed with stages
in 6 minutes and 52 seconds
......@@ -87,4 +87,9 @@
- 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
- Added return Plugin_Handled to commands
**v0.4.1**
- Added SteamWorks, to be able to detect server public ip
- Some changes for upcoming change of hosting
- Small bugfix
\ No newline at end of file
......@@ -24,6 +24,10 @@ https://forums.alliedmods.net/showthread.php?t=152216
+ SM 1.10.0 include files: https://github.com/JoinedSenses/SourceMod-IncludeLibrary/
**This is included with the plugin.**
**SteamWorks** Extension:
https://forums.alliedmods.net/showthread.php?t=229556
**This is included with the plugin.**
--
**Console Commands:**
**"sm_discord"**
......@@ -59,7 +63,7 @@ https://forums.alliedmods.net/showthread.php?t=152216
**"l_minplayersext"** *"def. 8"*
*"How many players needed on external server / active server. (Players)"*
**"l_votetimer"** *"def.30"*
**"l_votetimer"** *"def. 30"*
*"How long to keep the vote for (Seconds)"*
**"l_threshold"** *"def. 50"*
......
......@@ -21,8 +21,9 @@
//#include <emputils>
#include <socket>
#include <cURL>
#include <SteamWorks>
#define PluginVer "v0.4"
#define PluginVer "v0.4.1"
public Plugin myinfo =
{
......@@ -162,6 +163,15 @@ int BotsOnHowMany = 0;
Handle BotsVoteTimer = INVALID_HANDLE;
bool BotsVoteTimerOn = false;
//Get public ip
enum struct ServerData {
int id[11];
char ip[64];
char port[16];
}
ServerData serverData;
public void OnPluginStart()
{
//LoadTranslations("common.phrases");
......@@ -499,7 +509,7 @@ public Action SCommand_LOneTimeForceRedirect(int args)
for (int client = 1; client <= MaxClients; client++)
{
if (IsClientConnected(client) & IsClientInGame(client))
if (IsClientConnected(client) && IsClientInGame(client) && IsClientSourceTV(client) == false && IsFakeClient(client) == false)
{
PrintToChat(client, "[L] You have been redirected");
ClientCommand(client, "lobby_redirect %s", full);
......@@ -514,35 +524,38 @@ public Action SCommand_LOneTimeForceRedirect(int args)
public void ForceRedirectSingle(int Client)
{
if (GetConVarInt(l_fastconnecttest) == 0)
if (IsClientConnected(Client) && IsClientInGame(Client) && IsClientSourceTV(Client) == false && IsFakeClient(Client) == false)
{
GetConVarString(l_forceredirect, ForceRedirectAddr, sizeof(ForceRedirectAddr));
if (GetConVarInt(l_debug) == 1)
if (GetConVarInt(l_fastconnecttest) == 0)
{
PrintToServer("[L] Force Redirecting single client %i", Client);
GetConVarString(l_forceredirect, ForceRedirectAddr, sizeof(ForceRedirectAddr));
if (GetConVarInt(l_debug) == 1)
{
PrintToServer("[L] Force Redirecting single client %i", Client);
}
PrintToChat(Client, "[L] You have been redirected");
ClientCommand(Client, "lobby_redirect %s", ForceRedirectAddr);
}
PrintToChat(Client, "[L] You have been redirected");
ClientCommand(Client, "lobby_redirect %s", ForceRedirectAddr);
}
if (GetConVarInt(l_fastconnecttest) == 1)
{
GetConVarString(l_forceredirect, ForceRedirectAddr, sizeof(ForceRedirectAddr));
if (GetConVarInt(l_debug) == 1)
if (GetConVarInt(l_fastconnecttest) == 1)
{
PrintToServer("[L] Force Redirecting single client %i", Client);
GetConVarString(l_forceredirect, ForceRedirectAddr, sizeof(ForceRedirectAddr));
if (GetConVarInt(l_debug) == 1)
{
PrintToServer("[L] Force Redirecting single client %i", Client);
}
PrintToChat(Client, "[L] You have been redirected");
ClientCommand(Client, "disconnect; lobby_redirect %s", ForceRedirectAddr);
}
PrintToChat(Client, "[L] You have been redirected");
ClientCommand(Client, "disconnect; lobby_redirect %s", ForceRedirectAddr);
}
if (GetConVarInt(l_fastconnecttest) == 2)
{
GetConVarString(l_forceredirect, ForceRedirectAddr, sizeof(ForceRedirectAddr));
if (GetConVarInt(l_debug) == 1)
if (GetConVarInt(l_fastconnecttest) == 2)
{
PrintToServer("[L] Force Redirecting single client %i", Client);
GetConVarString(l_forceredirect, ForceRedirectAddr, sizeof(ForceRedirectAddr));
if (GetConVarInt(l_debug) == 1)
{
PrintToServer("[L] Force Redirecting single client %i", Client);
}
PrintToChat(Client, "[L] You have been redirected");
ClientCommand(Client, "lobby_redirect %s; disconnect", ForceRedirectAddr);
}
PrintToChat(Client, "[L] You have been redirected");
ClientCommand(Client, "lobby_redirect %s; disconnect", ForceRedirectAddr);
}
}
......@@ -551,7 +564,7 @@ public void ForceRedirectAll()
GetConVarString(l_forceredirect, ForceRedirectAddr, sizeof(ForceRedirectAddr));
for (int client = 1; client <= MaxClients; client++)
{
if (IsClientConnected(client) & IsClientInGame(client))
if (IsClientConnected(client) && IsClientInGame(client) && IsClientSourceTV(client) == false && IsFakeClient(client) == false)
{
PrintToChat(client, "[L] You have been redirected");
ClientCommand(client, "lobby_redirect %s", ForceRedirectAddr);
......@@ -565,35 +578,38 @@ public void ForceRedirectAll()
public void BackupRedirectSingle(int Client)
{
if (GetConVarInt(l_fastconnecttest) == 0)
if (IsClientConnected(Client) && IsClientInGame(Client) && IsClientSourceTV(Client) == false && IsFakeClient(Client) == false)
{
GetConVarString(l_backupserver, BackupServerAddr, sizeof(BackupServerAddr));
if (GetConVarInt(l_debug) == 1)
if (GetConVarInt(l_fastconnecttest) == 0)
{
PrintToServer("[L] Redirecting single client %i to a Backup Server", Client);
GetConVarString(l_backupserver, BackupServerAddr, sizeof(BackupServerAddr));
if (GetConVarInt(l_debug) == 1)
{
PrintToServer("[L] Redirecting single client %i to a Backup Server", Client);
}
PrintToChat(Client, "[L] You have been redirected");
ClientCommand(Client, "lobby_redirect %s", BackupServerAddr);
}
PrintToChat(Client, "[L] You have been redirected");
ClientCommand(Client, "lobby_redirect %s", BackupServerAddr);
}
if (GetConVarInt(l_fastconnecttest) == 1)
{
GetConVarString(l_backupserver, BackupServerAddr, sizeof(BackupServerAddr));
if (GetConVarInt(l_debug) == 1)
if (GetConVarInt(l_fastconnecttest) == 1)
{
PrintToServer("[L] Redirecting single client %i to a Backup Server", Client);
GetConVarString(l_backupserver, BackupServerAddr, sizeof(BackupServerAddr));
if (GetConVarInt(l_debug) == 1)
{
PrintToServer("[L] Redirecting single client %i to a Backup Server", Client);
}
PrintToChat(Client, "[L] You have been redirected");
ClientCommand(Client, "disconnect; lobby_redirect %s", BackupServerAddr);
}
PrintToChat(Client, "[L] You have been redirected");
ClientCommand(Client, "disconnect; lobby_redirect %s", BackupServerAddr);
}
if (GetConVarInt(l_fastconnecttest) == 2)
{
GetConVarString(l_backupserver, BackupServerAddr, sizeof(BackupServerAddr));
if (GetConVarInt(l_debug) == 1)
if (GetConVarInt(l_fastconnecttest) == 2)
{
PrintToServer("[L] Redirecting single client %i to a Backup Server", Client);
GetConVarString(l_backupserver, BackupServerAddr, sizeof(BackupServerAddr));
if (GetConVarInt(l_debug) == 1)
{
PrintToServer("[L] Redirecting single client %i to a Backup Server", Client);
}
PrintToChat(Client, "[L] You have been redirected");
ClientCommand(Client, "lobby_redirect %s; disconnect", BackupServerAddr);
}
PrintToChat(Client, "[L] You have been redirected");
ClientCommand(Client, "lobby_redirect %s; disconnect", BackupServerAddr);
}
}
......@@ -602,7 +618,7 @@ public void BackupRedirectAll()
GetConVarString(l_backupserver, BackupServerAddr, sizeof(BackupServerAddr));
for (int client = 1; client <= MaxClients; client++)
{
if (IsClientConnected(client) & IsClientInGame(client))
if (IsClientConnected(client) && IsClientInGame(client) && IsClientSourceTV(client) == false && IsFakeClient(client) == false)
{
PrintToChat(client, "[L] You have been redirected");
ClientCommand(client, "lobby_redirect %s", BackupServerAddr);
......@@ -628,7 +644,6 @@ public Action BackupRedirectTmr(Handle timer)
BackupRedirectAll();
}
public void CheckPopulatedServersSinglePlayer(int Client)
{
if (hDatabase != null)
......@@ -661,6 +676,7 @@ public void CheckPopulatedServersSinglePlayer(int Client)
PrintToServer("[L] Need to query, but db is down");
}
}
public void RedirectToPopulatedServerSinglePlayerCallback(Handle hDriver, Handle hResult, const char[] sError, int Client)
{
if (hResult == INVALID_HANDLE)
......@@ -697,32 +713,35 @@ public void RedirectToPopulatedServerSinglePlayerCallback(Handle hDriver, Handle
if(IsVoteInProgress() == false)
{
if (GetConVarInt(l_fastconnecttest) == 0)
if (IsClientConnected(Client) && IsClientInGame(Client) && IsClientSourceTV(Client) == false && IsFakeClient(Client) == false)
{
if (GetConVarInt(l_debug) == 1)
if (GetConVarInt(l_fastconnecttest) == 0)
{
PrintToServer("[L] Redirecting single client %i", Client);
if (GetConVarInt(l_debug) == 1)
{
PrintToServer("[L] Redirecting single client %i", Client);
}
PrintToChat(Client, "[L] You have been redirected");
ClientCommand(Client, "lobby_redirect %s", redirectAddressSP);
}
PrintToChat(Client, "[L] You have been redirected");
ClientCommand(Client, "lobby_redirect %s", redirectAddressSP);
}
if (GetConVarInt(l_fastconnecttest) == 1)
{
if (GetConVarInt(l_debug) == 1)
if (GetConVarInt(l_fastconnecttest) == 1)
{
PrintToServer("[L] Redirecting single client %i method 1", Client);
if (GetConVarInt(l_debug) == 1)
{
PrintToServer("[L] Redirecting single client %i method 1", Client);
}
PrintToChat(Client, "[L] You have been redirected");
ClientCommand(Client, "disconnect; lobby_redirect %s", redirectAddressSP);
}
PrintToChat(Client, "[L] You have been redirected");
ClientCommand(Client, "disconnect; lobby_redirect %s", redirectAddressSP);
}
if (GetConVarInt(l_fastconnecttest) == 2)
{
if (GetConVarInt(l_debug) == 1)
if (GetConVarInt(l_fastconnecttest) == 2)
{
PrintToServer("[L] Redirecting single client %i method 2", Client);
if (GetConVarInt(l_debug) == 1)
{
PrintToServer("[L] Redirecting single client %i method 2", Client);
}
PrintToChat(Client, "[L] You have been redirected");
ClientCommand(Client, "lobby_redirect %s; disconnect", redirectAddressSP);
}
PrintToChat(Client, "[L] You have been redirected");
ClientCommand(Client, "lobby_redirect %s; disconnect", redirectAddressSP);
}
}
}
......@@ -829,7 +848,7 @@ public Action PopulatedRedirectTmr(Handle timer)
PrintToChatAll("\x04[L] \x01\x07008000Redirecting\x01 players...");
for (int client = 1; client <= MaxClients; client++)
{
if (IsClientConnected(client) & IsClientInGame(client))
if (IsClientConnected(client) && IsClientInGame(client) && IsClientSourceTV(client) == false && IsFakeClient(client) == false)
{
PrintToChat(client, "[L] You have been redirected");
ClientCommand(client, "lobby_redirect %s", redirectAddress);
......@@ -1199,11 +1218,33 @@ public void OnConfigsExecuted()
{
PrintToServer("[L] Hostname: %s", hostname);
}
if (StrEqual(hostname, "Empires Backup Lobby") == true)
char serverIp[64];
char serverPort[10];
int ipaddr[4];
SteamWorks_GetPublicIP(ipaddr);
Format(serverIp, sizeof(serverIp), "%d.%d.%d.%d",ipaddr[0], ipaddr[1], ipaddr[2], ipaddr[3]);
strcopy(serverData.ip, sizeof(serverData.ip), serverIp);
GetConVarString(FindConVar("hostport"), serverPort, sizeof(serverPort));
strcopy(serverData.port, sizeof(serverData.port), serverPort);
if (GetConVarInt(l_debug) == 1)
{
PrintToServer("%s", serverData.ip);
PrintToServer("%s", serverData.port);
}
//Empires Backup Lobby disabled (by adding Vanilla at the end of hostname)
//I guess Vanilla should no longer happen
if (StrEqual(hostname, "Empires Backup Lobby Vanilla") == true)
{
VanillaLocal = true;
}
if (StrEqual(hostname, "Empires Lobby") == true)
//Detect if lobby is local to europires
if (StrEqual(serverData.ip, "185.165.242.40") == true)
{
EuropiresLocal = true;
}
......@@ -1252,13 +1293,11 @@ public void OnClientDisconnect(int Client)
if (BotsOffClient[Client] == 1)
{
BotsOffHowMany--;
PrintToServer("%i", BotsOffHowMany);
BotsOffClient[Client] = 0;
}
if (BotsOnClient[Client] == 1)
{
BotsOnHowMany--;
PrintToServer("%i", BotsOnHowMany);
BotsOnClient[Client] = 0;
}
}
......@@ -1977,7 +2016,7 @@ public Action StartConnectDialog(int param1)
for (int client = 1; client <= MaxClients; client++)
{
if (IsClientInGame(client))
if (IsClientConnected(client) && IsClientInGame(client) && IsClientSourceTV(client) == false && IsFakeClient(client) == false)
{
PrintToChat(client, "[L] You have been redirected");
ClientCommand(client, "lobby_redirect %s", addrx[param1]);
......
This diff is collapsed.
......@@ -4,14 +4,12 @@
{
"Version"
{
"Latest" "v0.4"
"Latest" "v0.4.1"
}
"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"
"Notes" "Added SteamWorks, to be able to detect server public ip"
"Notes" "Some changes for upcoming change of hosting"
"Notes" "Small bugfix"
}
"Files"
......@@ -22,10 +20,13 @@
"Plugin" "Path_Mod/addons/sourcemod/extensions/curl.ext.so"
"Plugin" "Path_Mod/addons/sourcemod/extensions/socket.ext.dll"
"Plugin" "Path_Mod/addons/sourcemod/extensions/socket.ext.so"
"Plugin" "Path_Mod/addons/sourcemod/extensions/SteamWorks.ext.dll"
"Plugin" "Path_Mod/addons/sourcemod/extensions/SteamWorks.ext.so"
"Source" "Path_Mod/addons/sourcemod/scripting/Lobby.sp"
"Source" "Path_Mod/addons/sourcemod/scripting/include/socket.inc"
"Source" "Path_Mod/addons/sourcemod/scripting/include/cURL.inc"
"Source" "Path_Mod/addons/sourcemod/scripting/include/cURL_header.inc"
"Source" "Path_Mod/addons/sourcemod/scripting/include/SteamWorks.inc"
}
}
\ No newline at end of file
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