# Local Player

```lua
-- Returns the index of the local player entity.
-- The index is calculated based on the player's index within the pmove structure,
-- which is incremented by 1 before being returned to match the indexing convention used by Lua.
-- Returns:
--     An integer representing the index of the local player entity.
LocalPlayer.GetIndex()
```

```lua
-- Retrieves the team of the local player.
-- Returns:
--     An integer representing the team of the local player.
LocalPlayer.GetTeam()
```

```lua
-- Get the current flags of the local player, which represents its current state.
-- Returns:
--     An integer value that represents the current flags of the local player. These flags can be used to determine if the player is on the ground, underwater, jumping, etc.
LocalPlayer.GetFlags()
```

<pre class="language-lua"><code class="lang-lua">-- Checks whether a player has a specific flag set or not.
-- Parameters:
--     <a data-footnote-ref href="#user-content-fn-1">flag</a>: an integer value representing the flag to be checked.
-- Returns:
--     True if the flag is set, false otherwise.
LocalPlayer.CheckFlag(<a data-footnote-ref href="#user-content-fn-1">flag</a>)
</code></pre>

```lua
-- Returns the button bit flags of the player's current input command.
-- Each bit represents a different button.
-- Returns:
--     An integer value representing the player's button bit flags.
LocalPlayer.GetButtons()
```

<pre class="language-lua"><code class="lang-lua">-- Check if a specific button is pressed in the given user command structure.
-- Parameters:
--     cmd: pointer to a usercmd_s structure, representing the user's input command.
--     <a data-footnote-ref href="#user-content-fn-2">button</a>: the button flag to be checked.
-- Returns:
--     True if the button is pressed in the user command, false otherwise.
LocalPlayer.CheckButton(cmd, <a data-footnote-ref href="#user-content-fn-2">button</a>)
</code></pre>

<pre class="language-lua" data-overflow="wrap"><code class="lang-lua">-- Sets the specified button as pressed in the given user command.
-- Parameters:
--     cmd: pointer to a usercmd_s structure representing the user command.
--     <a data-footnote-ref href="#user-content-fn-2">button</a>: integer value representing the button to be pressed.
LocalPlayer.PressButton(cmd, <a data-footnote-ref href="#user-content-fn-2">button</a>)
</code></pre>

<pre class="language-lua" data-overflow="wrap"><code class="lang-lua">-- Releases a button in the user command.
-- Parameters:
--     cmd: pointer to a usercmd_s struct representing the user's input.
--     <a data-footnote-ref href="#user-content-fn-2">button</a>: integer representing the button to release.
LocalPlayer.ReleaseButton(cmd, <a data-footnote-ref href="#user-content-fn-2">button</a>)
</code></pre>

```lua
-- Checks whether the local player is alive or not.
-- Returns:
--     True if the local player is alive, false otherwise.
LocalPlayer.IsAlive()
```

```lua
-- Check whether the local player is currently scoped with their weapon.
-- Returns:
--     True if the local player is scoped, false otherwise.
LocalPlayer.IsScoped()
```

```lua
-- Starts fixing player movement to prevent "jittery" movement behavior caused by the game engine.
-- This function calls the ::FixMoveStart function, which is a lower-level function that directly modifies the usercmd_s structure.
-- Usefull for anti aims.
-- Parameters:
--     cmd: pointer to the usercmd_s structure to be fixed.
LocalPlayer.FixMoveStart(cmd)
```

```lua
-- Fixes the movement commands at the end of the usercmd processing.
-- This function is intended to be called after all other functions that modify
-- the usercmd structure, to ensure that the resulting movement commands are valid.
-- Usefull for anti aims.
-- Parameters:
--     cmd: pointer to the usercmd_s structure to be fixed.
LocalPlayer.FixMoveEnd(cmd)
```

```lua
-- Returns the view angles of the local player.
-- Returns:
--     A vector representing the view angles of the local player.
LocalPlayer.GetViewAngles()
```

```lua
-- Sets the view angles of the local player.
-- Parameters:
--     angles: a Vector representing the new view angles to set.
LocalPlayer.SetViewAngles(angles)
```

```lua
-- Returns the position of the local player's eyes in the game world.
-- This is calculated by adding the player's origin to their view offset.
-- Returns:
--     A 3D vector representing the position of the local player's eyes.
LocalPlayer.GetEyePosition()
```

<pre class="language-lua"><code class="lang-lua">-- Checks if the player's current weapon is a knife.
-- Returns true if the current weapon is a knife, false otherwise.
<strong>LocalPlayer.IsCurWeaponKnife()
</strong></code></pre>

```lua
-- Checks if the player's current weapon is a pistol.
-- Returns true if the current weapon is a pistol, false otherwise.
LocalPlayer.IsCurWeaponPistol()
```

```lua
-- Checks if the player's current weapon is a grenade.
-- Returns true if the current weapon is a grenade, false otherwise.
LocalPlayer.IsCurWeaponNade()
```

```lua
-- Checks if the player's current weapon is a sniper rifle.
-- Returns true if the current weapon is a sniper rifle, false otherwise.
LocalPlayer.IsCurWeaponSniper()
```

```lua
-- Checks if the player's current weapon is a rifle.
-- Returns true if the current weapon is a rifle, false otherwise.
LocalPlayer.IsCurWeaponRifle()
```

```lua
-- Checks if the player's current weapon is a shotgun.
-- Returns true if the current weapon is a shotgun, false otherwise.
LocalPlayer.IsCurWeaponShotGun()
```

```lua
-- Checks if the player's current weapon is a machine gun.
-- Returns true if the current weapon is a machine gun, false otherwise.
LocalPlayer.IsCurWeaponMachineGun()
```

```lua
-- Checks if the player's current weapon is a machine gun.
-- Returns true if the current weapon is a machine gun, false otherwise.
LocalPlayer.IsCurWeaponSubMachineGun()
```

```lua
-- Returns the name of the weapon that the local player is currently holding.
-- The name is returned as a string.
-- Returns "Unknown" if the local player is not currently holding a weapon or is dead.
LocalPlayer.GetWeaponName()
```

```lua
-- Get the ID of the weapon that the local player is currently holding.
-- Returns:
--     An integer representing the weapon ID. If the local player is not holding a weapon,
--     or if the function fails to retrieve the ID, then it returns 0.
LocalPlayer.GetWeaponID()
```

<pre class="language-lua"><code class="lang-lua">-- Executes a client command with a string parameter.
-- Parameters:
--     command: the name of the command to execute,
--     value: the string parameter to pass to the command.
<strong>LocalPlayer.ExecuteCommand(command, value)
</strong></code></pre>

```lua
-- Gets the current value of a console variable as a string.
-- Parameters:
--     command: the name of the console variable
-- Returns:
--     a string containing the current value of the console variable.
LocalPlayer.GetCommandString(command)
```

```lua
-- Gets the current value of a console variable as a string.
-- Parameters:
--     command: the name of the console variable
-- Returns:
--     a float containing the current value of the console variable.
LocalPlayer.GetCommandFloat(command)
```

[^1]: You should check the [Flags](/sakura/documentation/variables/flags.md) for more information.

[^2]: You should check avaialble buttons in [Inputs](/sakura/documentation/variables/inputs.md)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://sakura-9.gitbook.io/sakura/documentation/namespaces/local-player.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
