> For the complete documentation index, see [llms.txt](https://csokis-organization.gitbook.io/csoki-scripts/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://csokis-organization.gitbook.io/csoki-scripts/kiegeszito-rendszerek/premium-bolt/exportok.md).

# Exportok

### Alapok

* Resource név: `csoki_premium`
* Minden metódus fogad `source`-ot (player id) **vagy** `xPlayer` objektumot első paraméterként.

### GetPlayerPP

Lekéri a játékos aktuális PP egyenlegét.

```lua
exports['csoki_premium']:GetPlayerPP(xPlayerOrSource)
```

#### Paraméterek

* `xPlayerOrSource`: `number | table`

#### Visszatérési érték

* `number`: PP egyenleg (`0`, ha a játékos nem található)

#### Példa

```lua
local pp = exports['csoki_premium']:GetPlayerPP(source)
print(('PP: %s'):format(pp))
```

### SetPlayerPP

Beállítja a játékos PP egyenlegét fix értékre.

```lua
exports['csoki_premium']:SetPlayerPP(xPlayerOrSource, value)
```

#### Paraméterek

* `xPlayerOrSource`: `number | table`
* `value`: `number` (0 vagy nagyobb)

#### Visszatérési érték

* `boolean`: `true` ha sikeres, különben `false`

#### Példa

```lua
local ok = exports['csoki_premium']:SetPlayerPP(source, 1500)
if not ok then
  print('SetPlayerPP sikertelen')
end
```

### GivePlayerPP

Hozzáad PP-t a játékos egyenlegéhez.

```lua
exports['csoki_premium']:GivePlayerPP(xPlayerOrSource, amount)
```

#### Paraméterek

* `xPlayerOrSource`: `number | table`
* `amount`: `number` (0 vagy nagyobb)

#### Visszatérési érték

* `boolean`: `true` ha sikeres, különben `false`

#### Példa

```lua
local ok = exports['csoki_premium']:GivePlayerPP(source, 250)
if ok then
  print('PP jóváírva')
end
```

### TakePlayerPP

Levon PP-t a játékos egyenlegéből.

```lua
exports['csoki_premium']:TakePlayerPP(xPlayerOrSource, amount)
```

#### Paraméterek

* `xPlayerOrSource`: `number | table`
* `amount`: `number` (0 vagy nagyobb)

#### Visszatérési érték

* `boolean`: `true` ha sikeres, különben `false`
* `false` akkor is, ha nincs elég PP

#### Példa

```lua
local ok = exports['csoki_premium']:TakePlayerPP(source, 500)
if not ok then
  print('Nincs elegendő PP vagy hibás paraméter')
end
```

### HasPlayerPP

Ellenőrzi, hogy a játékos rendelkezik-e legalább adott mennyiségű PP-vel.

```lua
exports['csoki_premium']:HasPlayerPP(xPlayerOrSource, amount)
```

#### Paraméterek

* `xPlayerOrSource`: `number | table`
* `amount`: `number`

#### Visszatérési érték

* `boolean`: `true`, ha a játékos PP-je legalább `amount`

#### Példa

```lua
if exports['csoki_premium']:HasPlayerPP(source, 1000) then
  print('Van elég PP')
else
  print('Nincs elég PP')
end
```

### Minta (vásárlás)

```lua
local price = 750
if exports['csoki_premium']:HasPlayerPP(source, price) then
  local ok = exports['csoki_premium']:TakePlayerPP(source, price)
  if ok then
    -- add item / reward
  end
end
```
