redid some comments but most importantly removed IsClientInGame check as it would not get through the condition
This commit is contained in:
parent
2609a4534f
commit
f62cc2bb40
@ -30,15 +30,17 @@ public void OnPluginStart()
|
|||||||
{
|
{
|
||||||
g_SteamIDRotations = new StringMap();
|
g_SteamIDRotations = new StringMap();
|
||||||
ConVar cvar;
|
ConVar cvar;
|
||||||
HookConVarChange((cvar = CreateConVar("sm_first_backup_fastdl_url", "https://fastdl.nide.gg/css_ze/", "the first backup fastdl URL")), Cvar_backupurl1);
|
HookConVarChange((cvar = CreateConVar("sm_first_backup_fastdl_url", "https://uk-fastdl.unloze.com/css_ze/", "the first backup fastdl URL")), Cvar_backupurl1);
|
||||||
cvar.GetString(g_cBackupURLS[0], sizeof(g_cBackupURLS[]));
|
cvar.GetString(g_cBackupURLS[0], sizeof(g_cBackupURLS[]));
|
||||||
delete cvar;
|
delete cvar;
|
||||||
|
|
||||||
ConVar cvar1;
|
ConVar cvar1;
|
||||||
HookConVarChange((cvar1 = CreateConVar("sm_second_backup_fastdl_url", "http://uk-fastdl.unloze.com/css_ze/", "the second backup fastdl URL")), Cvar_backupurl2);
|
HookConVarChange((cvar1 = CreateConVar("sm_second_backup_fastdl_url", "https://uk-fastdl.unloze.com/css_ze/", "the second backup fastdl URL")), Cvar_backupurl2);
|
||||||
cvar1.GetString(g_cBackupURLS[1], sizeof(g_cBackupURLS[]));
|
cvar1.GetString(g_cBackupURLS[1], sizeof(g_cBackupURLS[]));
|
||||||
delete cvar1;
|
delete cvar1;
|
||||||
|
|
||||||
|
//we only use one backup fastdl but you could potentially have several.
|
||||||
|
|
||||||
downloadurl = FindConVar("sv_downloadurl"); //Save original downloadurl, so we can send it to clients who we cant locate
|
downloadurl = FindConVar("sv_downloadurl"); //Save original downloadurl, so we can send it to clients who we cant locate
|
||||||
downloadurl.GetString(originalConVar, sizeof(originalConVar));
|
downloadurl.GetString(originalConVar, sizeof(originalConVar));
|
||||||
|
|
||||||
@ -174,8 +176,9 @@ public MRESReturn sendServerInfoDetCallback_Pre(Address pointer, Handle hReturn,
|
|||||||
|
|
||||||
public MRESReturn buildConVarMessageDetCallback_Pre(Handle hParams) //Second callback
|
public MRESReturn buildConVarMessageDetCallback_Pre(Handle hParams) //Second callback
|
||||||
{
|
{
|
||||||
if (g_icurrentClient > 0 && g_icurrentClient <= MaxClients && IsClientConnected(g_icurrentClient) && IsClientInGame(g_icurrentClient))
|
if (g_icurrentClient > 0 && g_icurrentClient <= MaxClients && IsClientConnected(g_icurrentClient))
|
||||||
{
|
{
|
||||||
|
//LogMessage("client %N in buildConVarMessageDetCallback_Pre", g_icurrentClient);
|
||||||
char clientIPAddress[64]; //IP of the connecting client
|
char clientIPAddress[64]; //IP of the connecting client
|
||||||
GetClientIP(g_icurrentClient, clientIPAddress, sizeof(clientIPAddress));
|
GetClientIP(g_icurrentClient, clientIPAddress, sizeof(clientIPAddress));
|
||||||
|
|
||||||
@ -186,10 +189,10 @@ public MRESReturn buildConVarMessageDetCallback_Pre(Handle hParams) //Second cal
|
|||||||
int rotated = -1;
|
int rotated = -1;
|
||||||
g_SteamIDRotations.GetValue(clientIPAddress, rotated);
|
g_SteamIDRotations.GetValue(clientIPAddress, rotated);
|
||||||
|
|
||||||
//0 = hetzner nide. 1 = ovh uk unloze. 2 = default sv_downloadurl again. so not overwriting anything
|
//0 = ovh uk unloze. 1 = ovh uk unloze. 2 = default sv_downloadurl again. so not overwriting anything
|
||||||
rotated = rotated % 3;
|
rotated = rotated % 3;
|
||||||
|
|
||||||
//the bz2 file does not exist on the backup urls so rotate to the next working one. for example hetzner nide might not have but ovh uk has.
|
//the bz2 file does not exist on the backup urls so rotate to the next working one.
|
||||||
while (rotated < sizeof(g_cBackupURLS) && !g_bDoesIndexHaveBZ2[rotated])
|
while (rotated < sizeof(g_cBackupURLS) && !g_bDoesIndexHaveBZ2[rotated])
|
||||||
{
|
{
|
||||||
rotated++;
|
rotated++;
|
||||||
@ -199,7 +202,7 @@ public MRESReturn buildConVarMessageDetCallback_Pre(Handle hParams) //Second cal
|
|||||||
char map[256];
|
char map[256];
|
||||||
GetCurrentMap(map, sizeof(map));
|
GetCurrentMap(map, sizeof(map));
|
||||||
g_SteamIDRotations.SetValue(clientIPAddress, rotated, true); //adapting in case of increment.
|
g_SteamIDRotations.SetValue(clientIPAddress, rotated, true); //adapting in case of increment.
|
||||||
LogMessage("client %N had missing map with cloudflare on %s. using %s instead.", g_icurrentClient, map, g_cBackupURLS[rotated]);
|
LogMessage("client %N had missing map with default sv_downloadurl on %s. using %s instead.", g_icurrentClient, map, g_cBackupURLS[rotated]);
|
||||||
setConVarValue(g_cBackupURLS[rotated]);
|
setConVarValue(g_cBackupURLS[rotated]);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user