public bool SpamAlert(coGameConnection client) { if (!bGlobal["$Pref::Server::FloodProtectionEnabled"]) { return(false); } if (!client["isSpamming"].AsBool() && client["spamMessageCount"].AsInt() >= iGlobal["$SPAM_MESSAGE_THRESHOLD"]) { console.error("Client " + client + " is spamming, message count = " + client["spamMessageCount"]); client["spamProtectStart"] = console.getSimTime().AsString(); client["isSpamming"] = true.AsString(); client.schedule(console.GetVarString("$SPAM_PENALTY_PERIOD"), "spamReset"); } if (client["isSpamming"].AsBool()) { double wait = Math.Floor((console.GetVarInt("$SPAM_PENALTY_PERIOD") - (console.getSimTime() - client["spamProtectStart"].AsDouble()) / 1000)); MessageClient(client, "", sGlobal["$SPAM_MESSAGE"], wait.AsString()); return(true); } client["spamMessageCount"] = (client["spamMessageCount"].AsInt() + 1).AsString(); client.schedule(sGlobal["$SPAM_PROTECTION_PERIOD"], "spamMessageTimeout"); return(false); }