Skip to content

Sharpyku/Sharpyku-GhostPlayers

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GhostPlayers — Per-Player Ghost Mode for CS2

A ghost mode plugin for CS2 servers running CounterStrikeSharp. Each player chooses whether they appear semi-transparent or normal to everyone else. Perfect for BHOP/surf/KZ servers.

CS2 .NET 8 License

Features

  • Per-player ghost toggle — Each player controls their own transparency with !ghost
  • Semi-transparent look — Configurable alpha (default 175) for that classic ghost appearance
  • Weapons & gloves included — Knife, gloves, and all weapons match the player's transparency
  • Legs always hidden — First-person legs are hidden regardless of ghost ON/OFF (alpha 254 trick)
  • MySQL/MariaDB persistence — Player preference saved to database, persists across reconnects
  • Auto-generated config — Single config.json with all settings
  • Periodic refresh — Re-applies transparency every few seconds to prevent other plugins from overriding

How It Works

  • Default: All players join as semi-transparent (ghost ON)
  • !ghost — Toggles your own appearance:
    • Ghost ON = You appear semi-transparent to everyone (alpha 175)
    • Ghost OFF = You appear normal/opaque to everyone (alpha 254)
  • Setting is saved in DB — next time you join, your preference is remembered

Note: Transparency is a server-side entity property in Source 2. Each player controls how they look, not how they see others. This is an engine limitation — there is no per-viewer rendering in CS2.

Requirements

  • CounterStrikeSharp v1.0.364+
  • MySQL or MariaDB — for saving player settings (optional — without it, settings reset on reconnect)

Installation

  1. Download the latest release from Releases
  2. Extract the GhostPlayers folder to:
    csgo/addons/counterstrikesharp/plugins/GhostPlayers/
    
  3. Make sure GhostPlayers.dll and MySqlConnector.dll are both in the folder
  4. Start/restart your server — a config.json will be auto-generated
  5. Edit the config to your liking (see below)

File Structure

csgo/addons/counterstrikesharp/
├── plugins/
│   └── GhostPlayers/
│       ├── GhostPlayers.dll
│       └── MySqlConnector.dll
└── configs/
    └── plugins/
        └── GhostPlayers/
            └── config.json         ← auto-created on first load

Configuration

On first server start, the plugin auto-generates a config file at:

csgo/addons/counterstrikesharp/configs/plugins/GhostPlayers/config.json

Default config:

{
  "ChatTag": "[Ghost]",
  "ChatTagColor": "Purple",
  "DefaultGhostEnabled": true,
  "GhostAlpha": 175,
  "RefreshIntervalSeconds": 5.0,
  "Database": {
    "Enabled": false,
    "Host": "localhost",
    "Port": 3306,
    "Database": "cs2",
    "User": "root",
    "Password": "",
    "TableName": "ghost_settings"
  }
}

Config Options

Option Default Description
ChatTag [Ghost] Tag shown in chat messages
ChatTagColor Purple Color of the tag. Options: Red, Blue, Green, Yellow, Orange, Purple, LightRed, LightBlue, LightPurple, DarkRed, DarkBlue, Grey, Olive, Lime, Gold, Silver
DefaultGhostEnabled true Whether ghost mode is ON by default for new players
GhostAlpha 175 Alpha value when ghost is ON (0 = invisible, 254 = barely transparent). 175 = ~31% transparent
RefreshIntervalSeconds 5.0 How often to re-apply transparency (prevents other plugins from overriding). Set to 0 to disable

Database Settings

Option Default Description
Database.Enabled false Set to true to enable MySQL/MariaDB persistence
Database.Host localhost Database server address
Database.Port 3306 Database server port
Database.Database cs2 Database name
Database.User root Database username
Database.Password "" Database password
Database.TableName ghost_settings Name of the settings table

The plugin automatically creates the database table on first connect. The ghost_settings table stores SteamID and Enabled per player.

No database? Leave Database.Enabled as false — the plugin works fine without it, settings just won't persist between sessions.

Commands

Command Description
!ghost Toggle your ghost mode ON/OFF

Chat Output

[Ghost] Ghost ON (semi-transparent)
[Ghost] Ghost OFF (normal)

Technical Details

  • Uses CBaseModelEntity.Render (alpha channel) and RenderMode_t.kRenderTransAlpha
  • Ghost OFF uses alpha 254 (not 255) — this hides first-person legs while appearing fully opaque to others
  • Transparency applied to player pawn + all weapons via WeaponServices.MyWeapons
  • Utilities.SetStateChanged() called on both m_nRenderMode and m_clrRender to network changes
  • Periodic timer re-applies render to prevent other plugins from overriding

Building from Source

dotnet build -c Release

Output: bin/Release/net8.0/GhostPlayers.dll

License

MIT License — see LICENSE for details.

About

Per-player ghost mode (semi-transparent) plugin for CS2 CounterStrikeSharp servers

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages