# API

## Client Exports

### IsInGame

Returns `true` if the player is playing in the Gun Range, otherwise `false`.

```lua
local retval = exports["rcore_gunrange"]:isInGame()

print(retval) -- true
```

## Server Exports

### IsPlayerInGame

Returns `true` if the player is playing in the Gun Range, otherwise `false`.

```lua
local retval = exports["rcore_gunrange"]:IsPlayerInGame(playerSource)

print(retval) -- true
```

## Client Events

### `rcore_gunrange:client:api:onMenuOpen`

Triggered whenever the player opens the gun range menu.

### `rcore_gunrange:client:api:onMenuClose`

Triggered when the player closes the gun range menu or when it is closed automatically (e.g., when a game starts).

### `rcore_gunrange:client:api:onGameStart`

Triggered when a game begins. Comes with four parameters.

```lua
 AddEventHandler('rcore_gunrange:client:api:onGameStart', function(gameMode, timeLimit, isRentingWeapons, weapon)
            print(gameMode) -- EXAM, PRACTISE, SESSION
            print(timeLimit) -- Time in seconds
            print(isRentingWeapons) -- true | false
            print(weapon) -- nil when player is not renting a weapon
        end)
```

### `rcore_gunrange:client:api:onGameEnd`

Triggered when a game ends or is stopped by the player. Comes with two parameters, which tells you what game mode player has completed playing and what score the playe got. The first parameter can also be `UNKNOWN` and second `0`, indicating that the player stopped the game using a command.

```lua
 AddEventHandler('rcore_gunrange:client:api:onGameEnd', function(gameMode, playerScore)
            print(gameMode) -- EXAM, PRACTISE, SESSION, UNKNOWN
            print(playerScore) -- Number
        end)
```


---

# 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://documentation.rcore.cz/paid-resources/rcore_gunrange/api.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.
