Module sv_zones

Zone System

Functions

GetZoneFromID (identifier) GetZoneFromID function.
DeleteZone (identifier) DeleteZone function.
IsCoordsInAnyZones (coords) GetZones function.
IsPlayerInZone (player, zone) IsPlayerInZone function.
GetPlayersInZone (zone) GetPlayersInZone function.
GetAmountOfPlayersInZone (zone) GetAmountOfPlayersInZone function.
IsAnyPlayerInZone (zone) IsAnyPlayerInZone function.
GetPlayerZones (player) GetPlayerZones function.
TriggerEventInZone (zone, event, ...) TriggerEventInZone function.
AddPropToZone (zone, id, propData) AddPropToZone function.
RemovePropFromZone (zone, id) RemovePropFromZone function.
UpdatePropModelInZone (zone, id, model) UpdatePropModelInZone function.
UpdatePropCoordsInZone (zone, id, coords, offsets) UpdatePropCoordsInZone function.
UpdatePropTextInZone (zone, id, text) UpdatePropTextInZone function.
GetPropsFromZone (zone) GetPropsFromZone function.
AddVehicleToZone (zone, id, vehData) AddVehicleToZone function.
RemoveVehicleFromZone (zone, id) RemoveVehicleFromZone function.
UpdateVehicleInZone (zone, id, VehicleData) UpdateVehicleInZone function.
UpdateVehicleTextInZone (zone, id, text) UpdateVehicleTextInZone function.
UpdateVehicleModelInZone (zone, id, model) UpdateVehicleModelInZone function.
GetVehicleFromZone (zone, id) GetVehicleFromZone function.
GetVehiclesFromZone (zone) GetVehiclesFromZone function.
AddPedToZone (zone, id, pedData) AddPedToZone function.
RemovePedFromZone (zone, id) RemovePedFromZone function.
GetPedsFromZone (zone) GetPedsFromZone function.
GetPedFromZone (zone, id) GetPedFromZone function.
TriggerEvent (eventName, ...) TriggerEvent sub-function.
RegisterContextMenu (src, menu) RegisterContextMenu function.
DeleteContextMenu (src, menu) DeleteContextMenu function.
DeleteContextMenus (src) DeleteContextMenus function.
CreateInputDialog (src, name, options) CreateInputDialog function.

Tables

Interaction Interaction Table.
ControlBlip ControlBlip Table This table contains all the control blips in the zone or cicle.
Propdata Propdata Table.
VehicleData VehicleData Table.
PedData PedData Table.
Job Job Table.
ZoneData ZoneData Table.

CreatePolyZone

CreatePolyZone (identifier, points, minZ, maxZ, enterCallback, leaveCallback, ZoneData) CreatePolyZone function.
SetName (name) SetName sub-function.
GetName () GetName sub-function.
GetIdentifier () GetIdentifier sub-function.
Enter (src) Enter sub-function.
Leave (src) Leave sub-function.
Update (src) Update sub-function.

CreateCircleZone

CreateCircleZone (identifier, position, distance, height, enterCallback, leaveCallback, ZoneData) CreateCircleZone function.
SetName (name) SetName sub-function.
GetName () GetName sub-function.
Enter (src) Enter sub-function.
Leave (src) Leave sub-function.
Update (src) Update sub-function.
GetSize () GetSize sub-function.
TriggerEvent (eventName, ...) TriggerEvent sub-function.


Functions

GetZoneFromID (identifier)
GetZoneFromID function. If the zone or circle with the identifier "central_park" exists, it will be stored in the variable 'zone'. If no such zone or circle exists, 'zone' will be nil.

Parameters:

  • identifier A unique identifier for the zone or circle

Returns:

    The zone or circle corresponding to the identifier, or nil if no such zone or circle exists

Usage:

    local zone = exports.jones_util:GetZoneFromID("central_park")
DeleteZone (identifier)
DeleteZone function. This function deletes a zone or circle with the given identifier. If the zone or circle exists and has members, it will make each member leave the zone or circle. It then removes the zone or circle from the zones and circles tables. If the zone or circle does not exist, it prints a message to the console. This will delete the zone or circle with the identifier "central_park" if it exists.

Parameters:

  • identifier A unique identifier for the zone or circle

Usage:

    exports.jones_util:DeleteZone("central_park")
IsCoordsInAnyZones (coords)
GetZones function. This function checks if the given coordinates are inside any of the defined zones or circles. It iterates over all zones and checks if the coordinates are inside the zone using the GetInside function. It also iterates over all circles and checks if the coordinates are within the circle's distance from its center. If the coordinates are inside a zone or a circle, it adds the zone or circle's id to the currentZones table. It returns the currentZones table which contains the ids of all zones and circles the coordinates are inside of.

Parameters:

  • coords A table containing x, y, and z coordinates

Returns:

    table containing the ids of all zones and circles the coordinates are inside of.

Usage:

    local zones = exports.jones_util:IsCoordsInAnyZones({x = 100, y = 200, z = 300})
IsPlayerInZone (player, zone)
IsPlayerInZone function. This function checks if the given player is inside the given zone or circle.

Parameters:

  • player The player's server id
  • zone The zone or circle's id

Returns:

    boolean

Usage:

    local isPlayerInZone = exports.jones_util:IsPlayerInZone(1, "central_park")
GetPlayersInZone (zone)
GetPlayersInZone function. This function returns a table containing the server ids of all players inside the given zone or circle.

Parameters:

  • zone The zone or circle's id

Returns:

    table

Usage:

    local players = exports.jones_util:GetPlayersInZone("central_park")
GetAmountOfPlayersInZone (zone)
GetAmountOfPlayersInZone function. This function returns the amount of players inside the given zone or circle.

Parameters:

  • zone The zone or circle's id

Returns:

    number

Usage:

    local amount = exports.jones_util:GetAmountOfPlayersInZone("central_park")
IsAnyPlayerInZone (zone)
IsAnyPlayerInZone function. This function checks if there are any players inside the given zone or circle.

Parameters:

  • zone The zone or circle's id

Returns:

    boolean

Usage:

    local isAnyPlayerInZone = exports.jones_util:IsAnyPlayerInZone("central_park")
GetPlayerZones (player)
GetPlayerZones function. This function returns a table containing the ids of all zones and circles the given player is inside.

Parameters:

  • player The player's server id

Returns:

    table

Usage:

    local zones = exports.jones_util:GetPlayerZones(1)
TriggerEventInZone (zone, event, ...)
TriggerEventInZone function. This function triggers an event in the given zone or circle.

Parameters:

  • zone The zone or circle's id
  • event The event to be triggered
  • ... The arguments to be passed to the event

Usage:

    exports.jones_util:TriggerEventInZone("central_park", "event_name", ...)
AddPropToZone (zone, id, propData)
AddPropToZone function. This function adds a prop to the given zone or circle.

Parameters:

  • zone The zone or circle's id
  • id A unique identifier for the prop
  • propData A table containing the prop's data { model: string, x: number, y: number, z: number, h: number, offsets: vector3 interaction: { ["interaction_id"] = { name: string, icon: string, id: string, condition: function } }

See also:

Usage:

    exports.jones_util:AddPropToZone("central_park", "prop-1", {model = "prop_bench_01a", x = 100, y = 200, z = 300, h = 0, offsets = vector3(0.0, 0.0, 0.0)})
RemovePropFromZone (zone, id)
RemovePropFromZone function. This function removes a prop from the given zone or circle.

Parameters:

  • zone The zone or circle's id
  • id The prop's unique identifier

Usage:

    exports.jones_util:RemovePropFromZone("central_park", "prop-1")
UpdatePropModelInZone (zone, id, model)
UpdatePropModelInZone function. This function updates the model of a prop in the given zone or circle.

Parameters:

  • zone The zone or circle's id
  • id The prop's unique identifier
  • model The prop's new model

Usage:

    exports.jones_util:UpdatePropModelInZone("central_park", "prop-1", "prop_bench_01b")
UpdatePropCoordsInZone (zone, id, coords, offsets)
UpdatePropCoordsInZone function. This function updates the coordinates of a prop in the given zone or circle.

Parameters:

  • zone The zone or circle's id
  • id The prop's unique identifier
  • coords A table containing the prop's new coordinates
  • offsets A vector3 containing the prop's new offsets

Usage:

    exports.jones_util:UpdatePropCoordsInZone("central_park", "prop-1", {x = 100, y = 200, z = 300})
UpdatePropTextInZone (zone, id, text)
UpdatePropTextInZone function. This function updates the display text of a prop in the given zone or circle.

Parameters:

  • zone The zone or circle's id
  • id The prop's unique identifier
  • text The prop's new display text

Usage:

    exports.jones_util:UpdatePropTextInZone("central_park", "prop-1", "Prop Name")
GetPropsFromZone (zone)
GetPropsFromZone function. This function returns a table containing all the props in the given zone or circle.

Parameters:

  • zone The zone or circle's id

Returns:

    table

See also:

Usage:

    local props = exports.jones_util:GetPropsFromZone("central_park")
AddVehicleToZone (zone, id, vehData)
AddVehicleToZone function. This function adds a vehicle to the given zone or circle.

Parameters:

  • zone The zone or circle's id
  • id A unique identifier for the vehicle
  • vehData A table containing the vehicle's data

See also:

Usage:

    exports.jones_util:AddVehicleToZone("central_park", "vehicle-1", {model = "adder", x = 100, y = 200, z = 300, h = 0, props = {}})
RemoveVehicleFromZone (zone, id)
RemoveVehicleFromZone function. This function removes a vehicle from the given zone or circle.

Parameters:

  • zone The zone or circle's id
  • id The vehicle's unique identifier

Usage:

    exports.jones_util:RemoveVehicleFromZone("central_park", "vehicle-1")
UpdateVehicleInZone (zone, id, VehicleData)
UpdateVehicleInZone function. This function updates the model and props of a vehicle in the given zone or circle.

Parameters:

  • zone The zone or circle's id
  • id The vehicle's unique identifier
  • VehicleData A table containing the vehicle's new props

See also:

Usage:

    exports.jones_util:UpdateVehicleInZone("central_park", "vehicle-1", {model = "adder", props = {}})
UpdateVehicleTextInZone (zone, id, text)
UpdateVehicleTextInZone function. This function updates the display text of a vehicle in the given zone or circle.

Parameters:

  • zone The zone or circle's id
  • id The vehicle's unique identifier
  • text The vehicle's new display text

Usage:

    exports.jones_util:UpdateVehicleTextInZone("central_park", "vehicle-1", "Vehicle Name")
UpdateVehicleModelInZone (zone, id, model)
UpdateVehicleModelInZone function. This function updates the model of a vehicle in the given zone or circle.

Parameters:

  • zone The zone or circle's id
  • id The vehicle's unique identifier
  • model The vehicle's new model

Usage:

    exports.jones_util:UpdateVehicleModelInZone("central_park", "vehicle-1", "adder")
GetVehicleFromZone (zone, id)
GetVehicleFromZone function. This function returns a table containing the vehicle in the given zone or circle.

Parameters:

  • zone The zone or circle's id
  • id The vehicle's unique identifier

Returns:

    VehicleData

See also:

Usage:

    local vehicle = exports.jones_util:GetVehicleFromZone("central_park", "vehicle-1")
GetVehiclesFromZone (zone)
GetVehiclesFromZone function. This function returns a table containing all the vehicles in the given zone or circle.

Parameters:

  • zone The zone or circle's id

Returns:

    table containing all the vehicles in the given zone or circle.

See also:

Usage:

    local vehicles = exports.jones_util:GetVehiclesFromZone("central_park")
AddPedToZone (zone, id, pedData)
AddPedToZone function. This function adds a ped to the given zone or circle.

Parameters:

  • zone The zone or circle's id
  • id A unique identifier for the ped
  • pedData A table containing the ped's data

See also:

Usage:

    exports.jones_util:AddPedToZone("central_park", "ped-1", {model = "a_m_m_beach_01", x = 100, y = 200, z = 300, h = 0})
RemovePedFromZone (zone, id)
RemovePedFromZone function. This function removes a ped from the given zone or circle.

Parameters:

  • zone The zone or circle's id
  • id The ped's unique identifier

Usage:

    exports.jones_util:RemovePedFromZone("central_park", "ped-1")
GetPedsFromZone (zone)
GetPedsFromZone function. This function returns a table containing all the peds in the given zone or circle.

Parameters:

  • zone The zone or circle's id

Returns:

    table

See also:

Usage:

    local peds = exports.jones_util:GetPedsFromZone("central_park")
GetPedFromZone (zone, id)
GetPedFromZone function. This function returns a table containing the ped in the given zone or circle.

Parameters:

  • zone The zone or circle's id
  • id The ped's unique identifier

Returns:

    PedData

See also:

Usage:

    local ped = exports.jones_util:GetPedFromZone("central_park", "ped-1")
TriggerEvent (eventName, ...)
TriggerEvent sub-function. This function triggers an event in the zone or circle.

Parameters:

  • eventName The event to be triggered
  • ... The arguments to be passed to the event

Usage:

    exports.jones_util:GetZoneFromID("central_park").TriggerEvent("event_name", ...)
RegisterContextMenu (src, menu)
RegisterContextMenu function. This function registers a context menu for the given player.

Parameters:

  • src The player's server id
  • menu The context menu to be registered

Usage:

    exports.jones_util:RegisterContextMenu(1, {
    	id = "example",
    	title = "Example",
    	options = {
    		{
    			name = "Option 1",
    			icon = "fas fa-user",
    			execute = function(src)
    				print(src)
    			end
    		},
    	}
    })
DeleteContextMenu (src, menu)
DeleteContextMenu function. This function deletes a context menu for the given player.

Parameters:

  • src The player's server id
  • menu The context menu to be deleted

Usage:

    exports.jones_util:DeleteContextMenu(1, "example")
DeleteContextMenus (src)
DeleteContextMenus function. This function deletes all context menus for the given player.

Parameters:

  • src The player's server id

Usage:

    exports.jones_util:DeleteContextMenus(1)
CreateInputDialog (src, name, options)
CreateInputDialog function. This function creates an input dialog for the given player.

Parameters:

  • src The player's server id
  • name The input dialog's name
  • options The arguments to be passed to the input dialog

Usage:

    exports.jones_util:CreateInputDialog(1, "example", {"first row", "second row"})

Tables

Interaction
Interaction Table. This table contains all the interactions in the zone or circle. This table needs to have a key for each interaction id.

Fields:

  • name The interaction's name
  • icon The interaction's icon
  • id The interaction's id
  • condition The interaction's condition function

Usage:

    local interactions = {
    	["interaction_id"] = {
    		name = "Interaction Name",
    		icon = "fa-regular fa-icon",
    		id = "interaction_id",
    		condition = function(src)
    			return true
    		end
    	}
    }
ControlBlip
ControlBlip Table This table contains all the control blips in the zone or cicle. This table needs to have a key for each control blip id.

Fields:

  • text The control blip's display text
  • pos The control blip's location
  • condition The control blip's condition function

Usage:

    local controlBlips = {
    ["claim_controlBlip"] = {
    	text = "Claim",
    	pos = vector3(0, 0, 0)
    	condition = function(src)
    		return true
    	end
    }
Propdata
Propdata Table. This table contains all the props in the zone or circle.

Fields:

  • model The prop's model
  • x The prop's x coordinate
  • y The prop's y coordinate
  • z The prop's z coordinate
  • h The prop's heading
  • offsets The prop's offsets
  • interaction The prop's interactions table

See also:

VehicleData
VehicleData Table. This table contains all the vehicles in the zone or circle.

Fields:

  • model The vehicle's model
  • x The vehicle's x coordinate
  • y The vehicle's y coordinate
  • z The vehicle's z coordinate
  • h The vehicle's heading
  • props The vehicle's props
  • displayText The vehicle's display text
  • interaction The vehicle's interactions table

See also:

PedData
PedData Table. This table contains all the peds in the zone or circle.

Fields:

  • model The ped's model
  • x The ped's x coordinate
  • y The ped's y coordinate
  • z The ped's z coordinate
  • h The ped's heading
  • interaction The ped's interactions table

See also:

Job
Job Table. This table contains all the jobs in the zone or circle. This table needs to have a key for each job id.

Usage:

    local jobs = {
    	"police",
    	"ambulance"
    }
ZoneData
ZoneData Table. This table contains all the metadata for the zone or circle.

Fields:

  • interactions The zone or circle's interactions table
  • jobs The zone or circle's jobs table
  • condition The zone or circle's condition function
  • bucket The zone or circle's bucket
  • controlBlips The zone or circle's control blips table

See also:

CreatePolyZone

CreatePolyZone (identifier, points, minZ, maxZ, enterCallback, leaveCallback, ZoneData)
CreatePolyZone function. This function creates a zone or circle with the given identifier.

Parameters:

  • identifier A unique identifier for the zone or circle
  • points A table containing the zone or circle's points vector2 coordinates
  • minZ The zone or circle's minimum z coordinate
  • maxZ The zone or circle's maximum z coordinate
  • enterCallback The function to be called when a player enters the zone or circle
  • leaveCallback The function to be called when a player leaves the zone or circle
  • ZoneData A table containing the zone or circle's metadata

See also:

Usage:

    exports.jones_util:CreatePolyZone("central_park", {{x = 100, y = 200}, {x = 300, y = 400}, {x = 500, y = 600}}, -100, 100, function(src) print(src) end, function(src) print(src) end, {})
SetName (name)
SetName sub-function. This function sets the zone or circle's name.

Parameters:

  • name The zone or circle's name

Usage:

    exports.jones_util:GetZoneFromID("central_park").SetName("Central Park")
GetName ()
GetName sub-function. This function returns the zone or circle's name.

Returns:

    string

Usage:

    local name = exports.jones_util:GetZoneFromID("central_park").GetName()
GetIdentifier ()
GetIdentifier sub-function. This function returns the zone or circle's identifier.

Returns:

    string

Usage:

    local identifier = exports.jones_util:GetZoneFromID("central_park").GetIdentifier()
Enter (src)
Enter sub-function. This function makes the given player enter the zone or circle.

Parameters:

  • src The player's server id

Usage:

    exports.jones_util:GetZoneFromID("central_park").Enter(1)
Leave (src)
Leave sub-function. This function makes the given player leave the zone or circle.

Parameters:

  • src The player's server id

Usage:

    exports.jones_util:GetZoneFromID("central_park").Leave(1)
Update (src)
Update sub-function. This function updates the zone or circle.

Parameters:

  • src The player's server id

Usage:

    exports.jones_util:GetZoneFromID("central_park").Update()

CreateCircleZone

CreateCircleZone (identifier, position, distance, height, enterCallback, leaveCallback, ZoneData)
CreateCircleZone function. This function creates a circle with the given identifier.

Parameters:

  • identifier A unique identifier for the circle
  • position A vector3 containing the circle's position
  • distance The circle's distance
  • height The circle's height
  • enterCallback The function to be called when a player enters the circle
  • leaveCallback The function to be called when a player leaves the circle
  • ZoneData A table containing the circle's metadata

See also:

Usage:

    exports.jones_util:CreateCircleZone("central_park", vector3(100, 200, 300), 100.0, 100.0, function(src) print(src) end, function(src) print(src) end, {})
SetName (name)
SetName sub-function. This function sets the circle's name.

Parameters:

  • name The circle's name

Usage:

    exports.jones_util:GetZoneFromID("central_park").SetName("Central Park")
GetName ()
GetName sub-function. This function returns the circle's name.

Returns:

    string

Usage:

    local name = exports.jones_util:GetZoneFromID("central_park").GetName()
Enter (src)
Enter sub-function. This function makes the given player enter the circle.

Parameters:

  • src The player's server id

Usage:

    exports.jones_util:GetZoneFromID("central_park").Enter(1)
Leave (src)
Leave sub-function. This function makes the given player leave the circle.

Parameters:

  • src The player's server id

Usage:

    exports.jones_util:GetZoneFromID("central_park").Leave(1)
Update (src)
Update sub-function. This function updates the circle.

Parameters:

  • src The player's server id

Usage:

    exports.jones_util:GetZoneFromID("central_park").Update()
GetSize ()
GetSize sub-function. This function returns the circle's distance and height.

Returns:

  1. float The circle's distance
  2. float The circle's height

Usage:

    local distance, height = exports.jones_util:GetZoneFromID("central_park").GetSize()
TriggerEvent (eventName, ...)
TriggerEvent sub-function. This function triggers an event in the circle.

Parameters:

  • eventName The event to be triggered
  • ... The arguments to be passed to the event

Usage:

    exports.jones_util:GetZoneFromID("central_park").TriggerEvent("event_name", ...)
generated by LDoc 1.5.0 Last updated 2024-05-13 19:05:24