mirror of
https://github.com/jimathy/jim_bridge.git
synced 2026-08-19 14:56:02 +01:00
readability
This commit is contained in:
110
README.md
110
README.md
@@ -90,6 +90,7 @@ Config = {
|
|||||||
### `openMenu(Menu, data)`
|
### `openMenu(Menu, data)`
|
||||||
|
|
||||||
This handles creation of menus using `OX_Lib`, `qb-menu` or `WarMenu`
|
This handles creation of menus using `OX_Lib`, `qb-menu` or `WarMenu`
|
||||||
|
|
||||||
It uses mixed/new functions to bring more compatability to one another
|
It uses mixed/new functions to bring more compatability to one another
|
||||||
|
|
||||||
`Menu` is your button entries and works like qb-menu or ox_lib, for example:
|
`Menu` is your button entries and works like qb-menu or ox_lib, for example:
|
||||||
@@ -132,7 +133,8 @@ openMenu(Menu, -- Menu here is your table name you created above
|
|||||||
|
|
||||||
### Support for multiple target events
|
### Support for multiple target events
|
||||||
These automatically detect what target script you are using
|
These automatically detect what target script you are using
|
||||||
They are also automatically removed when the script is stopped (for helping
|
|
||||||
|
They are also automatically removed when the script is stopped (for helping optimization)
|
||||||
### `createEntityTarget(entity, opts, dist)`
|
### `createEntityTarget(entity, opts, dist)`
|
||||||
Create an entity based target
|
Create an entity based target
|
||||||
```lua
|
```lua
|
||||||
@@ -222,7 +224,7 @@ Triggers removal of the target entity, by checking the entity name
|
|||||||
### `removeZoneTarget(target)`
|
### `removeZoneTarget(target)`
|
||||||
Triggers removal of a zone(Box/Circle) target by calling the target's name/id
|
Triggers removal of a zone(Box/Circle) target by calling the target's name/id
|
||||||
|
|
||||||
## `triggerNotify(title, message, type, src)`
|
### `triggerNotify(title, message, type, src)`
|
||||||
Handles notifications for the script called from either the server or client
|
Handles notifications for the script called from either the server or client
|
||||||
|
|
||||||
Supports:
|
Supports:
|
||||||
@@ -241,7 +243,7 @@ triggerNotify(
|
|||||||
)
|
)
|
||||||
```
|
```
|
||||||
|
|
||||||
## `drawText(image, input, style)`
|
### `drawText(image, input, style)`
|
||||||
This handles calling drawText functions
|
This handles calling drawText functions
|
||||||
|
|
||||||
Supports:
|
Supports:
|
||||||
@@ -261,11 +263,12 @@ drawText(
|
|||||||
)
|
)
|
||||||
```
|
```
|
||||||
|
|
||||||
## `hideText()`
|
### `hideText()`
|
||||||
Simply used to hide drawText prompts when not needed anymore
|
Simply used to hide drawText prompts when not needed anymore
|
||||||
|
|
||||||
## `createCallback(callbackName, funct)`
|
### `createCallback(callbackName, funct)`
|
||||||
This is my attempt at making multiframework server callbacks by using their provided events
|
This is my attempt at making multiframework server callbacks by using their provided events
|
||||||
|
|
||||||
(Only works server side)
|
(Only works server side)
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
@@ -277,10 +280,10 @@ createCallback(
|
|||||||
end
|
end
|
||||||
```
|
```
|
||||||
|
|
||||||
## `triggerCallback(callBackName, value)`
|
### `triggerCallback(callBackName, value)`
|
||||||
This is an attempt at a mutliframework callback
|
This is an attempt at a mutliframework callback
|
||||||
|
|
||||||
## `onPlayerLoaded(func)`
|
### `onPlayerLoaded(func)`
|
||||||
This is a multiframework event that is triggered when a player has fully loaded their character in
|
This is a multiframework event that is triggered when a player has fully loaded their character in
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
@@ -291,53 +294,65 @@ onPlayerLoaded(
|
|||||||
)
|
)
|
||||||
```
|
```
|
||||||
|
|
||||||
## createInput(title, opts)
|
### `createInput(title, opts)`
|
||||||
|
|
||||||
## searchCar(vehicle)
|
### `searchCar(vehicle)`
|
||||||
|
|
||||||
This function was made for `jim-mechanic` but can be used in other instances
|
This function was made for `jim-mechanic` but can be used in other instances
|
||||||
|
|
||||||
I searches the model name of a currently spawned vehicle and retrieves info about it
|
I searches the model name of a currently spawned vehicle and retrieves info about it
|
||||||
|
|
||||||
It is smart, in terms of, if you use this multiple times it reteives the previously found info instead of searching again
|
It is smart, in terms of, if you use this multiple times it reteives the previously found info instead of searching again
|
||||||
|
|
||||||
It retrieves data from your vehicles.lua/database:
|
It retrieves data from your vehicles.lua/database:
|
||||||
- `name` for example: "Zentorno Pegassi"
|
- `name` for example: "Zentorno Pegassi"
|
||||||
- `price` for example: 100000
|
- `price` for example: 100000
|
||||||
- `class` this converts the class number to a String, for example: if the class is 10 it converts this to "Off-road"
|
- `class` this converts the class number to a String, for example: if the class is 10 it converts this to "Off-road"
|
||||||
|
|
||||||
## getVehicleProperties(vehicle)
|
### `getVehicleProperties(vehicle)`
|
||||||
Gets the current properties of the vehicle in a table
|
Gets the current properties of the vehicle in a table
|
||||||
|
|
||||||
## setVehicleProperties(vehicle, props)
|
### `setVehicleProperties(vehicle, props)`
|
||||||
Set's the vehicles properites using the `props` table provided
|
Set's the vehicles properites using the `props` table provided
|
||||||
|
|
||||||
## checkDifferences(vehicle, newProps)
|
### `checkDifferences(vehicle, newProps)`
|
||||||
This function is used by `setVehicleProperties`
|
This function is used by `setVehicleProperties`
|
||||||
|
|
||||||
It determine's what differences there are between the current vehicle and the new set of properites
|
It determine's what differences there are between the current vehicle and the new set of properites
|
||||||
|
|
||||||
If there are differences, return `true`
|
If there are differences, return `true`
|
||||||
|
|
||||||
## RegisterNetEvent(GetCurrentResourceName()..":server:ChargePlayer", function(cost, type, newsrc)
|
### `RegisterNetEvent(GetCurrentResourceName()..":server:ChargePlayer", function(cost, type, newsrc)`
|
||||||
This event is made to REMOVE money from a player
|
This event is made to REMOVE money from a player
|
||||||
|
|
||||||
It can be called from client with `TriggerServerEvent`
|
It can be called from client with `TriggerServerEvent`
|
||||||
|
|
||||||
Also can be called from server with `TriggerEvent` and a source id in `newsrc`
|
Also can be called from server with `TriggerEvent` and a source id in `newsrc`
|
||||||
The name of the event uses GetCurrentResourceName() so it doesn't double up results with other scripts
|
|
||||||
|
The name of the event uses `GetCurrentResourceName()` so it doesn't double up results with other scripts
|
||||||
```lua
|
```lua
|
||||||
cost = 100 -- The amount of money to be removed
|
cost = 100 -- The amount of money to be removed
|
||||||
type = "cash" or "card" -- The type of money that should be removed
|
type = "cash" or "card" -- The type of money that should be removed
|
||||||
newsrc = 1 -- The source of the player, must be nil if calling from client
|
newsrc = 1 -- The source of the player, must be nil if calling from client
|
||||||
```
|
```
|
||||||
|
|
||||||
## RegisterNetEvent(GetCurrentResourceName()..":server:FundPlayer", function(fund, type, newsrc)
|
## `RegisterNetEvent(GetCurrentResourceName()..":server:FundPlayer", function(fund, type, newsrc)`
|
||||||
This event is made to ADD money from a player
|
This event is made to ADD money from a player
|
||||||
|
|
||||||
It can be called from client with `TriggerServerEvent`
|
It can be called from client with `TriggerServerEvent`
|
||||||
|
|
||||||
Also can be called from server with `TriggerEvent` and a source id in `newsrc`
|
Also can be called from server with `TriggerEvent` and a source id in `newsrc`
|
||||||
The name of the event uses GetCurrentResourceName() so it doesn't double up results with other scripts
|
|
||||||
|
The name of the event uses `GetCurrentResourceName()` so it doesn't double up results with other scripts
|
||||||
```lua
|
```lua
|
||||||
fund = 100 -- The amount of money to be added
|
fund = 100 -- The amount of money to be added
|
||||||
type = "cash" or "card" -- The type of money that should be added
|
type = "cash" or "card" -- The type of money that should be added
|
||||||
newsrc = 1 -- The source of the player, must be `nil` if calling from client
|
newsrc = 1 -- The source of the player, must be `nil` if calling from client
|
||||||
```
|
```
|
||||||
|
|
||||||
## createUseableItem(item, funct)
|
### `createUseableItem(item, funct)`
|
||||||
This is a server side event to make an item usable
|
This is a server side event to make an item usable
|
||||||
|
|
||||||
Note: If using ox-inv and the item info has event info, this will be ignored
|
Note: If using ox-inv and the item info has event info, this will be ignored
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
@@ -349,9 +364,11 @@ createUseableItem(
|
|||||||
)
|
)
|
||||||
```
|
```
|
||||||
|
|
||||||
## hasJob(job, source, grade)
|
### `hasJob(job, source, grade)`
|
||||||
This is an event that makes checking if the player has the requested job simple
|
This is an event that makes checking if the player has the requested job simple
|
||||||
|
|
||||||
It works both client side and server side
|
It works both client side and server side
|
||||||
|
|
||||||
returns `true` or `false` and if they are on duty or not
|
returns `true` or `false` and if they are on duty or not
|
||||||
```lua
|
```lua
|
||||||
local hasjob, duty =
|
local hasjob, duty =
|
||||||
@@ -362,8 +379,9 @@ local hasjob, duty =
|
|||||||
)
|
)
|
||||||
```
|
```
|
||||||
|
|
||||||
## getPlayer(source)
|
### `getPlayer(source)`
|
||||||
This retrieves basic info of the player
|
This retrieves basic info of the player
|
||||||
|
|
||||||
works client side and server side
|
works client side and server side
|
||||||
Retrieves:
|
Retrieves:
|
||||||
- Players Name
|
- Players Name
|
||||||
@@ -378,7 +396,7 @@ local PlayerInfo =
|
|||||||
print(json.encode(PlayerInfo, { indent = true })
|
print(json.encode(PlayerInfo, { indent = true })
|
||||||
```
|
```
|
||||||
|
|
||||||
## registerCommand(command, options)
|
### `registerCommand(command, options)`
|
||||||
This is a server side event that uses
|
This is a server side event that uses
|
||||||
- `ox_lib`'s - `lib.addCommand`
|
- `ox_lib`'s - `lib.addCommand`
|
||||||
- `qb-core`'s - `QBCore.Commands.Add`
|
- `qb-core`'s - `QBCore.Commands.Add`
|
||||||
@@ -397,8 +415,9 @@ registerCommand(
|
|||||||
)
|
)
|
||||||
```
|
```
|
||||||
|
|
||||||
## invImg(item)
|
### `invImg(item)`
|
||||||
This is used mainly for menu's to retrieve the item images
|
This is used mainly for menu's to retrieve the item images
|
||||||
|
|
||||||
It detects what inventory you are using and automatically generates an `nui://` link
|
It detects what inventory you are using and automatically generates an `nui://` link
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
@@ -406,7 +425,7 @@ local imgLink = invImg("lockpick")
|
|||||||
print(imgLink)
|
print(imgLink)
|
||||||
```
|
```
|
||||||
|
|
||||||
## registerStash(name, label, slots, weight)
|
### `registerStash(name, label, slots, weight)`
|
||||||
This is a serverside function used to register a new stash in `ox_inventory` and `qs-inventory`
|
This is a serverside function used to register a new stash in `ox_inventory` and `qs-inventory`
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
@@ -418,35 +437,35 @@ registerStash(
|
|||||||
)
|
)
|
||||||
```
|
```
|
||||||
|
|
||||||
## loadModel(model)
|
### `loadModel(model)`
|
||||||
This loads the requested model into the memory cache to help spawning of props
|
This loads the requested model into the memory cache to help spawning of props
|
||||||
- Checks if the model exists in the server
|
- Checks if the model exists in the server
|
||||||
- Attempts to load the model with a timeout, if not loaded, sends warning
|
- Attempts to load the model with a timeout, if not loaded, sends warning
|
||||||
|
|
||||||
## unloadModel(model)
|
### `unloadModel(model)`
|
||||||
This unloads a model to help clear the memory cache and help optimization
|
This unloads a model to help clear the memory cache and help optimization
|
||||||
- Recommended to run after spawning a prop
|
- Recommended to run after spawning a prop
|
||||||
|
|
||||||
## loadAnimDict(animDict)
|
### `loadAnimDict(animDict)`
|
||||||
This loads the requested animDict into the memory cache to help loading anims
|
This loads the requested animDict into the memory cache to help loading anims
|
||||||
- Checks if the dict exists in the server
|
- Checks if the dict exists in the server
|
||||||
|
|
||||||
## unloadAnimDict(animDict)
|
### `unloadAnimDict(animDict)`
|
||||||
This unloads the animDict to help clear the memory cache and help optimization
|
This unloads the animDict to help clear the memory cache and help optimization
|
||||||
- Recommended to run after running an animation
|
- Recommended to run after running an animation
|
||||||
|
|
||||||
## loadPtfxDict(ptFxName)
|
### `loadPtfxDict(ptFxName)`
|
||||||
This loads the requested ptFx dict into the memory cache to help loading particle effects
|
This loads the requested ptFx dict into the memory cache to help loading particle effects
|
||||||
- Skips if the effect is alredy loaded
|
- Skips if the effect is alredy loaded
|
||||||
|
|
||||||
## unloadPtfxDict(dict)
|
### `unloadPtfxDict(dict)`
|
||||||
This unloads a particle effect to help clear the memory cache and help optimization
|
This unloads a particle effect to help clear the memory cache and help optimization
|
||||||
- Recommended to run after running an ptfx
|
- Recommended to run after running an ptfx
|
||||||
|
|
||||||
## loadTextureDict(dict)
|
### `loadTextureDict(dict)`
|
||||||
This loads the requested texture dictionary into memory
|
This loads the requested texture dictionary into memory
|
||||||
|
|
||||||
## countTable(table)
|
### `countTable(table)`
|
||||||
This is a simple function to count how many entires are in a table, for if your table keys aren't numbered
|
This is a simple function to count how many entires are in a table, for if your table keys aren't numbered
|
||||||
```lua
|
```lua
|
||||||
local table = {
|
local table = {
|
||||||
@@ -456,8 +475,9 @@ local table = {
|
|||||||
print("countTable", countTable(table))
|
print("countTable", countTable(table))
|
||||||
```
|
```
|
||||||
|
|
||||||
## pairsByKeys(t)
|
### `pairsByKeys(t)`
|
||||||
Searches through a table alphabetically instead of randomly
|
Searches through a table alphabetically instead of randomly
|
||||||
|
|
||||||
This is an optional function made to replace:
|
This is an optional function made to replace:
|
||||||
```lua
|
```lua
|
||||||
for k, v in pairs(table) do end
|
for k, v in pairs(table) do end
|
||||||
@@ -467,9 +487,11 @@ with:
|
|||||||
for k, v in pairsByKeys(table) do end
|
for k, v in pairsByKeys(table) do end
|
||||||
```
|
```
|
||||||
|
|
||||||
## playAnim(animDict, animName, duration, flag, ped)
|
### `playAnim(animDict, animName, duration, flag, ped)`
|
||||||
A simplified version of `TaskPlayAnim()`
|
A simplified version of `TaskPlayAnim()`
|
||||||
|
|
||||||
Has some settings already set and basic ones ready to change
|
Has some settings already set and basic ones ready to change
|
||||||
|
|
||||||
Loads the animDict automatically with `loadAnimDict()`
|
Loads the animDict automatically with `loadAnimDict()`
|
||||||
```lua
|
```lua
|
||||||
playAnim(
|
playAnim(
|
||||||
@@ -481,8 +503,9 @@ playAnim(
|
|||||||
)
|
)
|
||||||
```
|
```
|
||||||
|
|
||||||
## stopAnim(animDict, animName, ped)
|
### `stopAnim(animDict, animName, ped)`
|
||||||
Similar to `StopAnimTask()`
|
Similar to `StopAnimTask()`
|
||||||
|
|
||||||
Made to stop the given animation with being able to choose which ped
|
Made to stop the given animation with being able to choose which ped
|
||||||
```lua
|
```lua
|
||||||
stopAnim(
|
stopAnim(
|
||||||
@@ -491,31 +514,36 @@ stopAnim(
|
|||||||
ped, -- Optional, for if you want any one other than the player to do the animation
|
ped, -- Optional, for if you want any one other than the player to do the animation
|
||||||
)
|
)
|
||||||
```
|
```
|
||||||
## makeVeh(model, coords)
|
### `makeVeh(model, coords)`
|
||||||
|
|
||||||
## makePed(model, coords, freeze, collision, scenario, anim, synced)
|
### `makePed(model, coords, freeze, collision, scenario, anim, synced)`
|
||||||
|
|
||||||
## makeProp(data, freeze, synced)
|
### `makeProp(data, freeze, synced)`
|
||||||
|
|
||||||
## instantLookEnt(ent, ent2)
|
### `instantLookEnt(ent, ent2)`
|
||||||
This function forcibly changes `ent`'s heading to face `ent2`
|
This function forcibly changes `ent`'s heading to face `ent2`
|
||||||
Helpful for animations
|
Helpful for animations
|
||||||
|
|
||||||
## lookEnt(entity)
|
### `lookEnt(entity)`
|
||||||
This function attempts to slowly turn the player to the given entity/coords
|
This function attempts to slowly turn the player to the given entity/coords
|
||||||
|
|
||||||
Accepts either a `entity ID` or `vector3`
|
Accepts either a `entity ID` or `vector3`
|
||||||
|
|
||||||
## destroyProp(entity)
|
### `destroyProp(entity)`
|
||||||
Attempts to remove a spawned prop
|
Attempts to remove a spawned prop
|
||||||
|
|
||||||
If its attached to a player it attempts to to detatch it first
|
If its attached to a player it attempts to to detatch it first
|
||||||
|
|
||||||
## pushVehicle(entity)
|
### `pushVehicle(entity)`
|
||||||
This attempts to make the current entity(vehicle) network controlled
|
This attempts to make the current entity(vehicle) network controlled
|
||||||
|
|
||||||
This helps with syncing it with other players (used in jim-mechanic alot)
|
This helps with syncing it with other players (used in jim-mechanic alot)
|
||||||
|
|
||||||
## ensureNetToVeh(vehNetId)
|
### `ensureNetToVeh(vehNetId)`
|
||||||
This was created to get around fivem's warnings of failing to get network objects
|
This was created to get around fivem's warnings of failing to get network objects
|
||||||
|
|
||||||
Although these warnings mean't nothing, it is annoying
|
Although these warnings mean't nothing, it is annoying
|
||||||
|
|
||||||
This is made to replace the native `NetToVeh()` but checking first if it exists
|
This is made to replace the native `NetToVeh()` but checking first if it exists
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user