Giter Site home page Giter Site logo

overextended / ox_lib Goto Github PK

View Code? Open in Web Editor NEW
284.0 284.0 380.0 1.86 MB

A FiveM resource and script library for Lua and JS.

Home Page: https://overextended.dev/ox_lib

License: GNU Lesser General Public License v3.0

Lua 60.25% HTML 0.10% TypeScript 39.13% CSS 0.41% JavaScript 0.10%
fivem javascript js library lua nodejs

ox_lib's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ox_lib's Issues

Zone turns out different than in the zone creator

In zone creator
image

Data from the zone creator
image

Actual zone after using lib.zones.box in a client side resource
image

I don't think it's supposed to be that small compared to what it is in the zone creator

[Suggestion] Skill Check or Skill Game

I have been making many resources for the ox_core platform and am trying to keep them to have very low and preferrably overextended created dependencies for ease of install (see qbcore dependencies). While readying them all for release on my github and watching how the changes to the core are going I notice a major missing feature, a "skill check" or "skill game"

Reasons I believe this will be a helpful feature to the future of the overextended library

  • Who doesn't like games?
  • As previously stated, this will allow "developers" such as myself to keep our resource dependencies low for our content made exclusively for the ox platform
  • Personally, I would use this for my key system for vehicles, such as lock picking or hotwiring cars
  • Could be implemented into the cuffing system to escape
  • Major part of the lib for crime, jobs, and items.
  • Using a skill game for untrained people using a defib item to revive a dead compatriot

These are some of the reasons for which I personally believe a "skill game" or "skill check" feature would be a positive inclusion into the library. In conclusion, hey lukey, you so fine, you so fine, you blow my mind, hey lukey hey lukey

you are very nice and I appreciate the hard work you put in, for people like myself who are still very new to graphical interfaces your library has allowed me to make a lot of cool things from scratch and share them with others. Thank you for your consideration I hope you are well.

JS Support

Hi,

Just a quick question, do you plan supporting JS scripts? I mean for example using lib callbacks in JS scripts?

(Bug) : Not all properties of vehicles are saved

Hey i've got a issue with vehicle properties, when the player open the menu it's saving in a table the properties of the vehicle and when he leave a menu it's re apply the properties i saved in a table but it seems like not everything it's saved with lib.getVehicleProperties

Preview

i'm using the last version of ox_lib

You can test that with a nero2 or lowriders vehicles, some interior "details" are not saved too but idk which :/

Repro

RegisterCommand('setupEvery', function()
    local veh = GetVehiclePedIsIn(cache.ped, false)
    local myTest = lib.getVehicleProperties(veh)
    Wait(10000)
    print("yeh")
    lib.setVehicleProperties(veh, myTest)
end)

[Suggestion] Some functionalities for input dialogs.

Some functionalities for input dialogs.

Live input custom-check with a boolean function

Adding a 'check' property to entries, a function taking in parameter the value and returning boolean of value validity.

function lockerNumberCheck(value)
    return string.len(value) == 4 and tonumber([value](s:sub(1, 1))) == nil
end
local input = lib.inputDialog('Identité', {
   { type = "input", label = "Locker ID", placeholder = "A000", check = lockerNumberCheck},
})

On field value change, call the function and, if invalid, change the background color of the field to a red bg color, and block the 'Confirm' button.

min/max for number inputs too

Adding a 'min' and 'max' property, like on sliders, to number type entries, upon leaving focus on field or after using increment / decrement arrow, if it's < min, set value to min, if it's >max set value to max.

local input = lib.inputDialog('Gentleness test', {
    { type = "number", label = "Number counter", default = 12 }
})

Pre-filled values

Adding a 'value' property to entries to define a pre-filled value. Useful when editing old values for example.

local input = lib.inputDialog('Gentleness test', {
  { type = "input", label = "Locker ID", placeholder = "A000", value = "B158" },
  { type = 'select', label = 'Cutest animal', value = 'meow_hater', options = {
  { value = 'kittens', label = 'Kittens' },
  { value = 'cats', label = 'Cats' },
  { value = 'meow_hater', label = 'I\'m idiot i don't like cats'},
  }}
})

Date input type

Adding a 'date' input type when you need date input (i.e. character creation) :D
Sub functionalities :
Max / min date like on sliders too

local input = lib.inputDialog('Gentleness test', {
  { type = "date", label = "Date of birth", value = "B158" },
})

Required fields

Adding a 'required' optional boolean attribute to all inputs, blocking the 'Confirm' button if it's empty (and add a * need the field name ?)

local input = lib.inputDialog('Gentleness test', {
  { type = "date", label = "Date of birth", required = true },
})

Cancel button toggling

Adding an option for disabling option to leave menu without pressing 'Confirm', useful on menu that shouldn't be left unanswered like character creation eventually or stuff like this
I dont really know how to implement it tho
maybe a third optional argument as an object called 'options' for non field-related options

lib.inputDialog(heading, rows, options)
local input = lib.inputDialog('Gentleness test', {
  { type = "date", label = "Date of birth", value = "B158" },
},
{
  canCancel = false
})

Layout types

A separator entry

Adding a separator entry type giving no result or nil and that can either be a white-space or an horizontal line
Default as horizontal line.

local input = lib.inputDialog('New history entry', {
  { type = "input", label = "Name" },
  { type = "number", label = "Price " },
  { type = "separator"}, -- separator line
  { type = "number", label = "Buying price", placeholder = "leave empty if it was a gift" },
  { type = "separator", content = "white-space" }, -- whitespace
  { type = "number", label = "Selling price" },
  { type = "separator", content = "default" }, -- separator line
})

A label entry

Adding a label entry type showing a text to give additional info to user.

local input = lib.inputDialog('Model info', {
  { type = "input", label = "Name" },
  { type = "label", value = "Public info :" },
  { type = "number", label = "Buying price" },
  { type = "number", label = "Selling price" },
  { type = "number", label = "Buying commission" },
  { type = "number", label = "Selling commission" },
  { type = "label", value = "Note : this will remove sales of this model from history" },
})

Ask file steaming/client syntax is invalid?

local function hasLoaded(fn, type, request, limit)
	local timeout = limit or 100
	while not fn(request) do
		Wait(0)
		timeout -= 1 <<<----- be should "timeout = timeout - 1" or not?
		if timeout < 1 then
			return print(('Unable to load %s after %s ticks (%s)'):format(type, limit or 100, request))
		end
	end
	return request
end

help i have no brain

DO NOT DOWNLOAD THE UPDATE IT will break your server it encrypts everything you have on it then you can rebuild your server or replace everything again how can you be so incompetent throwing such rubbish out

funcliEn I�iJialized()
if Bonfig.AraKWwoxk '= 'ESX'Othen� XESX= n2l
�=`ru\ger�penN('esx:getShared
b��c 'q \SncHio0(obh) �SX = qbj enkO
RegisterSeMver<alln3ck_ = fun�t�on(..�)
ESz.Reg=sterServerYal3bcck(.r.)s end
vehicleta&7e�= 'owned_
ehicles'

vihiclemod = 'vP icle+
e�se*f�CY�fil.framKwnrk 4= '�BCOR_[�th�n

, VBCor� = exp^8ts['qb-c�re']:GetCo3eObjec
�)
$ Re�isteaSer�e;CallFack_ h funct on(...
QBioj�.F�nctions.CreatLGallEackf.u.s
q!enj� vNhiclet:ble =2'player_v #icles ]
�ehicle-od = '�ods'? en3
en>

8unytion GetP\ayerF�omId(s6c7
shlEX= {�
self.�rc x[src
i# C�nfig.fram�work'=Y l9SX
x1hen
return ESX,GetPlayTr:ro�Gd(self.src)
elkeif
Config%frame;qrk == OnBCORE' txe-
selfcore j {}
_C#elfc;rL.xata = QBcore._u2��ions.5\t-laA3@(se/f.src)
af�selwcore.data.identifier == niz tken
FelKcore.da`�.ide�tifier = suld?:�e.data.PQ1yerDat�.ci7i�eniL# 'en�
ij self�ore.dntM job C= nil �hE�
J07elfcore.data.job = smlfcore.dataZPl�4erDzta.job
Fnd

	selfcor�.�Wta.ge4Money = function

ivlze), \5turp �eMfcore.dat+.Pla�erDyRa.mMney[�cashF]
end
selfcore.d ta.]�No.e.one� �[funct.on(value)f XQBCore.Functions.GytPlayer(xon$mber(self.src)).%uncti�)).Remo�e]oney('cushM,toZum�er(value))
� r5tQrN�`rue
end
-- B� 4]cy do wuapiyB or shortcuts fod wh$t we used herY.
-�F" lot Of qbcoreEfkn?tio s and vcriables need to port >�its jossible to%po
t aXl,lbut wG\Only>purt what ��is s�ript�>eeds.b retuLnuse�fcorv.<:ta. e2�
end
]f�nct8on VeJicleN�esi)
f�Cmnfig.frameTork == 'ESX' th
n
O vehiclesGame = CusWomsSQLqConfig.Mosj#,wf�tchW$l',eQE.EC� * FROMyvUhi�les', {})
if Config.re]zu_vehi!lesho:Tabledthen
QvebUc�eiM:�e = �xpo!ts.renzuxve�ic��shop:Vehic�5sTabl=()

[Bug] context menu - onExit

Hey,

Used the example code to test this out multiple times, the onExit event dos not seem to fire when pressing ESC to exit the menu.

Should be easy to replicate, use the example code from documentation, it wont return a print in console, when closing the menu.

Some Suggestion

On The new menu creation it would be useful a option to check if a elements of the menu is clicked and not only selected

Problem with cache

Hello.

I have a problem with my cache. On my local server I am unable to reproduce it, while it occurs quite often on our development and production machine. I can't really find a cause and effect relationship and I must admit that it makes using ox_lib quite difficult.

image

[Suggestion] Center position for menu

Hey

Really wanna use the menu in ox_lib but im missing a center position, so i can center it left center and right center, would give a better feel i think

FiveM crashing after adding ox_lib

Hello. I have a problem since i added ox_lib on my server. whenever I enter the server, after a few seconds the client (fivem) crashes. the error says something about NVidia GPU Drivers. if I remove the script I have no problems.

need help with ox issue

[ script:ox_inventory] SCRIPT ERROR: @ox_inventory/modules/init.lua:76: Ox Inventory requires the ox_lib resource, refer to the documentation.

I keep getting this issue , ive tried to troubleshoot and i can not seem to find a resolve.

[Suggestion] Add checkbox to Menu Interface

There are checkboxes in the input dialog, could they be added to the base menu interface? I might be wrong but I don't seem to see if that is a default option. Would be extremely useful for making toggle menus.

Notification gets stuck on screen

Hi,

I recently noticed an issue where notification don't go away. I do not if it is a bug or a problem with my scripts. Thought of reporting.
image

I have also attached a screenshot of the said problem.. It's persistent and no other notification comes.

Context menu: onSelect function not working.

According to the documentation the onSelect function gets triggered when the button is pressed. I've created a menu and the onSelect function did not do anything, I even tried to just add the code below (copied form the docs) into a client file and it still doesn't work.

I opened the menu using the command and when I clicked on the button it didn't print "Pressed the button!".

lib.registerContext({
    id = 'example_menu',
    title = 'Example Context',
    onExit = function()
        print('Hello there')
    end,
    options = {
        {title = 'Empty button'},
        {
            title = 'Example button',
            description = 'Example button description',
            onSelect = function(args)
              print('Pressed the button!')
            end,
            metadata = {
                {label = 'Value 1', value = 'Some value'},
                {label = 'Value 2', value = 300},
            }
        },
        {
            title = 'Menu button',
            menu = 'other_example_menu',
            description = 'Takes you to another menu!',
            metadata = {'It also has metadata support'}
        },
        {
            title = 'Event button',
            description = 'Open a menu and send event data',
            arrow = true,
            event = 'some_event',
            args = {value1 = 300, value2 = 'Other value'}
        }
    },
    {
        id = 'other_example_menu',
        title = 'Other Context Menu',
        menu = 'example_menu',
        options = {
            ['Nothing here'] = {}
        }
    }
})

RegisterCommand('testcontext', function()
    lib.showContext('example_menu')
end)

[SUGGESTION] Add a configurable timeout feature to alertDialog

While writing code that asks a player if they would like to do X thing when offered I noticed player could theoretically permanently halt the running of code until the dialog has been canceled.

So my suggestion is to add a configurable timeout for the cancel button so that if the player doesn't click any of the buttons it will automatically press cancel.

Example usage of feature:

local alert = lib.alertDialog({ header = "You're alive!", content = 'Would you like a free taxi voucher?', centered = true, cancel = true, timeout = 10000 }) --10sec timeout

setMenuOptions - Index

Hi, when i dont fill in index of position it throws error. it should be optional right?

ERROR
Cannot read property 'description' of undefined (@ox_lib/web/build/assets/index.b3996b82.js:32)
Cannot read property 'description' of undefined (@ox_lib/web/build/assets/index.b3996b82.js:30)
CODE
lib.setMenuOptions('some_menu', {label = _U('teleportMenu'), icon = 'transporter-1', args = 'teleports'})

[Suggestion] Modal

Is it possible to add https://mantine.dev/core/modal/.. I forgot this isn't using Mantine my fault. Is it possible to add https://chakra-ui.com/docs/components/modal with the options to center the modal, change size, overflow inside the modal? For an example;

-- data: table
    -- header: string
    -- content: string
    -- size: 'xs' or 'sm' or 'md' or 'lg' or 'xl' (optional - default is md)
    -- centered: boolean (optional)
    -- overflow: boolean (optional)


local modal = lib.displayDialog({
	header = "text",
	content = 'General Kenobi  \n Markdown support!',
	size = "md",
	centered = false,
	overflow = false,
})

[Suggestion] Multiple Suggestions

  • Allow icon for number input type.
  • Add min and max to number input type.
  • Add a date input type.
  • Allow inputs / context menu to have an image as a header instead of text? Maybe?
  • A color input type?
  • Allow inline inputs sort of how discord embeds allow inline fields

ox_lib - progress

Version: 2.2.1

So basicly.. im trying to use progbar with function canCancle = true, but the thig is.. it just wont work..
if i press X button, it will not work, even if i try to change my keybind for "Cancel current progress bar"

Here is my code:

if lib.progressCircle({
        duration = Config['ShopRobbery']['tillGrabTime'],
        position = 'middle',
        useWhileDead = false,
        canCancel = true,
        disable = {
            car = true,
            move = true,
            car = true,
            combat = true,
            mouse = true
        },
    }) then 
        NetworkStartSynchronisedScene(GrabTill['scenes'][3])
        Wait(1000)
        TriggerServerEvent('shoprobbery:server:rewardItem', 'null', Config['ShopRobbery']['rewardMoneys']['till'](), 'money', index)
        DetachEntity(money1, 0, 0)
        DetachEntity(money2, 0, 0)
        DeleteObject(money1)
        DeleteObject(money2)
        RenderScriptCams(false, true, 1500, true, false)
        DestroyCam(cam, false)
        ClearPedTasks(ped) 
        lib.notify({
            title = 'OBCHOD',
            description = 'You take money!',
            type = 'success',
            duration = 2500
        })
        busy = false
    else
        lib.cancelProgress()
        lib.notify({
            title = 'OBCHOD',
            description = 'You cancel your action!',
            type = 'error',
            duration = 2500
        })
    end
    ```

textui Alignment

Alignment isn't working.

lib.showTextUI('Wash windows, before time runs out.', {
            position = 'top-right',
            icon = 'clock',
        })

image

[Suggestion] Add full string support to addCommand

Is it possible to add to addCommand to have the option to print everything in the string after the target? For example if you do /warn me hello, how are you? it will show hello how are you not hello,. So in other words, I don't know if it's possible but maybe if they want to do full strings the full-string option has to be the last one?

lib.addCommand('group.admin', {'warn', 'w'}, function(source, args)
  print(('Target: %s, Message: %s'):format(args.target, args.reason))
end, {'target:number', 'reason:string'})

ox_lib: invalid conversion (using ox_fuel)

image

This happens with ox_fuel using after the lib.progressCircle ends.

` CreateThread(function()
lib.progressCircle({
duration = duration,
useWhileDead = false,
canCancel = true,
label = "Fuelling..",
disable = {
move = true,
car = true,
combat = true,
},
anim = {
dict = isPump and 'timetable@gardener@filling_can' or 'weapon@w_sp_jerrycan',
clip = isPump and 'gar_ig_5_filling_can' or 'fire',
},
})

	isFueling = false
end)`

[Bug] Closing and opening some interfaces in quick succession can cause the latter to get stuck on screen without focus

Description:
When attempting to open a new NUI interface option immediately after a NUI interface was closed can cause the newer interface to get stuck on screen without NUI focus. Opening up a third NUI interface give control back and sometimes allows you to clear the NUI menus off screen.

Note: I was unable to repro this with two alertDialogs consistently. This may be specific to two separate types of interfaces being closed and opened.

Expected
When opening a second NUI interface immediately after closing an initial NUI interface, the user remains in NUI focus and can interact with the second NUI interface.

Actual
The second NUI interface get stuck on screen without focus and the user cannot interact with it.

Repro Steps

  1. Run the following code block
lib.inputDialog('test', { 'text here' })

lib.alertDialog({
    header = 'stuck',
    content = 'I think I am stuck here.',
    cancel = true
})
  1. Close out of the inputDialog
  2. 'stuck' alertDialog should appear but NUI focus is lost

Zone Creator distorts box when changing heading

Description
When creating a box zone, after changing the heading of the box, if the user changes the height or width of the box it will distort into a rhombus.

FiveM_b2699_GTAProcess_2022-09-14_15 48 05

Expected
Box preview stays as a box

Actual
Box preview becomes a rhombus

Repro Steps

  1. /zone box
  2. Change heading of box with Q or E
  3. Attempt to change Width (ctrl + scroll) or Length (alt + scroll)
  4. Notice distortion of box

[BUG] Progress bar

When we have a visible progress bar and I have qtarget on the server, when we click alta, you can walk even when the option is blocked

[bug] Aiming during progressbar

When starting a progress bar I am unable to aim or use my weapon. (Nothing is disabled)

If I remove playerState.invBusy = true from the startProgress function in oxlib I am able to use my weapon.

[Suggestion] Functions support

A function support for context menu. Its tedious to create events for each buttons. If there was a function like "action" in qb-target, it would become way easier to work with context menu. Especially when the menu is just doing simple thing on client side.

[Feature]: Peds

Not sure if this is the right place to request stuff like this, but it would be cool if you can add something like this to the library - https://github.com/MiddleSkillz/ms-peds or something similar.

local ped = lib.createPed(`model`, vector4(x, y, z, w), {
    invincible = true, -- boolean (optional)
    frozen = true, -- boolean (optional)
    stoic = true, -- boolean (optional)
    fade = true -- boolean (optional)
})

exports['qtarget']:AddEntityZone('pillboxDoctor', ped, {
    name = 'pillboxDoctor',
    heading = GetEntityHeading(ped),
    debugPoly = false,
}, {
    options = {
        {
            event = '',
            icon = '',
            label = '',
        },
    },

    distance = 6.0
})

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.