Register Weapon
π€ Export: CreateWeaponInfo
CreateWeaponInfoDescription
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
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
mdt_weaponsserialNumber
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:
π Example Usage
π‘ If
imageurlisnil, the function will automatically use the default image.
Last updated