[FREE] Developer LUA Utility Library v1.8.0

BOII Development - LUA Utility Library


Introduction

Welcome to boii_utils, a comprehensive utility resource tailored for game developers and server administrators.

Our suite of tools is designed to simplify, streamline, and enhance the development process, offering a wide range of functionalities that span from string manipulations to table operations, and from input validations to miscellaneous utilities.

Utility library now includes a collection of framework bridge functions to allow for easier multi-framework compatible script development. Currently covers boii_base our soon to be released framework, qb-core, esx_legacy and ox_core. For other frameworks you will have to integrate your own setup into the existing functions. This should be relatively straight forward.


Why boii_utils?

  • :hammer_and_wrench: Developer’s Swiss Army Knife: Welcome to boii_utils, your one-stop-shop for a multitude of development utilities. From string manipulations, table operations, to input validations, even framework bridges. We’ve got you covered.
  • :wrench: Modularity at its Best: Why bear the brunt of unnecessary overhead? With boii_utils, pick only what you need, ensuring a lightweight and optimized experience.
  • :rocket: Optimized Performance: We understand the need for speed in gaming. That’s why our utilities are honed for top-tier performance and minimal resource usage.
  • :books: Comprehensive Yet Simple: Dive into a rich suite of functionalities. Whether it’s string operations, table manipulations, or input validations, we’ve curated it all for you. And the best part? It’s all neatly documented for your ease.
  • :link: Extensible by Design: While boii_utils is vast, we’ve made sure you can easily extend or modify it, tailoring the utilities library to your unique needs.

Features

:earth_africa: Shared Utilities

  • Debug: Debugging functions for quick and formatted debug notes.
  • General: General use functions for boolean values, string operations, coalesce, emulated try-catch behavior, and more.
  • Geometry: A broad selection of geometry functions to simplify complex mathematical operations.
  • Maths: Extensive mathematical functions for various calculations and operations.
  • Strings: String manipulation functions for data processing and manipulation.
  • Tables: Functions for efficient table operations and data management.
  • Validation: Robust functions for data validation to ensure data integrity.
  • Networking: Networking functions for reliable and efficient data communication.
  • Serialization: Functions for data serialization, simplifying data storage and transmission.
  • Keys: Key management functions for efficient key operations.
  • Default Ped Styles: Table data to store default style values for anything to do with character creation. (v1.1.0 update)

:desktop_computer: Server-Specific Utilities

  • Notifications: Server-side notification system for alerts and information dissemination.
  • Database: Core database functionalities for server data management.
  • Date & Time: Functions to manage and manipulate server-side date and time settings.
  • Networking: Advanced networking functions for server-client communication.
  • Scopes: Scope management for efficient player handling.
  • Callbacks: Event handling and callback functions.
  • Frameworks: Bridge functions for various server frameworks to provide an area to help with multi-framework script development.
  • Conversions: Data conversion utilities for framework data types into data used by the built-in utils systems.
  • Groups: Complete player group system.
  • Skills: Complete player skill system.
  • Reputation: Complete player reputation system.
  • Licences: Complete player licence system.
  • Items: Functions to allow for creating usable items.
  • Connections: Section to handle player connection logic and creating user accounts for use in later additions (e.g., command systems, priority systems). (v1.0.0 update)
  • Commands: Setup to handle registering server side commands, validating a users permissions to use and setting chat suggestions. (v1.0.0 update)
  • Commands List: Section of pre-defined commands. (v1.0.0 update)
  • Version Checks: Section to check resources versions against a github repo json file. (v1.2.0 update)
  • Cooldowns: Section to set and manage cooldowns across resources. (v1.4.0 update)
  • Zones: Section to manage zones throughout the server. (v1.5.0 update)

:video_game: Client-Side Utilities

  • Notifications: Functions for creating and managing client-side notifications.
  • Requests: Handling of native request functions, for example, RequestModel().
  • Entities: Handling of in-game entities such as objects and NPCs.
  • Peds: Functions specific to pedestrian (NPC) management.
  • Blips: Management of map blips and markers.
  • Vehicles: Functions related to vehicle management and control.
  • Draw: Graphic drawing functions for UI and in-game visuals.
  • Environment: Manipulation and management of the game environment.
  • Developer Tools: Utilities for development and debugging, including things like display on-screen coords.
  • Groups: Client-side group management and interactions.
  • Callbacks: Client-side event handling and callback functions.
  • Frameworks: Bridge functions for various server frameworks to provide an area to help with multi-framework script development.
  • Conversions: Data conversion utilities for framework data types into data used by the built-in utils systems.
  • Skills: Client-side handling of player skills system.
  • Reputation: Client-side handling of player reputation system.
  • Licences: Client-side handling of player license system.
  • Commands: Client side handling of command chat suggestions. (v1.0.0 update)
  • Character Creation: Client side functions to modify the players clothing, tattoos, genetics etc… (v1.1.0 update)
  • Cooldowns: Section to check cooldowns across resources. (v1.4.0 update)
  • Zones: Section to manage zones throughout the server. (v1.5.0 update)

Dependencies

By default the utils library uses oxmysql this could be changed provided you know what you are doing :slight_smile:

All framework bridge functions require your current framework to be ensured before boii_utils to ensure it can correctly get player management data. - This should no longer be necessary due to framework initialization updates

Frameworks covered by default:


Getting Started

To start using boii_utils, clone or download the latest version of the library and integrate into your projects. Make sure to read through the documentation for information regarding any of the utilities you wish to use.

GitHub
Tebex


Contribution & Support

boii_utils is an open-source project. We encourage developers to contribute, suggest improvements, or raise issues.

*I will try to respond to any of the questions people may have here, however it will be a faster through one of our direct channels :slight_smile: *


Links


Much love and happy scripting! :heart:

12 Likes

What can I say about this? this has some amazing functions in it! and we use this in our server day to day! Being a “novice” coder myself, having all these functions at my fingertips, is an absolute god send! Boii-development, you have made my customisation Journey so much easier! I have been using this, since its “beta” release, and this script has come so far in so little time! Keep up the good work! <3

2 Likes

:heart:

More stuff will be added as our new multi-framework updates progress, if there’s something needed throughout the development of those it will be added into here for future ease of use.

Hopefully should save people a tonne of time once they get used to the library :slight_smile:

2 Likes

Respect. Might give it a go on my next script

1 Like

For sure.

Currently in the process of rebuilding our qb catalogue into new updated resources and utils will be used pretty heavy throughout to speed up this process, along with allowing the new builds to be I guess technically “standalone” since utils will provide the bridge.

It’s speeding up my time anyway so hopefully it speeds up others too :saluting_face:
Any issue let me know and will get on it as soon as possible :heart:

1 Like

qbox support? would be amazing :slight_smile:

1 Like

Sure can do.
I’m not all that familiar with qbox but isn’t it just a “improved” version of qb-core?
Functions and stuff should be mostly the same if so.

Transitioned the release into v1.0.0 since it seems more than stable enough now, and the majority of what is needed for the in house resource updates is done.
(may still be some more to add as the updates progress, of course any suggestions for things to include are still open)

GitHub and Tebex versions of the resource have both been updated.
Docs have also been updated to include some brief information on the new additions.

Update Notes

# V1.0.0

# SERVER
- Connections **new**
-> Added new connections section to handle player connection logic and create a user account to be used in other systems.
- Commands **new**
-> Added new commands sections using user accounts created by new connections logic to handle permission checks
- Commands List **new**
-> Added new commands list section to keep utils commands organised, currently only includes a test command to get the players ID.
- Frameworks
-> Replaced initialization with a thread and slight delay to ensure framework objects are ready before initializing utils.
- Various
-> Replaced all uses of utils.debugging with utils.debug to accurately reflect new debug setup

# CLIENT
- Commands **new**
-> Added new commands section right now it just handles chat suggestions
- Frameworks
-> Replaced initialization with a thread and slight delay to ensure framework objects are ready before initializing utils.
- Various
-> Replaced all uses of utils.debugging with utils.debug to accurately reflect new debug setup

# Shared
- Debug
-> Replaced utils.debugging with shorter version utils.debug
-> Remove utils.debugging.debug; pretty redundant due to the other various options available

Much love folks <3

It does have backwards compactibility, but it would be better if it used qbox functions and modules directly. Some events are changed and PlayerData is as a module, some of their scripts like qbx_management uses exports, instead of events. Personally i only use the core, but seeing support for it would be awesome, as it will most likely have many changes in the future, to the point where support for them will be required. :slight_smile:

Yeh will admit I took a peak at the core again after that reply and noticed it seems to be a lot different now than it was when I first got wind of it.

Leave it with me will get that done for the next update have a couple other things to be added also since I will be starting work on our framework build again at end of the month.

1 Like

Just a note:

Currently working on some additions for v1.1.0 so any suggestions for additional things to include more than happy to try squeeze those in if time permits.

Planning to add some more support for other frameworks out of the box, a decent amount of code clean up, extensive commenting throughout to hopefully help people understand things a little better. Along with a extensive section to cover pretty much everything you could possibly need for creating any scripts related to character creation (character genetics, clothing, tattoos, barber).

New creation section is already tested and working as I am currently re-building the multi-character/creation system for boii_base just simply makes sense to share the work and reduce the load for others :wink:

So another quick update to throw into the mix.
Will make another as soon as possible to improve on the framework bridges with anything else needed and add support for more frameworks, time is just a little limited at the moment.

This update mostly brings a large clean up to the code hopefully to help people understand things just a little better. Have also added in functions to help out with character creation things (e.g, clothing stores, tattoos, character creators etc…).

Have been re-doing the multicharacter / creation process for boii_base (soon to be released) so decided to just put the functions in here save people have to do them :smile:

Below is a screenshot from the new creation process over on the framework build just to show that they do actually work :sweat_smile:

Enjoy :heart:


V1.1.0

# Client

- All Scripts
-> Improved on comments throughout with added use of ldoc tags
- Config
-> Added config.disable section and a toggle to disable framework bridges enabling library to be entirely standalone if required.
-> Added new toggle to disable debug prints for the new character creation section.
- Frameworks
-> Added return to exit framework bridges if disable = true
- Character Creation **NEW**
-> Added a new section to cover pretty much everything people might need to create their own clothing / tattoo / multi-character scripts basically anything involved with character creation is in here.

# Server

- All Scripts
-> Improved on comments throughout with added use of ldoc tags
- Config
-> Added config.disable section and a toggle to disable framework bridges enabling library to be entirely standalone
- Frameworks
-> Added return to exit framework bridges if disable = true

# Shared

- Default Ped Styles **NEW**
-> Added table to manage ped styles for character creation processes.

V1.2.0 has now been pushed!

Resource: boii_utils
Version: 1.2.0
Changes:
# Client

- Notifications
-> Improved conversion for notifications type can now use "info" for all information types and will be converted to type required

# Server

- Frameworks
-> Added function get_player_id to return a player characters identifier e.g. citizen id
-> Added function get_identity_by_id to get a player characters identity from database by their id
- Notifications
-> Fixed mistype with notifications calling TriggerEvent instead of TriggerClientEvent and added missing _src parameter
-> Improved conversion for notifications type can now use "info" for all information types and will be converted to type required
- Conversions
-> Removed testing prints that had been left in
- Version **new**
-> Added section to handle version checking using a github repo json file

# Shared

- Geometry
-> Added function calculate_rotation_matrix
-> Added function translate_point_to_local_space
-> Added function is_point_in_oriented_box

v1.4.0 is now up.

forgot to post for 1.3.0 my bad…

Resource: boii_utils
Version: 1.4.0
Changes: 
-> Moved all files into folders to allow for better future organisation.
-> Added boii dev branding back into top of files.
-> Added new section for handling resource cooldowns.
-> Fixed issue with missing callback to retrieve a singular skills data.
-> Updated debug logs to include name of invoking resource.

Turns out I’m quite bad at this… I also forgot to post for 1.5.0 and 1.6.0 :man_facepalming:

Resource: boii_utils
Version: 1.5.0
Changes: 
-> Added new ui section. This is a section for creating bridges for various UI elements, progress bars, notifications etc.",
-> Added new zones section. This section is for creating zones on the map and checking if players are in them for example safe zones.",
-> Added new update_inventory_data function currently only supported for boii framework will update for others asap.",
-> Added new geometry function line_intersects_circle to check if raycast line intercepts a circular space." 
Resource: boii_utils
Version: 1.6.0
Changes:
-> Moved all utils tables into configs instead of in being at bottom of individual files. Local functions are still assigned here.
-> Removed empty vehicle keys table from server config ideas for this have changed.
-> Modified licence update function to accept table params.
-> Split ui.lua into two files notifications.lua and progressbar.lua.
-> Updated readme file as tebex version was missing a readme.

v1.7.0 is being worked on got another couple things to add that could be useful for others :slight_smile:

v1.70 update

Resource: boii_utils
Version: 1.7.0
Changes:
- Blips
-> Updated notes for some of the functions.

- Frameworks
-> Modified server side get_balance function to return item cash for boii_core if balance_type = cash.
-> Added new callback to allow retrieving players id on client side.

- UI 
-> Corrected fxmanifest load order as progressbar could not access notify.
-> Fixed issue with progressbar bridge notifications

- Groups
-> Added a specified leader option to groups.
-> Modified group setup to allow for having a group image.
-> Added new server functions is_member and is_leader to check if player is member or leader of a group respectively.
-> Added new server function get_groups_of_type to retrieve all groups of a specified type.
-> Added new server function close_group to allow leaders to close a group.
-> Modified add function to now accept a params of player_details when adding players instead of using identity info directly.

- Date & Time
-> Added new function to get time difference in seconds between two timestamps.

Been wildly busy but utils v1.8.0 is here :slight_smile:
Notes for this one are a little long… was a big update… :sweat_smile:

# V 1.8.0

- Restructure to entire code base.
-> Moved files from individual folders to shared 'scripts' folders in respective areas.
-> Moved all 'utils' direct export functions to below each function to keep them close to the functions.
-> Added individual exports for each function where neccessary to remove the need for importing the entire library.

- Shared: Debug
-> Added new functions:
--> log_stack_trace: Logs the current stack trace.
--> dump: Dumps the content of a variable to the log this converts the variable into a JSON string.
--> measure_execution_time: Measures and logs the execution time of a function.
--> log_resource_usage: Logs the current resource usage of the server.
--> try_catch: Moved from general to debug, emulates try-catch behavior in Lua.
--> once: Moved from general to debug, ensures a function is called only once.
--> throttle: Moved from general to debug, throttles function execution.
--> is_number: Moved from general to debug, validates if value is a number.
--> is_table: Moved from general to debug, validates if value is a table.
--> is_string: Moved from general to debug, validates if value is a string.
--> is_function: Moved from general to debug, validates if value is a function.
--> coalesce: Moved from general to debug, returns the first non-nil value from the given arguments.
--> is_empty: Checks if a given value is empty (table or string).
--> debounce: Creates a debounced version of a function.

- Shared: General
-> Moved functions from general to debug: try_catch, once, throttle, is_number, is_table, is_string, is_function, coalesce.
-> Added new functions:
--> hex_to_rgb: Converts a hex value into rgb.
--> generate_uuid: Creates a new UUID, useful for unique identifiers.

- Shared: Keys
-> Added new functions:
--> print_key_list: Prints the list of all keys and their codes.
--> key_exists: Checks if a key exists in the keys table.

- Shared: Maths
-> Added new functions:
--> mean: Calculates the mean (average) of a list of numbers.
--> median: Calculates the median of a list of numbers.
--> mode: Calculates the mode (most frequent value) of a list of numbers.
--> standard_deviation: Calculates the standard deviation of a list of numbers.
--> linear_regression: Calculates the linear regression coefficients (slope and intercept) for a set of points.

- Shared: Networking -- test section! need tables code first.
-> Removed section, has been split into client and server functions respectively. 

- Shared: Strings
-> Added new functions:
--> to_upper:  Converts a string to uppercase.
--> to_lower: Converts a string to lowercase.
--> truncate: Truncates a string to a specified length.
--> repeat_string: Repeats a string a specified number of times.
--> to_title_case: Converts a string to a title case.
--> capitalize_first: Converts the first character of a string to uppercase.
--> remove_char: Removes all occurrences of a specified character from a string.
--> convert_case: Converts a string from one case to another.
--> slugify: Converts a string to a URL-friendly slug.
--> count_words: Counts the number of words in a string.
--> levenshtein: Calculates the Levenshtein distance between two strings.
--> is_palindrome: Checks if a given string is a palindrome.

- Shared: Tables
-> Added new functions:
--> deep_compare: Compares two nested tables.
--> chunk_table: Chunks a table into smaller tables of a specified size.
--> rotate_table: Rotates a table n places.
--> index_of: Returns the index of a value in a table.
--> zip: Zips two tables into a table of pairs.
--> unzip: Unzips a table of pairs into two separate tables.
--> invert: Inverts a table, swapping keys and values.
--> concatenate: Concatenates two tables.

- Client: Blips
-> Added new functions:
--> pulse_blip: Pulses a blip.
--> flash_blip: Flashes a blip for a certain duration.
--> set_blip_route: Set a route to the blip on the minimap.
--> set_blip_priority: Set the priority of a blip.
--> remove_blip_by_label: Remove a blip by its label.

- Client: Commands
-> Added new function get_suggestions for retrieving command chat suggestions when required.

- Client: Config
-> Removed client config entirely now set all settings server side and callback handles sharing to client.

- Client: Environment
-> Added new functions:
--> set_weather: Sets the current weather.
--> set_game_time: Sets the current game time.
--> get_wind_speed: Retrieves the current wind speed.
--> get_wind_direction: Retrieves the current wind direction.
--> set_wind_speed: Sets the wind speed.
--> set_wind_direction: Sets the wind direction.
--> get_sunrise_sunset_times: Retrieves the sunrise and sunset times based on the weather type.
--> is_daytime: Checks if the current time is day or night.
--> get_current_season: Retrieves the current season based on the in-game date.
--> get_environment_details: Retrieves comprehensive environment details including current season, time, weather, sunrise/sunset times, wind direction and speed, etc.
--> get_distance_to_water: Get the distance from the player to the nearest water body.
--> get_water_height_at_coords: Get the water height at a specific location.

- Client: Frameworks
-> Moved into new bridges folder; client/scripts/bridges.
-> Now automatically detects and sets framework so no longer needs to be defined in config.
-> Added new functions: 
--> get_item: Callback to use server side get_item.

- Client: Groups
-> Added new functions:
--> is_leader: Checks if the player is the leader of a specified group.
--> is_member: Checks if the player is a member of a specified group.
--> get_group_members: Fetches all members of the specified group.
--> get_group_members_by_id: Fetches all members of the group the specified player is in.

- Client: Player
-> Added new functions:
--> play_animation: Runs animation on the player with params.
--> is_player_in_water: Checks if the player is in water.
--> get_player_height_from_water: Retrieves the player's height from the nearest water surface.
--> is_player_near_water: Checks if the player is near water.

- Client: UI
-> Removed and moved to client/scripts/bridges, still uses utils.ui functions.

- Client / Server: Notifications
-> Modified notification bridge function to optimise and improve, now auto detects and uses notify resource without specifying.

- Client: Progressbar
-> Refactor and optimised the progress bridge, still need to add additional progress bar resources, now auto detects resource without specifying.

- Client: Vehicles
-> Modified get_vehicle_details now returns is_rear_engine flag for rear engine vehicles, also stores distance from closest vehicle.

- Server: Config
-> Modified rep, skills, and licences table to simplify.

- Server: Licences
-> Adjusted functions to work with new config layout.

- Server: Reputation
-> Adjusted functions to work with new config layout.

- Server: Skills
-> Adjusted functions to work with new config layout.

- Server: Frameworks
-> Moved some functions around to organise the file a little better.
-> Modified inventory related functions to detect boii_inventory or ox_inventory and redirect from framework functions if using resource is started.
-> Updated update_item_data function now covers new qb-inventory and ox_inventory.

- Client: Bridges

-> Added new bridge for drawtext ui covers show and hide drawtext for boii_ui, ox_lib, qb-core, okokTextUI, es_extended.