FlowDetector utilities for FXServer Github: FlowDetector

[DESCRIPTION]
to create a detector to comply with a worth’s altering

[INSTALLATION]
Set it as a dependency in you fxmanifest.lua
and

client_script '@flowdetector/flowdetector.lua'

[FUNCTIONS]

FlowCheckCreate(title,defaultValue)        --to create a detector to comply with a worth's altering
FlowCheck(title,inputValue)                --input a worth into the detector


FlowCheckDelete(title)                     --waste the detector


FlowOnInitialise(title,thefirstValue)      --when the worth is from undefined to a newervalue 
FlowOnSame(title)                          --when the newervalue is similar from oldervalue
FlowOnChange(title,fromValue,toValue)      --when the oldervalue grow to be a brand new worth 

FlowDetector.OnInitialise[name](title,thefirstValue) --same as above however example2.lua
FlowDetector.OnSame[name](title,thefirstValue)  --same  as above however example2.lua
FlowDetector.OnChange[name](title,thefirstValue)  --same  as above however example2.lua

[EXAMPLE] using cfx-switchcase by negbook(github)

operate FlowOnChange(title,fromValue,toValue)
	native case = {} --cfx-switchcase by negbook https://github.com/negbook/cfx-switchcase/blob/principal/cfx-switchcase.lua
    native swap = setmetatable({},{__call=operate(a,b)case=setmetatable({},{__call=operate(a,b)return a[b]finish,__index=operate(a,c)return c and c==b and setmetatable({},{__call=operate(a,d)d()finish})or operate()finish finish})return a[b]finish,__index=operate(a,c)return setmetatable({},{__call=operate(a,...)finish})finish})
    swap(title)(
        case('coords')(operate()
            print('Place Up to date:from ('..sort(fromValue)..') '..tostring(fromValue)..'  to ('..sort(toValue)..') '..tostring(toValue))
        finish),
        case('well being')(operate()
            print('Well being Up to date:from ('..sort(fromValue)..') '..tostring(fromValue)..'  to ('..sort(toValue)..') '..tostring(toValue))
        finish)
    )
finish 
    FlowCheckCreate('coords')
    FlowCheckCreate('well being',"howdy")
    CreateThread(operate()
        
        whereas true do Wait(1000)
            FlowCheck('coords',GetEntityCoords(PlayerPedId()))
            FlowCheck('well being',GetEntityHealth(PlayerPedId()))
        finish 
    finish)

[EXAMPLE2]

native IsPause = false
FlowDetector.OnChange["Pause"] = operate(title,outdated,new)
    if outdated == false then 
        print(title,"Turning On Pause")
    else 
        print(title,"Turning Off Pause")
    finish 
finish 

CreateThread(operate()
    FlowCheckCreate("Pause")
    whereas true do
        IsPause = FlowCheck("Pause",IsPauseMenuActive())
        Citizen.Wait(332)
    finish
finish)

CreateThread(operate()
    whereas true do
        print(IsPause)
        Citizen.Wait(1000)
    finish
finish)

cfx-switchcase utilities for FXServer Github: cfx-switchcase
[INSTALLATION]
Simply Copy and Paste to your code which want the switch-case operate

native case = {} --cfx-switchcase by negbook https://github.com/negbook/cfx-switchcase/blob/principal/cfx-switchcase.lua
native swap = setmetatable({},{__call=operate(a,b)case=setmetatable({},{__call=operate(a,b)return a[b]finish,__index=operate(a,c)return c and c==b and setmetatable({},{__call=operate(a,d)d()finish})or operate()finish finish})return a[b]finish,__index=operate(a,c)return setmetatable({},{__call=operate(a,...)finish})finish})

[EXAMPLE]

native case = {} --cfx-switchcase by negbook https://github.com/negbook/cfx-switchcase/blob/principal/cfx-switchcase.lua
native swap = setmetatable({},{__call=operate(a,b)case=setmetatable({},{__call=operate(a,b)return a[b]finish,__index=operate(a,c)return c and c==b and setmetatable({},{__call=operate(a,d)d()finish})or operate()finish finish})return a[b]finish,__index=operate(a,c)return setmetatable({},{__call=operate(a,...)finish})finish})

CreateThread(operate()
        native a = 4
        native b = "some"
        swap(a)(
            case(1)(operate()
                    print(99)
            finish),
            case(4)(operate()
                    print(98)
            finish)
        )
        swap(b)(
            case("some")(operate()
                    print(99)
            finish),
            case("the place")(operate()
                    print(98)
            finish)
        )
      
finish)



Looking for paid scripts? Click here