Kartik Scripts

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

ParameterTypeRequiredDescription
serialstringโœ… YesThe unique serial number of the weapon.
imageurlstringโŒ NoOptional image URL of the weapon. If not provided, a default image is used.
citizenidstringโœ… YesThe citizen ID of the owner of the weapon.
weaponnamestringโœ… YesThe model name or type of the weapon.

๐Ÿ—‚๏ธ Database Table: mdt_weapons

Column NameTypeDescription
serialNumberVARCHARPrimary key, unique weapon serial.
citizenIdVARCHARThe citizen ID linked to the weapon.
weaponNameVARCHARName/model of the weapon.
imageTEXTURL of the image representing weapon.

โš™๏ธ Function Logic

  1. Checks if a weapon with the given serial number already exists.
  2. If not, inserts a new record with the provided details.
  3. If it exists, updates the existing record with the latest citizenId, weaponName, and image.

๐Ÿ–ผ๏ธ 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 imageurl is nil, the function will automatically use the default image.


On this page