DiscordAPI - ZenarchistCode/ZenModPack GitHub Wiki

raid_alarm

What Is This?

This mod includes a whole bunch of Discord integration functionality - ranging from a Raid Alarm for players to use, to kill feeds and admin tools for moderators to use.

The raid alarm can be built and managed by players in-game to send Webhook messages to their own Discord channels.

Click here to view a video guide of how to set the raid alarm up: https://youtu.be/fgJRFBte8SQ

It was obviously inspired by Daemonforge's Raid Alarm mod, but this mod was built from scratch and does not use any of his code or his Universal API - it's purely standalone.

It comes with some basic chat commands as well - such as !admin to send a Discord message to the server's Discord to notify admins of a request for help (or bug report / player report etc - any text after "!admin Example text message" will be relayed to Discord), as well as a !tele X Y command to teleport the admins to a location on the map.

The chat commands are easily moddable by overriding this class:

modded class ZenAdminMessagePlugin
{
    // Process regular civilian commands
    override bool ProcessCommand(notnull PlayerBase player, string command, string text, array<string> params)
    {
        if (command == "example")
        {
            // do something
            Print(params.Get(0)); // Print the first parameter the player sent (each space represents a new parameter)
            Print(text); // Print the text sent by the player (includes ALL parameters as one text string)
            return true; // Tell the game we handled this command - don't relay it back to regular public chat!
        }

        return false;
    }

    // Process admin commands
    override bool ProcessAdminCommand(notnull PlayerBase player, string command, string text, array<string> params)
    {
        // Works the same as above, but only admin commands are handled by this method (admin IDs defined in the JSON config)
    }
}

Discord API

The mod comes with a rudimentary discord API built into it which makes it really easy for you to send Discord messages to a list of webhook(s) whenever you want, using a simple-to-use JSON object builder.

Here is an example of how to build your own Discord message with your own mods (obviously doing this will require this @ZenDiscordAPI or @ZenModPack mod as a dependency):

ZenDiscordMessage msg = new ZenDiscordMessage("Webhook Username");
msg.SetTitle("Message Title");
msg.SetMessage("Text to send - [add links](www.likethis.com)");
msg.SetFooter("Some footer to put at bottom of message");
msg.SetColor(255, 0, 0); // Color (Red, Green, Blue 0-255)
msg.AddWebhooks(GetZenDiscordConfig().AdminWebhooks); // A TStringArray/array<string> of webhooks
GetZenDiscordAPI().SendMessage(msg); // Send the built message to the webhooks

JSON Config

This mod comes with a detailed JSON config which will be automatically created in %server_profile%/Zenarchist/Utilities/ZenDiscordConfig.json

I included a bunch of text options for multi-language support - just replace the English messages with your language.

{
    "CONFIG_VERSION": "1", // Don't touch
    "AdminUIDs": [ // Admin UIDs in here
        "4s_12UDE-PKYemc7adlZyKGVSrwzIMW0T32Q69CerkE="
    ],
    "AdminWebhooks": [ // Admin discord channel webhooks go here (multiple allowed)
        "https://discord.com/api/webhooks/1263661792194728040/AEWqPnfHW8h8sIJuFBKsjW1mtOHFANXtWQVh3oquwcevG0aO2CyowmP4IQuKLqOFHJno"
    ],
    "KillFeedWebhooks": [ // Kill feed webhooks go here (multiple allowed)
        "https://discord.com/api/webhooks/1263661792194728040/AEWqPnfHW8h8sIJuFBKsjW1mtOHFANXtWQVh3oquwcevG0aO2CyowmP4IQuKLqOFHJno"
    ],
    "ServerName": "HardcoreDayZ", // Your server name
    "PingAdminCommand": "admin", // The command to ping an admin in-game (type "!admin" in chat)
    "MessageReceived": "Your message has been successfully relayed to the admins. Please be patient for their response.", // The message sent to the player when using PingAdminCommand
    "JustLoggedIn": "just logged in to", // Used for admin discord
    "Explanation": "A player on your watchlist just connected.", // Used for admin discord
    "KillFeed": "Killfeed", // Used for kill feed
    "Killed": "killed", // Used for kill feed
    "With": "with", // Used for kill feed
    "Melee": "melee", // Used for kill feed
    "KillerAge": "Killer Age", // Used for kill feed
    "VictimAge": "Victim Age", // Used for kill feed
    "Minutes": "minutes", // Used for kill feed
    "Hours": "hours", // Used for kill feed
    "EnableDiscordKillFeed": 1, // Used for kill feed
    "DisplayKillLocation": 1, // Used for kill feed
    "DisplayPlayerSteamID": 1, // Used for kill feed
    "TriggerAdminRaidAlert": 1, // Trigger a message to admin discord whenever a raid is detected
    "MapURL": "https://www.izurvive.com/livoniaSat/", // The Map url for your world (includes link to position in discord messages)
    "RaidAlarmRequiresTerritory": 1, // Setting up raid alarms requires a territory? 0/1
    "RaidRadarDishInvincible": 0, // Radar dishes are invulnerable? 0/1
    "RaidRadarDishCheckRoofTimerMinutes": 30, // How often to check for a roof above the radar dish (set to 0 to only check on restarts, set to -1 to disable)
    "RaidDetectionDistance": 150, // How far from the raid station can a raid be detected
    "RaidAlarmResetInMinutes": 5.0, // How long it takes for a raid alarm sound effect to expire
    "RaidPlaySound": 1, // Turn on/off raid sound (0/1)
    "RaidDiscordAlertRequiresRadar": 1, // If set to 0, then raid alarms are sent to player discord without a radar dish attached
    "RaidDiscordAlertCooldownSecs": 1, // This is the minimum time in seconds between player discord alerts (prevents spamming on/off etc)
    "RaidAlarmMessageTitle": "RAID ALARM", // This gets sent to player discord
    "RaidAlarmAttackMessage": "Your base is under attack!", // This gets sent to player discord
    "RaidAlarmWebhookUpdate": "Raid alarm configuration has been changed.", // This gets sent to player discord
    "RaidAlarmConnectionOnline": "Connection established - monitoring for raid activity.", // This gets sent to player discord
    "RaidAlarmConnectionOffline": "Connection lost - raid activity is no longer being monitored.", // This gets sent to player discord
    "RaidAlarmRequiresTerritoryText": "You need to be the member of a territory to set up this raid alarm!", // This gets sent to player discord
    "RaidAlarmTooClose": "This raid alarm is too close to an existing raid alarm!", // This gets sent to player discord
    "RaidAlarmBatteryWarning": "Battery Charge", // This gets sent to player discord
    "BaseDamageTriggersRaidAlert": 1, // Enable/disable BasebuildingBase object damage triggering raid alarm
    "BaseDismantleTriggersRaidAlert": 1, // Enable/disable non-territory members dismantling BasebuildingBase objects triggering raid alarm
    "ItemsDeployedTriggerRaidAlert": [ // If any of these items are deployed it will trigger the raid alarm (MUST match classname or base type, case doesn't matter)
        "HDSN_BreachingChargeBase",
        "expansionsatchel",
        "plastic_explosive"
    ],
    "RequireAnItemForIngameAlert": 0, // Turn on/off the requirement to have any of the following items in your inventory to receive in-game raid alerts (the number = 1/0 means whether or not the item should have a working battery or not)
    "ItemsRequiredForIngameAlert": {
        "itempda": 1,
        "baseradio": 1,
        "personalradio": 1
    },
    "PlayerWatchlist": { // A watchlist of player IDs to be notified in admin discord when they log in to your server
        "4s_12UDE-PKYemc7adlZyKGVSrwzIMW0T32Q69CerkE=": "Example reason they're on watchlist - potential cheater, accused by multiple players etc"
    }
}

Types.xml

    <!-- Discord raid alarm -->
    <type name="Zen_RaidAlarmStation">
        <lifetime>1209600</lifetime>
        <flags count_in_cargo="0" count_in_hoarder="0" count_in_map="1" count_in_player="0" crafted="1" deloot="0"/>
    </type>
	<type name="Zen_RaidAlarmRadar">
        <lifetime>1209600</lifetime>
        <flags count_in_cargo="0" count_in_hoarder="0" count_in_map="1" count_in_player="0" crafted="1" deloot="0"/>
    </type>
	<type name="Zen_RaidAlarmStationKit">
        <lifetime>14400</lifetime>
        <flags count_in_cargo="0" count_in_hoarder="0" count_in_map="1" count_in_player="0" crafted="1" deloot="0"/>
    </type>
	<type name="Zen_RaidAlarmRadarKit">
        <nominal>2</nominal>
        <lifetime>14400</lifetime>
        <restock>3600</restock>
        <min>1</min>
        <quantmin>-1</quantmin>
        <quantmax>-1</quantmax>
        <cost>100</cost>
        <flags count_in_cargo="0" count_in_hoarder="0" count_in_map="1" count_in_player="0" crafted="0" deloot="1"/>
        <category name="tools"/>
        <usage name="Military"/>
		<value name="Tier2"/>
        <value name="Tier3"/>
    </type>
⚠️ **GitHub.com Fallback** ⚠️