diff --git a/fastdl-rotator/scripting/fastdl_rotater.sp b/fastdl-rotator/scripting/fastdl_rotater.sp index 914e483..1426f1d 100644 --- a/fastdl-rotator/scripting/fastdl_rotater.sp +++ b/fastdl-rotator/scripting/fastdl_rotater.sp @@ -150,12 +150,12 @@ public void OnMapEnd() public void Cvar_backupurl1(ConVar convar, const char[] oldValue, const char[] newValue) { - convar.SetString(newValue); + convar.SetString(g_cBackupURLS[0]); } public void Cvar_backupurl2(ConVar convar, const char[] oldValue, const char[] newValue) { - convar.SetString(newValue); + convar.SetString(g_cBackupURLS[1]); } public void OnConfigsExecuted() @@ -174,35 +174,36 @@ public MRESReturn sendServerInfoDetCallback_Pre(Address pointer, Handle hReturn, public MRESReturn buildConVarMessageDetCallback_Pre(Handle hParams) //Second callback { - if ((g_icurrentClient == 0 || g_icurrentClient > MaxClients)) return MRES_Ignored; - - char clientIPAddress[64]; //IP of the connecting client - GetClientIP(g_icurrentClient, clientIPAddress, sizeof(clientIPAddress)); - - for (int i = 0; i < sizeof(g_cIPaddresses); i++) + if (g_icurrentClient > 0 && g_icurrentClient <= MaxClients && IsClientConnected(g_icurrentClient) && IsClientInGame(g_icurrentClient)) { - if (StrEqual(g_cIPaddresses[i], clientIPAddress)) + char clientIPAddress[64]; //IP of the connecting client + GetClientIP(g_icurrentClient, clientIPAddress, sizeof(clientIPAddress)); + + for (int i = 0; i < sizeof(g_cIPaddresses); i++) { - int rotated = -1; - g_SteamIDRotations.GetValue(clientIPAddress, rotated); - - //0 = hetzner nide. 1 = ovh uk unloze. 2 = default sv_downloadurl again. so not overwriting anything - 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. - while (rotated < sizeof(g_cBackupURLS) && !g_bDoesIndexHaveBZ2[rotated]) + if (StrEqual(g_cIPaddresses[i], clientIPAddress)) { - rotated++; + int rotated = -1; + g_SteamIDRotations.GetValue(clientIPAddress, rotated); + + //0 = hetzner nide. 1 = ovh uk unloze. 2 = default sv_downloadurl again. so not overwriting anything + 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. + while (rotated < sizeof(g_cBackupURLS) && !g_bDoesIndexHaveBZ2[rotated]) + { + rotated++; + } + if (rotated < sizeof(g_cBackupURLS)) + { + char map[256]; + GetCurrentMap(map, sizeof(map)); + 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]); + setConVarValue(g_cBackupURLS[rotated]); + } + break; } - if (rotated < sizeof(g_cBackupURLS)) - { - char map[256]; - GetCurrentMap(map, sizeof(map)); - 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]); - setConVarValue(g_cBackupURLS[rotated]); - } - break; } } return MRES_Ignored;