Add Server hostname and ip in all tables in case plugin might be used on multiple servers
Just in case this plugin could be used on multiple servers in the future, you might need to add Hostname and IP to tables, which might be useful.
To detect hostname:
https://sm.alliedmods.net/new-api/convars/GetConVarString
SetConVarString(Hostname, buffer);
Since hostname might change, you might also need IP.
To get the public IP is a bit tricky, I use it in Lobby plugin, but you need steamworks extension.
Official steamworks download: https://github.com/KyleSanderson/SteamWorks/releases
Or version I use on Lobby:
Steamworks: https://git.empiresmod.com/sourcemod/Lobby/-/tree/master/addons/sourcemod/extensions
Steamworks include: https://git.empiresmod.com/sourcemod/Lobby/-/tree/master/addons/sourcemod/scripting/include
Code from Lobby (you could probably simplify it) (I hope I did not miss anything):
#include <SteamWorks>
//Get public ip declare
enum struct ServerData {
int id[11];
char ip[64];
char port[16];
}
ServerData serverData;
char serverIp[64];
char serverPort[10];
int ipaddr[4];
//Get public ip
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);
}