# Functions

## iCore.player.getPlayerByLicense

{% hint style="info" %}
Get player database by license. Use when player is offline and don't have player server id.

{% endhint %}

```
local player = iCore.player.getPlayerByLicense(license)
print('json.encode(player))
```

## iCore.player.getData

{% hint style="info" %}
Return player data for using in server-side.
{% endhint %}

```
local id = source
local player = iCore.player.getData(id)
print(json.encode(player))
```

## iCore.player.setData

{% hint style="info" %}
Set player data for using in server-side and client-side, auto sync.
{% endhint %}

```
local id = source
iCore.player.setData(id, {fakeName = 'Julia'})
```

## iCore.player.save

{% hint style="info" %}
Save player data to database.
{% endhint %}

```
AddEventHandler('playerDropped', function(reason)
	local id = source
	local player = iCore.player.getData(id)
	if player and player.userId then
		iCore.player.save(player)
		print('Player disconnect (User ID: ' .. player.userId .. ') (Name: ' .. player.name .. ') (Reason: ' .. reason .. ')')
	end
end)
```

## iCore.player.item

{% hint style="info" %}
Give or minus player item and amount.
{% endhint %}

```
local id = source
iCore.player.item(id, {item = 'cash', amount = 30})
```

```
local id = source
iCore.player.item(id, {item = 'cash', amount = -30})
```


---

# 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://viet-gaming-network.gitbook.io/icore/server-side/functions.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.
