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
| Name | Type | Required | Description |
|---|---|---|---|
propertyId | number | string | ✅ | Property ID to grant access to. |
targetCid | string | ✅ | Citizen ID receiving the key. |
grantedByCid | string | ❌ | Citizen ID granting the key (defaults to 'phone' if omitted). |
📤 Returns
| Type | Description |
|---|---|
table | Result 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