Jump to content

Recommended Posts

Posted

Overview

A simple AMX Mod X plugin that allows players to toggle between first-person and third-person camera views in Counter-Strike.

Author: steams.ro
Version: 1.1

Features

  • Toggle between normal (first-person) and third-person camera views
  • Simple command interface (/cam)
  • Works in both public and team chat
  • Player state management (prevents camera change when dead)
  • Automatic cleanup on player disconnect
  • User feedback messages

Commands

  • say /cam - Toggle camera view (public chat)
  • say_team /cam - Toggle camera view (team chat)

Installation

  1. Compile the .sma file using AMX Mod X compiler
  2. Place the compiled .amxx file in addons/amxmodx/plugins/
  3. Add the plugin name to addons/amxmodx/configs/plugins.ini
  4. Restart the server or change map

Requirements

  • AMX Mod X 1.8.2 or higher
  • Engine module

Improvements Made

1. Removed Unnecessary arrayset()

Global boolean arrays are automatically initialized to false, making the manual reset redundant.

2. Added Connection Handlers

  • client_connect() - Resets camera state when player joins
  • client_disconnect() - Cleans up camera state when player leaves

This prevents potential bugs where camera states persist incorrectly.

3. Added Alive Check

The plugin now verifies if the player is alive before allowing camera changes, preventing issues with spectator mode or death states.

4. Simplified Toggle Logic

Changed from verbose if-else to cleaner boolean negation:

g_bEnabled[id] = !g_bEnabled[id];

5. Added User Feedback

Players now receive chat messages confirming their camera view changes.

6. Proper Return Values

Added PLUGIN_HANDLED returns to properly signal that the command was processed.

7. Code Cleanup

Removed AMXX-Studio auto-generated comments for cleaner code.

Technical Details

Global Variables

  • g_bEnabled[33] - Boolean array tracking third-person state for each player (index 1-32)

Functions

  • plugin_init() - Registers plugin and commands
  • plugin_precache() - Precaches required model for third-person view
  • client_connect() - Initializes player camera state
  • client_disconnected() - Cleans up player camera state
  • setview() - Main command handler for camera toggling

Usage Example

  1. Player types /cam in chat
  2. Plugin checks if player is alive
  3. If alive, toggles camera view
  4. Sends confirmation message to player
  5. Player can type /cam again to switch back

Notes

  • The plugin requires models/rpgrocket.mdl to be precached for third-person view functionality
  • Camera state is per-player and persists until toggled or player disconnects
  • Dead players cannot change camera view

 

camera_view.sma camera_view.amxx

×
×
  • Create New...