Kartik Scripts

AssignStarterApartment

exports['kartik-properties']:AssignStarterApartment(source, propertyId)

๐Ÿ”น Description

Moves a player into a starter apartment from another resource, such as a custom multicharacter or spawn script. It:

  1. Creates a weekly lease at the unit's starter rent (the landlord is the unit's owner: company, job or state).
  2. Grants the player a key (granted_by = 'starter').
  3. Takes the unit off the market and locks it.
  4. Sets the inside_property metadata so the player spawns inside on their next load.
  5. Updates the unit straight away: it shows in the entrance Select Unit list and the tablet building directory, and the player's map pins refresh. For a starter pool unit, the pool also files its next waiting unit.

The player can already be loaded (for example when the export is called from an NPC at a real estate office). No restart or relog is needed.


๐Ÿ”ง Parameters

NameTypeRequiredDescription
sourcenumberโœ…Server id of the player to move in.
propertyIdnumber | stringโœ…Id of a unit flagged as a starter.

๐Ÿ“ค Returns

TypeDescription
booleantrue on success, or if this player already leases the unit (nothing is created twice). false if the player has no character, the unit doesn't exist, isn't a starter, is frozen, or is already leased to another player.

๐Ÿง  Example Usage

RegisterNetEvent('my-multichar:server:pickedStarter', function(propertyId)
    local src = source
    if exports['kartik-properties']:AssignStarterApartment(src, propertyId) then
        TriggerClientEvent('kartik-properties:client:spawnInStarter', src, propertyId)
    end
end)

๐Ÿ“Œ Notes

This export does not check whether the starter system is switched on, or whether the player already has another home. It does refuse a unit that is leased to another player, so a false result can mean "pick another unit".

  • The built-in starter flow (auto-assign / selection screen) does not need this export. It is only for custom spawn flows.
  • See Starter Apartments for how starters are flagged and supplied.

On this page