# Addon state

# Get the addon state SHARED

GetAddonState returns true if SVMod is enabled, false otherwise.

Can return nil if the addon does not yet know its status.

if SVMOD:GetAddonState() then
  -- SVMod is enabled
elseif SVMOD:GetAddonState() == false then
  -- SVMod is disabled
elseif SVMOD:GetAddonState() == nil then
  -- We don't now yet.
  -- This happens on the client-side when the server has not yet announced the SVMod state.
end

Let's take the opportunity to recall something in Lua. The keyword not means: "true if the field is not true". In other words, writing not SVMOD:GetAddonState() will be true when the state is false OR nil. So beware! In such cases, write == false and == nil to be safe.

# Set the addon state client-side CLIENT

SetAddonState enables or disables SVMod on the server.

You must have the SV_EditOptions permission to do this. (superadmin by default)

-- (CLIENT) Disable SVMod
SVMOD:SetAddonState(false)

-- (CLIENT) Enable SVMod
SVMOD:SetAddonState(true)

# Set the addon state server-side SERVER

Disable and Enable respectively enables or disables SVMod on the server.

-- (SERVER) Disable SVMod
SVMOD:Disable()

-- (SERVER) Enable SVMod
SVMOD:Enable()