Register Weapon
๐ค Export: CreateWeaponInfo
Description
The CreateWeaponInfo function exports weapon data to the mdt_weapons table in the database. It is used to associate a weapon serial number with a citizen, weapon model, and optionally an image. If the weapon serial already exists, it updates the relevant fields.
โ Function Signature
exports['kartik-mdt']:CreateWeaponInfo(serial, imageurl, citizenid, weaponname)๐ฅ Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
serial | string | โ Yes | The unique serial number of the weapon. |
imageurl | string | โ No | Optional image URL of the weapon. If not provided, a default image is used. |
citizenid | string | โ Yes | The citizen ID of the owner of the weapon. |
weaponname | string | โ Yes | The model name or type of the weapon. |
๐๏ธ Database Table: mdt_weapons
| Column Name | Type | Description |
|---|---|---|
serialNumber | VARCHAR | Primary key, unique weapon serial. |
citizenId | VARCHAR | The citizen ID linked to the weapon. |
weaponName | VARCHAR | Name/model of the weapon. |
image | TEXT | URL of the image representing weapon. |
โ๏ธ Function Logic
- Checks if a weapon with the given serial number already exists.
- If not, inserts a new record with the provided details.
- If it exists, updates the existing record with the latest
citizenId,weaponName, andimage.
๐ผ๏ธ Default Image
If no imageurl is provided, the following default image URL is used:
https://kappa.lol/hObsm7๐ Example Usage
local serial = "WEAPON123456"
local imageurl = "https://example.com/images/pistol.png"
local citizenid = "CIT1234"
local weaponname = "Pistol"
exports['kartik-mdt']:CreateWeaponInfo(serial, imageurl, citizenid, weaponname)๐ก If
imageurlisnil, the function will automatically use the default image.