Add identity-safe player moderation runtimes for T5 and T6
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
/* TWS moderation 1.0.0: native durable policy, connection-safe actions, HTTPS synchronization. */
|
||||
#include maps\_utility;
|
||||
#include common_scripts\utility;
|
||||
|
||||
init()
|
||||
{
|
||||
if (GetDvar(#"zombiemode") != "1")
|
||||
return;
|
||||
scripts\sp\tws_t5_common::ensure_config();
|
||||
level.moderation_ready = false;
|
||||
scripts\sp\tws_t5_common::register_connect_handler(::moderation_connected);
|
||||
level thread moderation_loop();
|
||||
}
|
||||
|
||||
moderation_connected()
|
||||
{
|
||||
self endon("disconnect");
|
||||
if (!level.moderation_ready)
|
||||
return;
|
||||
moderation_observe(self);
|
||||
moderationPump();
|
||||
}
|
||||
|
||||
moderation_observe(player)
|
||||
{
|
||||
if (!isDefined(player))
|
||||
return;
|
||||
guid = player getGuid();
|
||||
if (!isDefined(guid) || (typeof(guid) != "string" && typeof(guid) != "int"))
|
||||
return;
|
||||
// Preserve large identifiers as strings; native validation rejects ambiguous inputs.
|
||||
guid = "" + guid;
|
||||
name = player.name;
|
||||
if (!isDefined(name))
|
||||
name = "Unknown player";
|
||||
player moderationObserve(guid, name);
|
||||
}
|
||||
|
||||
moderation_loop()
|
||||
{
|
||||
for (;;)
|
||||
{
|
||||
if (GetDvar("tws_moderation_enabled") == "0")
|
||||
{
|
||||
moderationStop();
|
||||
level.moderation_ready = false;
|
||||
wait 3;
|
||||
continue;
|
||||
}
|
||||
level.moderation_ready = moderationConfigure(GetDvar("tws_server_id"), GetDvar("tws_moderation_url"),
|
||||
GetDvar("tws_moderation_token"), GetDvarInt("tws_moderation_generation"));
|
||||
if (!level.moderation_ready)
|
||||
{
|
||||
wait 3;
|
||||
continue;
|
||||
}
|
||||
players = getPlayers();
|
||||
for (i = 0; i < players.size; i++)
|
||||
moderation_observe(players[i]);
|
||||
moderationPump();
|
||||
wait 0.5;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user