Lot natives
Lots are the homes, venues and community spaces of a world, identified by their ZoneId (a string).
Developer Preview. Scripting is live on Neighborly servers – everything on these pages works today. The API is young, so tell us what you need next on Discord.
Lots are the homes, venues and community spaces of a world, identified by their ZoneId (a string). The server knows every lot and who owns it; clients know the lots of the server they are connected to.
Open in the natives browser Search all 199 natives at once.
GetCurrentLot
ZoneId? GetCurrentLot()Returns the lot the local player is on.
Changes only when the player travels. Instead of polling it, listen to lotEntered and lotLeft and keep the value in a local.
Parameters
This native takes no parameters.
Returns
ZoneId? Lot the local player is on.
Example
RegisterCommand('where', function()
local zoneId = GetCurrentLot()
if not zoneId then
return ShowToast('You are travelling.')
end
ShowToast(('%s · %s'):format(GetLotName(zoneId), GetWorldName(GetLotWorld(zoneId))), 3000)
end, false)GetLotName
string GetLotName(ZoneId zoneId)Returns a lot's name.
Available in client and server scripts. On a client it reads the synced copy of the world, which can trail the server by a moment – make gameplay decisions on the server.
Parameters
| Parameter | Type | Description |
|---|---|---|
zoneId | ZoneId | Zone id of the lot. |
Returns
string The lot's name.
Example
AddEventHandler('lotEntered', function(zoneId)
exports.neighborly:notify({ text = 'Welcome to ' .. GetLotName(zoneId), icon = 'house', duration = 3000 })
end)GetLotOwner
HouseholdId? GetLotOwner(ZoneId zoneId)Returns the household that owns a lot.
Use GetLotOwnerPlayer when you want to send an event to the owner – it returns their server id while they are online.
Parameters
| Parameter | Type | Description |
|---|---|---|
zoneId | ZoneId | Zone id of the lot. |
Returns
HouseholdId? Household that owns the lot.
Example
RegisterNetEvent('rtx_doorbell:ring', function(zoneId)
local src = source
if GetLotOwner(zoneId) == GetPlayerHousehold(src) then
return TriggerClientEvent('neighborly:notify', src, { text = 'This is your own home.' })
end
local owner = GetLotOwnerPlayer(zoneId)
if owner then
TriggerClientEvent('rtx_doorbell:ding', owner, GetPlayerName(src))
end
end)GetLotType
string GetLotType(ZoneId zoneId)Returns the lot type.
Rental lots need For Rent (EP15) on the server. Community lots have no owner household.
Parameters
| Parameter | Type | Description |
|---|---|---|
zoneId | ZoneId | Zone id of the lot. |
Returns
string 'residential', 'community' or 'other'.
Example
if GetLotType(zoneId) ~= 'residential' then
return
endGetLotValue
int GetLotValue(ZoneId zoneId)Returns what the lot is worth.
Available in client and server scripts. On a client it reads the synced copy of the world, which can trail the server by a moment – make gameplay decisions on the server.
Parameters
| Parameter | Type | Description |
|---|---|---|
zoneId | ZoneId | Zone id of the lot. |
Returns
int Value in simoleons including furniture.
Example
RegisterCommand('appraise', function()
local zoneId = GetCurrentLot()
if not zoneId then
return
end
ShowNotification(('%s is worth %s.'):format(GetLotName(zoneId), FormatMoney(GetLotValue(zoneId))), {
title = 'Home appraisal',
icon = 'house'
})
end, false)IsLotPublic
boolean IsLotPublic(ZoneId zoneId)Checks whether a lot is open to all players.
Public lots can be visited by anyone without an invitation. Residential lots belong to a household.
Parameters
| Parameter | Type | Description |
|---|---|---|
zoneId | ZoneId | Zone id of the lot. |
Returns
boolean true if anyone may visit.
Example
if not IsLotPublic(zoneId) then
exports.neighborly:notify({ text = 'This is a private home.', type = 'warning' })
endGetLotWorld
string GetLotWorld(ZoneId zoneId)Returns the world a lot is in.
Available in client and server scripts. On a client it reads the synced copy of the world, which can trail the server by a moment – make gameplay decisions on the server.
Parameters
| Parameter | Type | Description |
|---|---|---|
zoneId | ZoneId | Zone id of the lot. |
Returns
string World id.
Example
RegisterNetEvent('rtx_taxi:quote', function(zoneId)
local src = source
local from = GetPlayerLot(src)
if type(zoneId) ~= 'string' or not from or not GetLotName(zoneId) then
return
end
local price = GetLotWorld(zoneId) == GetLotWorld(from) and 25 or 60
TriggerClientEvent('neighborly:notify', src, {
text = ('A ride to %s in %s costs %s.'):format(GetLotName(zoneId), GetLotWorld(zoneId), FormatMoney(price))
})
end)GetLotsInWorld
table GetLotsInWorld(string world)Returns every lot in a world.
Available in client and server scripts. On a client it reads the synced copy of the world, which can trail the server by a moment – make gameplay decisions on the server.
Parameters
| Parameter | Type | Description |
|---|---|---|
world | string | World id, see GetWorlds. |
Returns
table List of zone ids.
Example
for _, zoneId in ipairs(GetLotsInWorld('willow_creek')) do
if GetLotOwner(zoneId) == nil and GetLotType(zoneId) == 'residential' then
print('For sale:', GetLotName(zoneId))
end
endSee also
GetSimsOnLot
table GetSimsOnLot(ZoneId? zoneId)Returns every Sim on the lot the local player is on.
Client only: it runs on the local player's PC and affects only their game. Other players don't see the result unless you tell the server.
Parameters
| Parameter | Type | Description |
|---|---|---|
zoneId | ZoneId? | Must be the lot you are on. Leave it out for the current lot. |
Returns
table List of Sims, including townies. Other players' Sims are returned with their real ids.
Example
CreateThread(function()
while true do
local zoneId = GetCurrentLot()
if zoneId then
SendNUIMessage({ action = 'crowd', count = #GetSimsOnLot(zoneId) })
end
Wait(5000)
end
end)GetPlayersOnLot
table GetPlayersOnLot(ZoneId zoneId)Returns the players whose Sims are on a lot.
The fastest way to send something to “everyone here” – loop over it and trigger a client event for each player.
Parameters
| Parameter | Type | Description |
|---|---|---|
zoneId | ZoneId | Zone id of the lot. |
Returns
table List of server ids.
Example
for _, player in ipairs(GetPlayersOnLot(zoneId)) do
TriggerClientEvent('neighborly:notify', player, { text = 'Last call!' })
endTravelToLot
boolean TravelToLot(Player player, ZoneId zoneId)Sends a player's Sim to another lot with the normal travel loading screen. On a client, call it with just the zone id to travel yourself.
Respects locks and privacy: returns false when the player isn't allowed on that lot.
Parameters
| Parameter | Type | Description |
|---|---|---|
player | Player | Server id of the player. |
zoneId | ZoneId | Zone id of the lot. |
Returns
boolean false if the lot doesn't exist.
Example
RegisterNetEvent('rtx_taxi:go', function(zoneId)
local src = source
if IsLotPublic(zoneId) and TakeMoney(src, 20, 'Taxi') then
TravelToLot(src, zoneId)
end
end)GetLotOwnerPlayer
Player? GetLotOwnerPlayer(ZoneId zoneId)Returns the player who owns a lot, if they are connected.
Server only. To show the result in a client UI, return it from a server callback or publish it in a state bag.
Parameters
| Parameter | Type | Description |
|---|---|---|
zoneId | ZoneId | Zone id of the lot. |
Returns
Player? Server id of the owner while they are online.
Example
RegisterNetEvent('rtx_doorbell:ring', function(zoneId)
local owner = GetLotOwnerPlayer(zoneId)
if owner then
TriggerClientEvent('rtx_doorbell:ding', owner, GetPlayerName(source))
end
end)GetLotOwnerAccount
string? GetLotOwnerAccount(ZoneId zoneId)Returns the account id of a lot's owner, even when they are offline.
Server only. To show the result in a client UI, return it from a server callback or publish it in a state bag.
Parameters
| Parameter | Type | Description |
|---|---|---|
zoneId | ZoneId | Zone id of the lot. |
Returns
string? Account id of the owner.
Example
local db = exports.neighborly:db()
RegisterNetEvent('rtx_mail:send', function(zoneId, text)
local owner = GetLotOwnerAccount(zoneId)
if owner and type(text) == 'string' then
db:set('mail:' .. owner .. ':' .. os.time(), { from = GetPlayerName(source), text = text:sub(1, 200) })
end
end)