# Setup

## Setting Up the Script

1. This script can be used with both the target system <mark style="color:green;">(qb-target, ox\_target)</mark> and the menu <mark style="color:green;">(qb-menu, ox\_lib, esx)</mark><br>

   <figure><img src="https://1034396727-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FBXIsRWbAXJHBnjtE4Gxk%2Fuploads%2FW0aQkgRIFw9WSCyaTWrr%2Fimage.png?alt=media&#x26;token=f7eeac14-0fa2-4e09-9bba-001d2622d9cd" alt=""><figcaption></figcaption></figure>

2. <mark style="color:orange;">**CodeStudio.UseMetaData**</mark>  Enable this if you want to use metadata-based ID cards, which have unique IDs that contain information about the person who owns them. For example, if you steal someone else's ID, it will display information about the main person who owns the ID \*Note that your inventory must support metadata. Otherwise, set this to false

3. Customize ID Issuing Location: You can restrict the location for multiple jobs and issue multiple IDs at the same location, as well as have multiple locations for the same<br>

   <figure><img src="https://1034396727-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FBXIsRWbAXJHBnjtE4Gxk%2Fuploads%2Fr98k3sA5W55AwbDzIT36%2Fcode.png?alt=media&#x26;token=5b9714b1-d792-42ff-b13e-dea9afb6ae83" alt=""><figcaption></figcaption></figure>

4. The <mark style="color:green;">Player Management Menu</mark> includes all the IDs you create in CodeStudio.DefaultID, although you can customize what is displayed in the menu. However, any customization should be based on CodeStudio.DefaultID. Similarly, <mark style="color:green;">Job Management</mark> includes all the items you put in CodeStudio.JobCards to manage cards

5. Customize Management Menus: You can restrict player and job management menus access based on multiple jobs and grades, and enable a job+player management menu. Additionally, you can have multiple locations for the same<br>

   <figure><img src="https://1034396727-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FBXIsRWbAXJHBnjtE4Gxk%2Fuploads%2FIqqPHVxSWXxxJEpuMXal%2Fcode.png?alt=media&#x26;token=a1d32d3a-3e96-4298-a64d-ecb86155e488" alt=""><figcaption></figcaption></figure>

6. You can customize ID cards and job badges/cards in detail using the editing template provided below. Additionally, you can set <mark style="color:green;">card expiry</mark> by specifying the number of days in the configuration. If you don't want cards to expire, set expireCard to false \
   \
   (<mark style="color:red;">**\*Disable any other script that you have to issue or give ID cards**</mark> *Example (qb-inventroy which issues id\_card and qb-cityhall which you have to customize:* [#events-and-exports](#events-and-exports "mention")))\
   \ <br>

   <figure><img src="https://1034396727-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FBXIsRWbAXJHBnjtE4Gxk%2Fuploads%2Fvj0EbRH0p5ga1u7XrIXn%2Fcode.png?alt=media&#x26;token=82a9865e-4fcf-41eb-baeb-acfd8e07c6c0" alt=""><figcaption><p><mark style="background-color:blue;"><strong>This is a template example of how to customize ID cards</strong></mark><br><br></p></figcaption></figure>

   <figure><img src="https://1034396727-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FBXIsRWbAXJHBnjtE4Gxk%2Fuploads%2FD6DU9aSVNessPHRudU6e%2Fcode.png?alt=media&#x26;token=ef122454-df45-4e5d-a720-6a2180f63f27" alt=""><figcaption><p><mark style="background-color:blue;"><strong>This is a template example of how to customize job cards/badges</strong></mark></p></figcaption></figure>

7. The script comes with an automatic SQL creator and automatically makes items usable. Simply register your ID card or job card items into your server after setting up the script

## Events and Exports

### Client Side

1. <pre class="language-lua" data-title="Open Player Manage Menu"><code class="lang-lua">--Specify the cards that you want to allow to manage
   TriggerEvent('cs:idcard:openPlayerMenu', {'id_card', 'drive_card'})
   </code></pre>
2. <pre class="language-lua" data-title="Open Job Manage Menu"><code class="lang-lua"><strong>TriggerEvent('cs:idcard:openJobMenu', job_name)
   </strong></code></pre>
3. Event to give ID/Job Cards from different resources \[This will check if a player issued card]:

   ```lua
   TriggerEvent('cs:idcard:getCard', card_name)
   ```
4. Export to check whether a player has a certain card:

   <pre class="language-lua"><code class="lang-lua"><strong>exports['cs_idcard']:CheckID(card_name)
   </strong></code></pre>

### Server Side

1. Export to check whether a player has a certain card (server side):<br>

   ```lua
   exports['cs_idcard']:CheckID(Player_ID, card_name)
   ```
2. Export to give ID/Job Cards from different resources (server side):<br>

   ```lua
   exports['cs_idcard']:GiveCard(Player_ID, card_name)
   ```
3. Event to Register ID/Job Card To a Player:<br>

   ```lua
   exports['cs_idcard']:RegisterCard(Player_ID, card_name, addItem)

   Player_ID = Server ID of Player
   card_name = Card Name which you want to issue (Ex. id_card, drive_card)
   addItem = If you want to give that card as an item

   Example:
   exports['cs_idcard']:RegisterCard(source, 'id_card', true)
   ```
4. Event to Remove/Deregister ID/Job Card From a Player:<br>

   ```lua
   exports['cs_idcard']:RemoveCard(Player_ID, card_name)

   Player_ID = Server ID of Player
   card_name = Card Name which you want to issue (Ex. id_card, drive_card)

   Example:
   exports['cs_idcard']:RemoveCard(source, 'id_card')
   ```
