Developer Preview

Packs natives

Find out which packs the server requires and which ones players own.

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.

Find out which packs the server requires and which ones players own.

Open in the natives browser Search all 199 natives at once.

IsPackInstalled

Client
boolean IsPackInstalled(string pack)

Checks whether the local player has a pack installed, even if the server doesn't require it.

A pack the player owns but the server doesn't require can't be used for shared gameplay – other players may not have it. Use it for local extras only.

Parameters

ParameterTypeDescription
packstringPack code like 'EP01'.

Returns

boolean Whether the local player owns it.

Example

if IsPackInstalled('SP13') then
    print('You have Laundry Day')
end

GetRequiredPacks

Shared
table GetRequiredPacks()

Returns the packs every player on this server has.

Every player on the server owns all of these, so objects, worlds and interactions from them are safe to use.

Parameters

This native takes no parameters.

Returns

table Pack codes from requiredPacks.

Example

local seasons = false
for _, pack in ipairs(GetRequiredPacks()) do
    if pack == 'EP05' then
        seasons = true
    end
end

GetPlayerPacks

Server
table GetPlayerPacks(Player player)

Returns every pack a player owns.

Server only. To show the result in a client UI, return it from a server callback or publish it in a state bag.

Parameters

ParameterTypeDescription
playerPlayerServer id of the player.

Returns

table Pack codes the player owns.

Example

RegisterCommand('packs', function(source, args)
    local target = tonumber(args[1]) or source
    local names = {}
    for _, pack in ipairs(GetPlayerPacks(target)) do
        names[#names + 1] = GetPackName(pack)
    end
    print(('%s owns %d packs: %s'):format(GetPlayerName(target), #names, table.concat(names, ', ')))
end, true)

DoesPlayerHavePack

Server
boolean DoesPlayerHavePack(Player player, string pack)

Checks one pack for one player.

Server only. To show the result in a client UI, return it from a server callback or publish it in a state bag.

Parameters

ParameterTypeDescription
playerPlayerServer id of the player.
packstringPack code.

Returns

boolean Whether they own it.

Example

if DoesPlayerHavePack(source, 'EP04') then
    TriggerClientEvent('rtx_pets:unlock', source)
end

GetPackName

Shared
string GetPackName(string pack)

Returns a pack's name, like 'Get to Work' for EP01.

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

ParameterTypeDescription
packstringPack code.

Returns

string Display name.

Example

AddEventHandler('onResourceStart', function(name)
    if name ~= GetCurrentResourceName() then
        return
    end
    local names = {}
    for _, pack in ipairs(GetRequiredPacks()) do
        names[#names + 1] = GetPackName(pack)
    end
    print('Packs on this server: ' .. table.concat(names, ', '))
end)

GetAllPacks

Shared
table GetAllPacks()

Returns all pack codes Neighborly knows about.

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

This native takes no parameters.

Returns

table Every known pack code.

Example

for _, pack in ipairs(GetAllPacks()) do
    print(pack, GetPackName(pack))
end