Modules

Last updated: July 4, 2018

Custom Languages

Important: Do not modify LANGUAGE.Version. This is the version of jBlacklist your language is compatible with.

  1. Navigate to addons > jblacklist > lua > jblacklist > languages..
  2. Make a copy of the sh_english.lua file and rename it to sh_nameoflanguage.lua.
  3. Open the file and replace LANGUAGE.Name = "English" with LANGUAGE.Name = "NameOfYourLanguage".
  4. Replace LANGUAGE.Author = "Jompe" with LANGUAGE.Author = "YourName".
  5. Go through the whole file and translate all phrases.
  6. Save the file and restart your server.

Custom Blacklists

Template

  • The blacklist module should be created in addons > jblacklist > lua > jblacklist > blacklists as sh_blacklistname.lua.

  • Blacklist Template

    --[[-------------------------------------------------------------------------
    Create the blacklist.
    ---------------------------------------------------------------------------]]
    
    --Create a new blacklist table to work in.
    local BLACKLIST = {}
    
    --Define some basic vars for the blacklist.
    BLACKLIST.Name = "BlacklistName"
    BLACKLIST.Enabled = true
    
    --Register the blacklist.
    jBlacklist.RegisterBL(BLACKLIST)
    
    --[[-------------------------------------------------------------------------
    Non-optional functions.
    ---------------------------------------------------------------------------]]
    
    --Create a function to get the blacklist description.
    BLACKLIST.GetDescription = function(  )
    	return "This blacklist does something very incredible."
    end
    
    --Create a function to get the blacklist's blacklisted-phrase.
    BLACKLIST.GetBlacklistedPhrase = function()
    	return "You are not allowed to do this due to being blacklisted."
    end
    
    --[[-------------------------------------------------------------------------
    Optional functions.
    ---------------------------------------------------------------------------]]
    
    --Creating function that will be called on the server when the blacklist is issued. (Only called if target is online)
    BLACKLIST.OnIssued = function( ply )
    
    end
    
    --Create a function that will be called on the server when the blacklist expires. (Only called if target is online)
    BLACKLIST.OnExpire = function( ply )
    
    end
    
    --[[-------------------------------------------------------------------------
    Hooks
    ---------------------------------------------------------------------------]]
    
    --Add a hook that will prevent the player from doing something if the player is blacklisted.
    --jBlacklist.AddHook works just the same as hook.Add but will only add the hook on the server and get priority over other hooks.
    jBlacklist.AddHook("HookName","HookIdentifier",function( ply )
    
    	--Check if the player is blacklisted.
    	if ply:IsBlacklisted(BLACKLIST) then
    
    		--Do something that prevent the player from doing something here.
    
    		--Tell the player that the current action was blocked due to being blacklisted.
    		jBlacklist.ShowBlacklistedPopup( ply, BLACKLIST )
    
    	end
    
    end)

    Blacklist Structure


    This part of the blacklist structure creates a new local table to store all the blacklist information in.

    local BLACKLIST = {}

    BLACKLIST.Name holds the name of the blacklist. This will be used to identify it and will also be shown in the administration menu.

    BLACKLIST.Name = "BlacklistName"

    BLACKLIST.Enabled is a boolean which states if the blacklist is enabled or not. Setting this to false will result in the blacklist not being loaded. This will hide the blacklist from the administration menu and wont make blacklisted player's restricted from it.

    BLACKLIST.Enabled = true

    jBlacklist.RegisterBL(BLACKLIST) will make jBlacklist load your blacklist into the addon. This is required for the blacklist to work.

    jBlacklist.RegisterBL(BLACKLIST)

    BLACKLIST.GetDescription is a non-optional function which is used internally to get the description of your blacklist.

    BLACKLIST.GetDescription = function(  )
        return "This blacklist does something very incredible."
    end

    BLACKLIST.GetBlacklistedPhrase is a non-optional function which is used internally to get the phrase that should be shown to inform the user it tried doing something it was blacklisted from doing.

    BLACKLIST.GetBlacklistedPhrase = function()
    	return "You are not allowed to do this due to being blacklisted."
    end

    BLACKLIST.OnIssued is a optional function that will be called on the server when a player receives a blacklist if the player is currently logged into the same server as where the blacklist was issued. It comes with 1 argument which is a player-entity of the blacklisted player.

    BLACKLIST.OnIssued = function( ply )
     
    end

    BLACKLIST.OnExpire is a optional function that will be called on the server when a player's blacklist expires. It comes with 1 argument which is a player-entity of the blacklisted player.

    BLACKLIST.OnExpire = function( ply )
     
    end

    Depending on what your blacklist does you may want to add hooks to your blacklist. These will be used to detect what a player shouldn't be allowed doing. Check the Garry's Mod wiki for available hooks and how they can be used. The difference between jBlacklist.AddHook and hook.Add is that jBlacklist.AddHook only will add the hook on the server and get priority over other hooks.

    jBlacklist.AddHook("HookName","HookIdentifier",function( )
     
    end)

    You can check if a player is blacklisted by calling PLAYER:IsBlacklisted() with your blacklist-table as an argument to check if a player is blacklisted from that specific blacklist.

    if ply:IsBlacklisted(BLACKLIST) then
    
    end
    

    Calling this will Tell the player that the current action was blocked due to being blacklisted. It will also inform the player how much time of the blacklist is left and how to see all their blacklists.

    jBlacklist.ShowBlacklistedPopup( ply, BLACKLIST )