NSS Docs
DiscordStoreHomepage
nss_libs
nss_libs
  • README
  • Changelog
  • UI components
    • NssUiApi basics
    • NssAudio
    • NssButton
    • NssClient
    • NssConfirm
    • NssHelper
    • NssLoadingIndicator
    • NssModal
    • NssPadLock
    • NssResponsive
    • NssSimpleTextEditor
    • NssSvgReplacer
    • NssTextBox
    • NssTip
  • Client/server modules
    • AttachProp
    • Blip
    • Character
      • Client Character
      • Server Character
    • Chunk
    • ClientEvent
    • ConfigValidator
    • Database
    • DatabaseUpdater
    • DependencyAutoRestart
    • Discord
    • EntityInRange
    • Helper
      • Client Helper
      • Server Helper
      • Shared Helper
    • Inventory
    • Keyboard
    • Notify
    • Npc
    • ParticleFxPlayer
    • PointInRange
    • Prompts
    • ServerEvent
    • VersionCheck
Powered by GitBook
On this page
  • Example
  • TODO

Was this helpful?

  1. Client/server modules

PointInRange

Important: Do not use this module if your radius is higher than 10m because this results in a massive count of chunks and the more chunks exists the more performance and memory usage is needed. Example: A radius of 100m results in 40x40x40 chunks, so 68000 chunks. This is too much for the PointInRange API. Use the Chunk module instead.

Example

---@type NssLibsPointInRangeApi
local pir_api = exports.nss_libs:getPointInRangeApi(GetCurrentResourceName())

---@type NssLibsPointInRangeListenerApi
local pir_listener
local radius = 10.0
local x, y, z = 0.0, 0.0, 0.0

local on_enter = function()

    -- Do something when player enters the radius
    print("Entered the location")

    -- Ensure the player can only enter once for all time ;)
    if pir_listener then
        pir_listener.remove()
    end
end

local on_leave = function()

    -- Do something when player leaves the radius
    print("Left the location")
end

-- Ignore the nearest check
pir_listener = pir_api.add(x, y, z, radius, on_enter, on_leave, pir_api.IGNORE_NEAREST_CHECK)

-- Nearest point wins (excluding points that ignore the nearest check)
pir_listener = pir_api.add(x, y, z, radius, on_enter, on_leave)

TODO

PreviousParticleFxPlayerNextPrompts

Last updated 1 year ago

Was this helpful?