Creating a Custom Ban System on a Garry's Mod Server

In this tutorial, you'll learn how to set up a custom ban system on your Garry's Mod server using the VolticHost Game Panel. This system lets you ban or unban players via custom Lua commands, helping you maintain a healthy gaming environment. 🚀


📌 Prerequisites


1️⃣ First Step - Uploading the Custom Ban System Script

  1. Log in to VolticHost Game Panel.

  2. Navigate to the File Manager from the main dashboard.

  3. Go to the /garrysmod/lua/autorun/server/ directory.

  4. Create a new file named custom_ban_system.lua.

  5. Open custom_ban_system.lua for editing and paste the following script:

    if SERVER then
        local bannedPlayers = {}
    
        -- Command to ban a player by SteamID
        concommand.Add("custom_ban", function(ply, cmd, args)
            if not args[1] then
                ply:ChatPrint("Usage: custom_ban <steamid>")
                return
            end
            local steamID = args[1]
            bannedPlayers[steamID] = true
            ply:ChatPrint("Player with SteamID " .. steamID .. " has been banned.")
        end)
    
        -- Hook to prevent banned players from joining
        hook.Add("PlayerInitialSpawn", "CheckCustomBan", function(ply)
            if bannedPlayers[ply:SteamID()] then
                ply:Kick("You are banned from this server.")
            end
        end)
    
        -- Command to unban a player by SteamID
        concommand.Add("custom_unban", function(ply, cmd, args)
            if not args[1] then
                ply:ChatPrint("Usage: custom_unban <steamid>")
                return
            end
            local steamID = args[1]
            bannedPlayers[steamID] = nil
            ply:ChatPrint("Player with SteamID " .. steamID .. " has been unbanned.")
        end)
    end
    
  6. Save the file after editing.

  7. Restart your server from the VolticHost Game Panel to load the new script.

✅ Custom ban system script uploaded and loaded successfully!


2️⃣ Next Step - Testing and Managing the Ban System

  1. Join your server and open the in-game console.

  2. Test the ban command by typing:

    custom_ban STEAM_0:1:12345678
    

    Replace STEAM_0:1:12345678 with an actual SteamID for testing.

  3. Attempt to rejoin the server with a banned SteamID to verify that the player is kicked.

  4. Test the unban command by typing:

    custom_unban STEAM_0:1:12345678
    

    This should remove the ban and allow the player to join the server again.

  5. Verify that chat messages confirm each command's successful execution.

✅ Custom ban system tested and functioning successfully!


🎉 Conclusion

You have now successfully created a custom ban system on your Garry's Mod server using the VolticHost Game Panel! Maintain a controlled gaming environment by easily banning or unbanning players with custom Lua commands. 🚀

For more assistance, contact VolticHost Support.