cs2-SimpleAdmin/CS2-SimpleAdmin-docs/docs/user/commands/playercommands.md
Ravid-A 530f60366d Fix unban delay, admin loading, rename persistence; add css_history (1.9.0)
Fixes for issues reported by server owners, plus one new command.

Unbans took up to a minute to apply, and on SQLite never applied at all:
- css_unban only wrote to the database, but the connect check reads an
  in-memory cache that syncs on a 61s timer. BanManager.UnbanPlayer now
  marks the bans UNBANNED in CacheManager and rebuilds the indexes, and
  logs failures instead of swallowing them.
- SQLite has no ON UPDATE CURRENT_TIMESTAMP and the unban/expire queries
  never set updated_at, so the delta refresh never saw the change and
  the ban stayed active until a plugin reload. Both queries set it now.
- The delta query uses >= so a change written in the same second as the
  refresh snapshot is not skipped.
- css_unban issues removeid when UnlockedCommands is on, clearing the
  engine-level banid that css_ban adds.
- RebuildIndexes builds fresh dictionaries and swaps them under a lock,
  so the game thread cannot read a half-built index now that unbans can
  trigger a rebuild off the timer thread.

Admin permissions were intermittently missing after a restart:
- The startup reload fired at a fixed 3s, usually before ServerManager
  had resolved ServerId, so the admin query ran with a null server and
  returned only global admins, with nothing reloading afterwards.
  ServerManager now reloads admins once ServerId is set, and on both of
  its failure paths so global admins still load.
- Loading the plugin mid-map (css_plugins load) fires no map start, so
  server loading is kicked off after 5s if it has not happened.
- CreateAdminsJsonFile no longer strips permissions from inside the
  ToDictionary lambda, where it ran once per name group and seconds
  before the new data was loaded. It returns the new cache and
  PermissionManager.ApplyAdminCache applies it on the main thread
  immediately before AdminManager.LoadAdminData.
- Reloads are serialized with a semaphore and carry a generation, so
  overlapping ones cannot race on the JSON files or apply a stale
  snapshot after the hibernation cap.
- GetAllPlayersFlags and GetAllGroupsData rethrow instead of returning
  an empty list; ReloadAdmins catches, logs and aborts. A transient
  database error previously wrote an empty admins.json and stripped
  every admin on the server.

Permanent renames did not survive a restart:
- New sa_renames table (migration 017); css_prename upserts or deletes,
  and the table is loaded into memory once the server is ready.
- The rename is re-applied on connect before the DatabaseProvider /
  CacheManager early return, which previously skipped it whenever the
  DB or cache was not ready yet.
- New EventPlayerChangename handler, and both it and OnPlayerInfo
  re-check after a short delay instead of comparing names at event
  time; the engine may not have written the client's new name yet, and
  Rename itself takes 0.4s to settle.

Smaller fixes:
- css_say printed "ADMIN: <text>" with no name. The caller name is
  passed to the localizer and sa_adminsay_prefix carries {1} in all 13
  languages.
- css_penalties <player> with @css/kick reassigned only the local user
  id while every lookup kept using caller.SteamID, so an admin checking
  another player always saw their own penalties. It now uses the
  target's SteamID, and replies instead of throwing when that player's
  connect data has not finished loading.
- css_rename returned early for an admin in silent mode, which skipped
  the rename itself rather than just the announcement.

New: css_history <#userid|name|steamid64> [bans|gags|mutes|silences|warns]
(@css/kick) prints every ban, gag, mute, silence and warn with status,
duration, the admin who issued it, the reason and, for lifted bans and
mutes, who lifted it, when and why. A SteamID64 works for players who
are not online. Also available in the admin menu under Players >
History. The data was always there: unban, unmute and expiry only flip
the status column, rows are never deleted.

Build:
- The csproj listed all 32 migration files by hand, so a new migration
  silently never reached the output. Replaced with a glob.
- Commands missing from an existing Commands.json are registered under
  their default name, so new commands appear without deleting the file.
  An empty alias list still disables a command.
2026-10-03 02:33:10 +03:00

516 lines
9.2 KiB
Markdown

---
sidebar_position: 5
---
# Player Commands
Commands for managing and manipulating players on your server.
:::note
Many of these commands are included in the base plugin. For extended fun commands (god mode, noclip, freeze, etc.), see the [Fun Commands Module](../../modules/funcommands).
:::
## Player Management
### Slay Player
Kill a player instantly.
```bash
css_slay <#userid or name>
```
**Permission:** `@css/slay`
**Examples:**
```bash
css_slay #123
css_slay PlayerName
css_slay @ct # Slay all CTs
css_slay @t # Slay all terrorists
```
**Use cases:**
- Punishment for rule breaking
- Ending rounds quickly
- Removing camping players
---
### Slap Player
Slap a player, dealing damage and pushing them.
```bash
css_slap <#userid or name> [damage]
```
**Permission:** `@css/slay`
**Parameters:**
- `damage` - HP damage to deal (default: 0)
**Examples:**
```bash
css_slap #123 # Slap with no damage
css_slap PlayerName 10 # Slap for 10 HP damage
css_slap @all 5 # Slap everyone for 5 damage
```
**Effects:**
- Player is pushed in a random direction
- Optional damage dealt
- Makes slap sound
**Use cases:**
- Funny punishment
- Getting player attention
- Moving AFK players
---
## Player Attributes
### Set Player Health
Set a player's health points.
```bash
css_hp <#userid or name> <health>
```
**Permission:** `@css/slay`
**Examples:**
```bash
css_hp #123 100 # Set to full health
css_hp PlayerName 1 # Set to 1 HP
css_hp @ct 200 # Give all CTs 200 HP
```
**Valid range:** 1 - 999+
---
### Set Player Speed
Modify a player's movement speed.
```bash
css_speed <#userid or name> <speed>
```
**Permission:** `@css/slay`
**Parameters:**
- `speed` - Speed multiplier (1.0 = normal, 2.0 = double speed, 0.5 = half speed)
**Examples:**
```bash
css_speed #123 1.5 # 150% speed
css_speed PlayerName 0.5 # 50% speed (slow motion)
css_speed @all 2.0 # Double speed for everyone
css_speed #123 1.0 # Reset to normal speed
```
**Common values:**
- `0.5` - Slow motion
- `1.0` - Normal (default)
- `1.5` - Fast
- `2.0` - Very fast
- `3.0` - Extremely fast
**Note:** Speed persists across respawns until reset.
---
### Set Player Gravity
Modify a player's gravity.
```bash
css_gravity <#userid or name> <gravity>
```
**Permission:** `@css/slay`
**Parameters:**
- `gravity` - Gravity multiplier (1.0 = normal, 0.5 = moon jump, 2.0 = heavy)
**Examples:**
```bash
css_gravity #123 0.5 # Moon jump
css_gravity PlayerName 2.0 # Heavy gravity
css_gravity @all 0.1 # Super jump for everyone
css_gravity #123 1.0 # Reset to normal
```
**Common values:**
- `0.1` - Super high jumps
- `0.5` - Moon gravity
- `1.0` - Normal (default)
- `2.0` - Heavy/fast falling
**Note:** Gravity persists across respawns until reset.
---
### Set Player Money
Set a player's money amount.
```bash
css_money <#userid or name> <amount>
```
**Permission:** `@css/slay`
**Examples:**
```bash
css_money #123 16000 # Max money
css_money PlayerName 0 # Remove all money
css_money @ct 10000 # Give all CTs $10,000
```
**Valid range:** 0 - 65535 (CS2 engine limit)
---
## Team Management
### Switch Player Team
Move a player to a different team.
```bash
css_team <#userid or name> [ct/t/spec] [-k]
```
**Permission:** `@css/kick`
**Parameters:**
- `ct` - Counter-Terrorist team
- `t` - Terrorist team
- `spec` - Spectators
- `-k` - Kill player during switch (optional)
**Examples:**
```bash
css_team #123 ct # Move to CT
css_team PlayerName t # Move to T
css_team @spec t # Move all spectators to T
css_team #123 ct -k # Move to CT and kill
```
**Configuration:**
```json
"TeamSwitchType": 1
```
Determines team switch behavior.
---
### Rename Player
Temporarily rename a player.
```bash
css_rename <#userid or name> <new name>
```
**Permission:** `@css/kick`
**Examples:**
```bash
css_rename #123 "NewName"
css_rename PlayerName "RenamedPlayer"
css_rename @all "Everyone"
```
**Notes:**
- Rename is temporary (resets on reconnect)
- For permanent rename, use `css_prename`
---
### Permanent Rename
Permanently force a player's name.
```bash
css_prename <#userid or name> <new name>
```
**Permission:** `@css/ban`
**Examples:**
```bash
css_prename #123 "EnforcedName"
css_prename PlayerName "NewIdentity"
```
**Notes:**
- Name is enforced even after reconnect, map change and server restart
- Stored in the database (`sa_renames`) and shared by every server using that database
- Player cannot change it; `css_prename <player>` with no name removes the rename
- Useful for offensive names
---
## Weapon Management
### Give Weapon
Give a weapon to a player.
```bash
css_give <#userid or name> <weapon>
```
**Permission:** `@css/cheats`
**Weapon names:**
- Rifles: `ak47`, `m4a1`, `m4a1_silencer`, `aug`, `sg556`, `awp`
- SMGs: `mp5sd`, `mp7`, `mp9`, `p90`, `ump45`
- Heavy: `nova`, `xm1014`, `mag7`, `m249`, `negev`
- Pistols: `deagle`, `elite`, `fiveseven`, `glock`, `hkp2000`, `p250`, `tec9`, `usp_silencer`
- Grenades: `flashbang`, `hegrenade`, `smokegrenade`, `molotov`, `incgrenade`, `decoy`
- Equipment: `kevlar`, `assaultsuit`, `defuser`, `knife`
**Examples:**
```bash
css_give #123 awp
css_give PlayerName ak47
css_give @ct m4a1
css_give @all deagle
```
---
### Strip Weapons
Remove all weapons from a player.
```bash
css_strip <#userid or name>
```
**Permission:** `@css/slay`
**Examples:**
```bash
css_strip #123
css_strip PlayerName
css_strip @t # Disarm all terrorists
```
**Effects:**
- Removes all weapons
- Leaves player with knife only
- Removes grenades and equipment
---
## Teleportation
### Teleport to Player
Teleport yourself to another player.
```bash
css_tp <#userid or name>
css_tpto <#userid or name>
css_goto <#userid or name>
```
**Permission:** `@css/kick`
**Examples:**
```bash
css_tp #123
css_goto PlayerName
```
**Use cases:**
- Checking player behavior
- Admin help
- Spectating suspicious players
---
### Teleport Player to You
Bring a player to your location.
```bash
css_bring <#userid or name>
css_tphere <#userid or name>
```
**Permission:** `@css/kick`
**Examples:**
```bash
css_bring #123
css_tphere PlayerName
css_bring @all # Bring everyone to you
```
**Use cases:**
- Moving stuck players
- Gathering players
- Admin events
---
### Respawn Player
Respawn a dead player.
```bash
css_respawn <#userid or name>
```
**Permission:** `@css/cheats`
**Examples:**
```bash
css_respawn #123
css_respawn PlayerName
css_respawn @ct # Respawn all dead CTs
```
**Notes:**
- Player spawns at spawn point
- Equipped with default weapons
- Can break competitive balance
---
## Player Targeting
All player commands support advanced targeting:
### Target Syntax
- `@all` - All players
- `@ct` - All Counter-Terrorists
- `@t` - All Terrorists
- `@spec` - All spectators
- `@alive` - All alive players
- `@dead` - All dead players
- `@bot` - All bots
- `@human` - All human players
- `@me` - Yourself
- `#123` - Specific user ID
- `PlayerName` - By name (partial match supported)
### Multiple Targets
```bash
css_slay @ct # Kills all CTs
css_hp @all 200 # Give everyone 200 HP
css_speed @t 2.0 # Make all Ts fast
```
---
## Permission Requirements
| Command | Required Permission | Description |
|---------|-------------------|-------------|
| `css_slay` | `@css/slay` | Kill players |
| `css_slap` | `@css/slay` | Slap players |
| `css_hp` | `@css/slay` | Set health |
| `css_speed` | `@css/slay` | Modify speed |
| `css_gravity` | `@css/slay` | Modify gravity |
| `css_money` | `@css/slay` | Set money |
| `css_team` | `@css/kick` | Change team |
| `css_rename` | `@css/kick` | Temporary rename |
| `css_prename` | `@css/ban` | Permanent rename |
| `css_give` | `@css/cheats` | Give weapons |
| `css_strip` | `@css/slay` | Remove weapons |
| `css_tp` | `@css/kick` | Teleport to player |
| `css_bring` | `@css/kick` | Bring player |
| `css_respawn` | `@css/cheats` | Respawn players |
---
## Best Practices
### Punishment Commands
**Slay:**
- Use for rule violations
- Better than kick for minor issues
- Allows player to stay and learn
**Slap:**
- Lighter punishment
- Good for warnings
- Can be funny/entertaining
### Gameplay Modification
**HP/Speed/Gravity:**
- Use for events/fun rounds
- Don't abuse during competitive play
- Reset to normal after use
**Respawn:**
- Very disruptive to gameplay
- Use sparingly
- Good for fixing bugs/mistakes
### Team Management
**Team switching:**
- Balance teams fairly
- Don't abuse for winning
- Use `-k` flag for competitive integrity
---
## Configuration
### Team Switch Behavior
```json
"TeamSwitchType": 1
```
Controls how team switching works.
---
## Troubleshooting
### Speed/Gravity not persisting
**Solution:** These are maintained by a timer. If they reset:
- Check server console for errors
- Ensure plugin is loaded correctly
- Try reapplying the modification
### Can't teleport
**Check:**
- Target player is connected
- You have correct permissions
- Both players are valid
### Give weapon not working
**Check:**
- Weapon name is correct
- Player is alive
- Player has inventory space
---
## Related Commands
- **[Fun Commands Module](../../modules/funcommands)** - Extended fun commands (freeze, god mode, noclip)
- **[Ban Commands](basebans)** - Punishment commands
- **[Base Commands](basecommands)** - Server management