This is a Garry's Mod lua guide for addon authors on how to add support for nZombies gamemodes (such as the new nZombies Chronicles). It's very easy, but instead of a single comparison, you support several matches
This is the broadest and most future-proof method. It matches any gamemode whose name starts with "nzombies" including variants that don't exist yet.
local is_nzombies = string.StartsWith(string.lower(engine.ActiveGamemode()), "nzombies")
if is_nzombies then
-- your special nzombies stuff
endSimilar to Method 1, but even more permissive. It matches any gamemode whose name contains "nzombies" anywhere in the string, not just at the start.
local is_nzombies = string.find(string.lower(engine.ActiveGamemode()), "nzombies") ~= nil
if is_nzombies then
-- your special nzombies stuff
endUse this if you only want to support specific, known nZombies variants rather than all of them. This requires updating your addon manually whenever you want to add support for a new variant.
local nzombies = {
["nzombies"] = true,
["nzombies_chronicles"] = true,
["nzombies-unlimited"] = true
}
local is_nzombies = (nzombies[string.lower(engine.ActiveGamemode())] == true)
if is_nzombies then
-- your special nzombies stuff
endif engine.ActiveGamemode() == "nzombies" then
This only matches the original gamemode. It will break your addon on every other variant of nZombies, since their gamemode names are different strings entirely.
Don't do this. Use one of the methods above instead so your addon works across all nZombies variants, current and future.
nZombies variants like nZombies Chronicles are built on the same underlying gamemode. They share most of the same functionality, and the biggest difference between them is simply the gamemode name itself.
Because of this, checking for an exact name match (like "nzombies") only catches the original gamemode and misses every variant. The methods above work around this by matching on the shared "nzombies" naming pattern instead of one exact name, so your addon correctly recognizes all variants of nZombies.