# Shop Account

The resource offers a custom account system that is standalone and not dependent on frameworks.

### Get Shop ID

You can get the player's mechanic shop id with this export:

```lua
local src = source
local shopID = exports['t1ger_mechanicsystem']:GetPlayerMechId(src)
-- src(INT): player server id
```

### Add Account Money

{% hint style="warning" %}
Requires: Mechanic Shop ID (use exports to get the ID based on player's server id or player's job name)
{% endhint %}

```lua
exports['t1ger_mechanicsystem']:PlusMechanicAccount(shopId, amount)
-- shopId(INT): mechanic shop id
-- amount(INT): amount of money to add to the account
```

### Remove Account Money

{% hint style="warning" %}
Requires: Mechanic Shop ID (use exports to get the ID based on player's server id or player's job name)
{% endhint %}

```lua
exports['t1ger_mechanicsystem']:MinusMechanicAccount(shopId, amount)
-- shopId(INT): mechanic shop id
-- amount(INT): amount of money to add to the account
```

### Usage - Example #1

Here's an example to easily add/remove money from a mechanic shop:

<pre class="language-lua"><code class="lang-lua"><strong>local src = source -- player server id
</strong><strong>local amount = 5000 -- how much should be added/removed? 
</strong>
-- export to get the shop id based on player server id:
local shopId = exports['t1ger_mechanicsystem']:GetPlayerMechId(src)

-- add money:
exports['t1ger_mechanicsystem']:PlusMechanicAccount(shopId, amount)

-- remove oney:
exports['t1ger_mechanicsystem']:MinusMechanicAccount(shopId, amount)
</code></pre>

### Usage - Example #2

Here's an alternative example using TriggerEvent (similar to esx\_addonaccount)

```lua
local playerJob = 't1mechanic' -- add function/export to get the player's job here. 
local amount = 5000 -- how much should be added/removed? 

TriggerEvent('mechanicsystem:server:getPlayerMechanicShop', playerJob, function(mechanicShop)
    -- remove money:
    if mechanicShop.account >= amount then
        exports['t1ger_mechanicsystem']:MinusMechanicAccount(mechanicShop.id, amount)
    else
        print("not enough money")
    end
    
    -- add money:
    exports['t1ger_mechanicsystem']:PlusMechanicAccount(mechanicShop.id, amount)
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://docs.t1ger.net/resources/t1ger-mechanic-system/shop-account.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.
