Skip to content

Extended: CCSPlayer

dounai2333 edited this page Jan 19, 2025 · 4 revisions

Introduction

How to get this userdata:

Entity()
Player()
GetPlayerByIndex()
GetPlayerByUserId()
GetActiveRandomPlayer()
entity:ToCSPlayer()

tostring

tostring(player)

Format player to a proper string "Player [{index}][{nickname}]".

AddAssists

player:AddAssists(assist)

Adds the provided amount to the player's assist count.

assist: number

AddDeaths

player:AddDeaths(death)

Adds the provided amount to the player's death count.

death: number

AddFrags

player:AddFrags(frag)

Adds the provided amount to the player's frag/kill count.

frag: number

AddUserFlags

player:AddUserFlags(userflag)

Adds cso2 user flags to the player.

userflag: number

Aimbot

player:Aimbot(target)

Make player aim directly to another player.

target: player

Alive

player:Alive()

Checks if the player is alive.

Return: true or false

Armor

player:Armor()

Returns the player's armor.

Return: number

Assists

player:Assists()

Returns the amount of assists a player has.

Return: number

Blink

player:Blink(color, duration, frequency)

Make player have blink effect, same as original player:SetBlink() but a simplified version.

color: color. Example: Color(255, 0, 255)

duration: number

frequency: number

ChatPrint

player:ChatPrint(message, type)

Prints a string to the chatbox of the client, with some types.

message: string

type: number

ConCommand

player:ConCommand(command)

Runs the concommand on the player. This does not work on bots.

command: string

Crouching

player:Crouching()

Returns whether the player is crouching or not.

Return: true or false

Deaths

player:Deaths()

Returns the player's death count.

Return: number

DrawViewModel

player:DrawViewModel(draw)

Show/Hide the player's weapon's viewmodel.

draw: bool

DrawWorldModel

player:DrawWorldModel(draw)

Show/Hide the player's weapon's worldmodel.

draw: bool

DropObject

player:DropObject()

Drops any object the player is currently holding.

Frags

player:Frags()

Returns the amount of frags a player has.

Return: number

Freeze

player:Freeze(frozen)

Freeze the player. Frozen players cannot move, look around, or attack. Key bindings are still called.

frozen: bool

GetAimVector

player:GetAimVector()

Returns the direction that the player is aiming.

Return: vector

GetClassID

player:GetClassID()

Returns the player's class id.

Return: number

GetDuckLoseSpeed

player:GetDuckLoseSpeed()

Get if player should have a slower speed when crouching.

Return: true or false

GetEntityInUse

player:GetEntityInUse()

Returns the entity the player is currently using, like func_tank mounted turrets or +use prop pickups.

Return: entity or nil

GetEyeTraceSimple

player:GetEyeTraceSimple()

Returns world coordinate of what the player is looking at, with a angles.

Return: vector, angle

GetJumpPower

player:GetJumpPower()

Returns the jump power of the player.

Return: number

GetMaxSpeed2

player:GetMaxSpeed2()

A real version, returns the player's maximum movement speed.

Return: number

GetModel

player:GetModel()

Gets the playermodel of given player.

Return: string

GetObserverMode

player:GetObserverMode()

Returns the the observer mode of the player.

Return: number

GetObserverTarget

player:GetObserverTarget()

Returns the player that who is currently observing.

Return: player or nil

GetShootPos

player:GetShootPos()

Returns the position of a player's view.

Return: vector

GetResourcePointer

player:GetResourcePointer()

Get the player statistics (scoreboard) pointer.

Return: number

GetStamina

player:GetStamina()

Returns the the stamina of the player.

Return: number

GetStepSize

player:GetStepSize()

Returns the maximum height player can step onto.

Return: number

GetUserCmd

player:GetUserCmd()

Get the total keys the player is current pressing.

Return: number

GetUserFlags

player:GetUserFlags()

Returns all cso2 user flags of given player.

Return: number

GetVehicle

player:GetVehicle()

Gets the vehicle the player is driving.

Return: entity or nil

GetViewOffset

player:GetViewOffset()

Returns the view offset of the player which equals the difference between the players actual position and their view.

Return: number

GetViewPunchAngles

player:GetViewPunchAngles()

Returns players screen punch effect angle.

Return: angle

GetWalkSpeedScale

player:GetWalkSpeedScale()

Returns the player's walking speed multiplier.

This only affect if player is pressing shift key, i.e. slow walking.

Return: number

GetWeapons

player:GetWeapons()

Returns a table of the player's weapons.

Return: table

Give

player:Give(weapon)

Gives the player a weapon. weapon can be number or string.

weapon: number or string. Example: 160 or weapon_awmgaussplus

GodDisable

player:GodDisable()

Disables god mode on the player.

GodEnable

player:GodEnable()

Enables god mode on the player.

HasGodMode

player:HasGodMode()

Returns whether the player has god mode or not.

Return: true or false

InVehicle

player:InVehicle()

Returns if the player is in a vehicle.

Return: true or false

IsAdmin

player:IsAdmin()

NOT FINISHED: This part of code is not finished yet, using this most likely won't help you.

Returns whether the player is an admin or not. By default the listenserver host are always admin.

Return: true or false

IsFrozen

player:IsFrozen()

Returns whether the players movement is currently frozen.

Return: true or false

IsListenServerHost

player:IsListenServerHost()

Returns if a player is the host of the current session.

BUG: This will return false before the host player actually spawnin.

Return: true or false

IsUserFlagSet

player:IsUserFlagSet(userflag)

Checks if given cso2 user flag(s) is set or not.

Return: true or false

userflag: number

KeyDown

player:KeyDown(key)

Returns whether player is pressing this key.

Return: true or false

key: number

Kick

player:Kick()

Kicks the player from the server.

Kill

player:Kill()

Kills a player.

Name

player:Name()

Returns the players name. This is same as player:Nick().

Return: string

Nick

player:Nick()

Returns the player's nickname. This is same as player:Name().

Return: string

Ping

player:Ping()

Returns the player's ping to server.

Return: number

PrintMessage

player:PrintMessage(printtype, message)

Displays a message either in their chat, console, or on the screen.

printtype: number

message: string

ReadResource

player:ReadResource(type, address, ispointer)

Read the player statistics from player resource (scoreboard). ispointer is only for string variables.

Return: any

type: string. Example: int, float or vector

address: number. Example: 0x358

ispointer: bool

RemoveUserFlags

player:RemoveUserFlags(userflag)

Removes specified cso2 user flag(s) from the player.

userflag: number

SelectWeapon

player:SelectWeapon(class)

Sets the active weapon of the player by its class name.

class: string

SetArmor

player:SetArmor(armor, helmet)

Sets the player armor to the argument, and if helmet is present.

armor: number

helmet: bool

SetAssists

player:SetAssists(assist)

Sets a player's assists.

assist: number

SetDeaths

player:SetDeaths(death)

Sets a player's death count.

death: number

SetDuckLoseSpeed

player:SetDuckLoseSpeed(lose)

Sets if player should have a slower speed when crouching.

lose: bool

SetEyeAngles

player:SetEyeAngles(angle)

Sets the local angle of the player's view.

angle: angle

SetFrags

player:SetFrags(frag)

Sets a player's frags (kills).

frag: number

SetJumpPower

player:SetJumpPower(power)

Sets the jump power, eg. the velocity that will be applied to the player when they jump.

power: number

SetMaxSpeed

player:SetMaxSpeed(speed)

Sets the maximum speed which the player can move at.

speed: number

SetObserverMode

player:SetObserverMode(mode)

Sets the players observer mode.

mode: number

SetProgressBar

player:SetProgressBar(duration)

Runs a progress bar on player, the progress bar will show on player's screen.

duration: number

SetStamina

player:SetStamina(stamina)

Sets the players stamina.

stamina: number

SetStepSize

player:SetStepSize(size)

Sets the maximum height a player can step onto without jumping.

size: number

SetUserFlags

player:SetUserFlags(userflag)

Sets cso2 user flag(s) for the player. This overrides any other flags the player might have had. Use player:AddUserFlags() for adding flags.

userflag: number

SetVelocity

player:SetVelocity(velocity)

Adds the velocity to player's base velocity.

velocity: vector

SetViewPunchAngles

player:SetViewPunchAngles(angle)

Sets client's view punch angle, but not the velocity.

angle: angle

SetWalkSpeedScale

player:SetWalkSpeedScale(scale)

Sets the player's walking speed multiplier.

This only affect if player is pressing shift key, i.e. slow walking.

scale: number

ShouldBleed

player:ShouldBleed(bleed)

Sets if player should bleed when being hit.

bleed: bool

StripWeapon

player:StripWeapon(class)

Removes the specified weapon class from a certain player.

class: string

StripWeapons

player:StripWeapons()

Removes all weapons from a certain player.

UserID

player:UserID()

Returns the player's ID. You can use Player() to get the player by their ID.

WriteResource

player:WriteResource(type, address, value, ispointer)

Write the player statistics from player resource (scoreboard) to given value. ispointer is only for string variables.

type: string. Example: int, float or vector

address: number. Example: 0x358

value: any

ispointer: bool

Clone this wiki locally