JixelPatterns
  • JixelPatterns Documentation
  • Troubleshooting
    • Common Issues
    • Setting Up Locations
    • FAQ
  • Dependency
    • Jim_Bridge
      • Animal Ped Support
      • Script Helpers
      • Loader Functions
      • Callbacks
      • Cameras
      • Context Menus
      • Crafting
      • DrawText
      • Dui Functions
      • Input Creator
      • Inventories
      • Job Functions
      • Make Functions
      • Meta Handlers
      • Notifications
      • Phones
      • Player Functions
      • Poly Zones
      • Progress Bars
      • Scale Entity
      • Shops
      • Skillcheck
      • Society Banking
      • Stash Control
      • Targets
      • Vehicles
      • Wrapper Functions
      • Scaleforms
  • Paid Assets
    • Jim-Mechanic
      • Common Issues
      • Installation
      • Locations
        • Creating a Location
      • Nitrous
      • Harness + Seatbelt
      • Emergency Repair Bench
      • Odometer
      • Speedometer
      • Performance Mods
      • Preview System
      • Repair System
      • Car Lifts
      • Plate Change
      • Push Vehicle
      • Stancer Kit
      • Vehicle Seat Picker
    • Jim-Bakery
      • Installation
    • Jim-BeanMachine
      • Installation
    • Jim-BurgerShot
      • Installation
    • Jim-CatCafe
      • Installation
    • Jim-Henhouse
      • Installation
    • Jim-PizzaThis
      • Installation
    • Jim-Popsdiner
      • Installation
  • Free Assets
    • Jim-Mining
      • Installation
      • How To Use
        • Mining
        • Stone Washing
        • Gold Panning
    • Jim-Recycle
      • Installation
      • How To Use
        • Recycling
        • Dumpster Diving
        • Scrapping
    • Jim-Payments
      • Installation
      • How To Use
    • Jim-Shops
      • Installation
      • How To Use
    • Jim-Boarding
      • Installation
      • How To Use
    • Jim-Trains
      • Installation
      • How To Use
    • Jim-Consumbles
      • Installation
      • How To Use
    • Jim-DJBooth
      • Installation
      • How To Use
    • Jim-JobGarage
      • Installation
      • How To Use
    • Jim-Chairs
      • Installation
    • Jim-Notepad
      • Installation
      • How To Use
Powered by GitBook
On this page
  • helpers.lua
  • isStarted(script)
  • getScript()
  • isServer()
  • debugPrint(...) / eventPrint(...)
  • jsonPrint(table)
  • keyGen()
  • cv(amount)
  • formatCoord(vec)
  • getCenterOfZones(coords)
  • countTable(tbl)
  • pairsByKeys(tbl)
  • concatenateText(tbl)
  • RotationToDirection(rot)
  • basicBar(percent)
  • normalizeVector(vec)
  • drawLine(start, end, color) / drawSphere(pos, color)
  • PerformRaycast(start, end, entity?, flags?)
  • adjustForGround(coords)
  • ensureNetToVeh(id) / ensureNetToEnt(id)
  • sendLog(text) / sendServerLog(data)
  • GetGroundMaterialAtPosition(coords)
  • GetPropDimensions(model)
  • GetEntityForwardVector(entity)
  1. Dependency
  2. Jim_Bridge

Script Helpers

helpers.lua

This utility module provides functions for resource checks, debugging, formatting, coordinate math, vector calculations, progress bars, and drawing tools.

isStarted(script)

  • Returns true if a resource is started.

Example:

if isStarted("myResource") then print("Resource is running") end

getScript()

Caches and returns the name of the current resource.

Easier than typing GetCurrentResourceName() over and over

Example:

print("Current script:", getScript())

isServer()

Returns true if running on the server.

This was mainly made becuase IsDuplicityVersion() kept confusing me

Example:

if isServer() then print("Server-side!") end

debugPrint(...) / eventPrint(...)

Prints messages with debug context if debugMode is enabled.

Example:

debugPrint("Loaded object:", objName)

jsonPrint(table)

Pretty-prints a table with colorized JSON if debugMode is enabled.

Example:

jsonPrint(myData)

keyGen()

Generates a 3-character unique ID.

Good grabbing randomly generated strings

Example:

print("Generated Key:", keyGen())

cv(amount)

Comma-separates a number (e.g., 1000000 to 1,000,000).

Example:

print(cv(1000000)) -- "1,000,000"

formatCoord(vec)

Outputs a formatted string from vector types.

Compacts and adds console colours to the vector to be printed

Example:

print(formatCoord(vector3(123.45, 678.9, 10.0)))

getCenterOfZones(coords)

Returns average center position of a vector3 list.

A few use cases, but I used it to see how well spaced blips were together

Example:

local center = getCenterOfZones({vector3(0,0,0), vector3(10,10,0)})

countTable(tbl)

Returns the number of entries in a table.

Simple function to print how many "entires" are in a table

Example:

print(countTable({a=1,b=2,c=3})) -- 3

pairsByKeys(tbl)

Iterator for sorted keys.

Example:

for k, v in pairsByKeys(myTable) do print(k, v) end

concatenateText(tbl)

Joins string table entries with newlines.

Example:

print(concatenateText({"Line 1", "Line 2"}))

RotationToDirection(rot)

Converts a heading vector to a directional vector.

Example:

local dir = RotationToDirection(rotation)

basicBar(percent)

Returns a bar like ████░░░░░ at 50%.

Basically a progress bar but as a string, I use this in drawTexts when progressbars aren't able to be used

Example:

print(basicBar(50))

normalizeVector(vec)

Returns a normalized version of a vector3.

Example:

local norm = normalizeVector(vector3(3,4,0))

drawLine(start, end, color) / drawSphere(pos, color)

Debug drawing helpers.

Stays visible for more than one frame

Example:

drawLine(vector3(0,0,0), vector3(10,10,10), vector4(255,0,0,255))
drawSphere(vector3(5,5,5), vector4(0,255,0,255))

PerformRaycast(start, end, entity?, flags?)

Raycast with material detection. Returns ray hit data.

If debugMode is on it will draw a line ti visualise the raycast being done

Example:

local hit, hitPos, material = PerformRaycast(startVec, endVec, playerPed, 1)
if hit == 1 then
    print("Hit at position:", hitPos)
    print("Material:", material)
end

adjustForGround(coords)

Adjusts a z-coordinate to ground height.

Example:

coords = adjustForGround(vector3(100, 200, 300))

ensureNetToVeh(id) / ensureNetToEnt(id)

Resolves net ID to entity safely.

Delays the checking of netID to local ID but stops FiveM network entity warnings

Example:

local veh = ensureNetToVeh(netId)

sendLog(text) / sendServerLog(data)

Logging helpers, includes player name, coords, script source.

Example:

sendLog("Suspicious activity detected")

GetGroundMaterialAtPosition(coords)

Returns the material hash + readable name from the surface below coords.

Example:

local hash, name = GetGroundMaterialAtPosition(vector3(0,0,0))

GetPropDimensions(model)

Loads a model and returns width, depth, height.

I use this to parse a model to create a box target instead of entity target when creating distProps/distPeds

Example:

local w,d,h = GetPropDimensions("prop_barrel_01a")

GetEntityForwardVector(entity)

Returns the forward direction vector based on entity heading.

Example:

local fwd = GetEntityForwardVector(PlayerPedId())

PreviousAnimal Ped SupportNextLoader Functions

Last updated 3 days ago