Kartik Scripts

GrantHousingKey

exports['kartik-properties']:GrantHousingKey(propertyId, targetCid, grantedByCid)

🔹 Description

Grants a digital key (and optional physical key item if Config.PhysicalKeys.enabled is active) to a citizen for a specific property. Automatically updates database records and logs an audit trail.


🔧 Parameters

NameTypeRequiredDescription
propertyIdnumber | string✅Property ID to grant access to.
targetCidstring✅Citizen ID receiving the key.
grantedByCidstring❌Citizen ID granting the key (defaults to 'phone' if omitted).

📤 Returns

TypeDescription
tableResult table { success = true/false, data = { name, identifier }, msg = '...' }.

🧠 Example Usage

local result = exports['kartik-properties']:GrantHousingKey(12, 'XYZ98765', 'ABC12345')

if result.success then
    print('Key granted successfully to ' .. result.data.name)
else
    print('Failed to grant key: ' .. tostring(result.msg))
end

On this page