Skip to content

Commit

Permalink
docs: removed deprecated functions. qbx-core -> qbx_core. Added modul…
Browse files Browse the repository at this point in the history
…es. Reverted code background style change
  • Loading branch information
Manason committed Sep 26, 2023
1 parent 5b771e6 commit fbdac29
Show file tree
Hide file tree
Showing 10 changed files with 52 additions and 91 deletions.
2 changes: 1 addition & 1 deletion pages/contributors.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ Before creating enhancement suggestions, please check [this list](#before-submit

- **Make sure it doesn't already exist.** Sounds silly, but there's a lot of features built in to Qbox that people don't realize so take a look through the docs and stuff to make sure it's not already there.
- **Check if there's already PR which provides that enhancement.**
- **Determine which resource the enhancement should be suggested in.** Whichever resource the suggestion is about, is where it should go. If the suggestion is about Qbox as a whole, make the suggestion in the qbx-core repository.
- **Determine which resource the enhancement should be suggested in.** Whichever resource the suggestion is about, is where it should go. If the suggestion is about Qbox as a whole, make the suggestion in the qbx_core repository.
- **Perform a [cursory search](https://github.com/search?q=is%3Aissue+user%3Aqbox-project++&type=issues&state=open)** to see if the enhancement has already been suggested. If it has, add a comment to the existing issue instead of opening a new one.

#### How Do I Submit A (Good) Enhancement Suggestion?
Expand Down
5 changes: 2 additions & 3 deletions pages/converting.mdx
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
# Converting to Qbox from Qb

1. Check your job grades in `qbx-core/shared/jobs.lua`. In Qbox, job grades are numbers without quotations, whereas in Qb they are strings.
1. Check your job grades in `qbx_core/shared/jobs.lua`. In Qbox, job grades are numbers without quotations, whereas in Qb they are strings.
2. Configure ox_inventory and convert your database. Back it up first! https://overextended.dev/ox_inventory/Frameworks/qb
3. For security, by default Qbox sets entity lock down mode to relaxed, which prevents clients from spawning networked entities. If you need to change this setting to support scripts that do this, set convar qbx:bucketlockdownmode to 'inactive'
4. Qbox has multicharacter built-in to core. If you want to keep using your own multicharacter resource, disable core's via core config. Otherwise delete your multicharacter resource.
5. Qbox maintains a qb compatibility layer, so you can continue to use exports['qb-core']. However, this means you won't get access to all the Qbox features and functions. So consider switching off of exports['qb-core'] when you can.

# Switching a resource from Qb to Qbox
1. Import the needed modules from qbx-core to supply replacement functions for ones from QBCore
1. Import the needed modules from qbx_core to supply replacement functions for ones from QBCore
2. Replace calls to QBCore one by one with calls to the imported modules. Both can be used at the same time, so conversion can be done partially, or over time.
3. After all QBCore is no longer being called, remove it
2 changes: 1 addition & 1 deletion pages/developers.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Developer's Guide

This guide is intended for those creating scripts using qbx-core. Following these principles will make it less likely for your
This guide is intended for those creating scripts using qbx_core. Following these principles will make it less likely for your
script to break in future Qbox updates.

## Do not access database tables owned by core
Expand Down
4 changes: 2 additions & 2 deletions pages/resources/core/events/client.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ Player's permissions are updated. Only works for permissions set by qbx
RegisterNetEvent('QBCore:Client:OnPermissionUpdate', function() end)
```

### qbx-core:client:playerLoggedOut
### qbx_core:client:playerLoggedOut

Player logs out and no longer exists in core memory

```lua
RegisterNetEvent('qbx-core:client:playerLoggedOut', function() end)
RegisterNetEvent('qbx_core:client:playerLoggedOut', function() end)
```

### QBCore:Client:OnJobUpdate
Expand Down
2 changes: 1 addition & 1 deletion pages/resources/core/events/server.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { Callout } from "nextra/components";

## Non-Networked Events

### QBCore:Server:PlayerLoaded
### QBCore:Server:OnPlayerLoaded

Player has finished loading

Expand Down
12 changes: 2 additions & 10 deletions pages/resources/core/functions/client.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,9 @@ import { Callout } from "nextra/components";
## Module: core

<Callout type="info">
called using `QBCore.Functions.<FunctionName>`
called using `QBX.Functions.<FunctionName>`
</Callout>

### GetPlayerData

get playerData via callback or return

```lua
---@param cb? fun(playerData: PlayerData)
---@return PlayerData? playerData
```

### Notify

Expand Down Expand Up @@ -171,7 +163,7 @@ Returns the closest entity from the list and the specified coords (if set)
### GetClosestPed

Returns the closest ped.
Use QBCore.Functions.GetClosestPlayer if wanting to ignore non-player peds.
Use QBX.Functions.GetClosestPlayer if wanting to ignore non-player peds.

```lua
---@param coords? vector3 uses player position if not set
Expand Down
66 changes: 8 additions & 58 deletions pages/resources/core/functions/server.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,91 +5,41 @@ import { Callout } from "nextra/components";
## Exports

<Callout type="info">
called using `exports['qbx-core']:<FunctionName>`
called using `exports['qbx_core']:<FunctionName>`
</Callout>

### AddJob
### CreateJobs

Single add job function which should only be used if you planning on adding a single job

```lua
---@param jobName string
---@param job Job
---@return boolean success
---@return string message
```

### AddJobs

Add multiple jobs
Add or overwrite jobs. This is a runtime only change and will not modify files.

```lua
---@param jobs table<string, Job>
---@return boolean success
---@return string message
---@return Job? errorJob job causing the error message. Only present if success is false.
```

### RemoveJob

Single Remove Job

```lua
---@param jobName string
---@return boolean success
---@return string message
```

### UpdateJob

-- Single Update Job
Remove a job from memory. This is a runtime only change and will not modify files.

```lua
---@param jobName string
---@param job Job
---@return boolean success
---@return string message
```

### AddGang
### CreateGangs

Single Add Gang

```lua
---@param gangName string
---@param gang Gang
---@return boolean success
---@return string message
```

### AddGangs

Multiple Add Gangs
Add or overwrite gangs. This is a runtime only change and will not modify files.

```lua
---@param gangs table<string, Gang>
---@return boolean success
---@return string message
---@return Gang? errorGang present if success is false. Gang that caused the error message.
```

### RemoveGang

Single Remove Gang

```lua
---@param gangName string
---@return boolean success
---@return string message
```

### UpdateGang

Single Update Gang
Remove a gang from memory. This is a runtime only change and will not modify files.

```lua
---@param gangName string
---@param gang Gang
---@return boolean success
---@return string message
```
Expand All @@ -111,7 +61,7 @@ Single Update Gang
## Module: core

<Callout type="info">
called using `QBCore.Functions.<FunctionName>`
called using `QBX.Functions.<FunctionName>`
</Callout>

### GetSource
Expand Down
9 changes: 0 additions & 9 deletions pages/resources/core/functions/shared.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,6 @@ Returns the number plate of the specified vehicle
---@return string?
```

### DebugPrint

When sending a table, prints the contents of it, otherwise it prints the string directly

```lua
---@param value string | table
---@param indent? integer
```

### CommaValue

Converts a number to a string version with commas
Expand Down
37 changes: 35 additions & 2 deletions pages/resources/core/import.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ You can load this inside another resource you have, for example one named 'test_
You can add the following to your fxmanifest.lua to then add the module in there:

```lua
shared_script '@qbx-core/import.lua'
shared_script '@qbx_core/import.lua'

module 'test:hack'
```
Expand All @@ -39,7 +39,7 @@ or
To specify multiple modules

```lua
shared_script '@qbx-core/import.lua'
shared_script '@qbx_core/import.lua'

modules {
'test:hack',
Expand All @@ -49,3 +49,36 @@ modules {
That code will now load the hack.lua inside the test/modules/ folder into the test_hack resource as it's own script.

That means you can use it like any other script you have in your own resource.

# Modules

## core
Adds global QBX with slightly different fields depending on if importing on the client or the server

###### client
```lua
QBX.Config -- access global config created in config.lua
QBX.Shared -- access tables of jobs, gangs, locations, etc. https://github.com/Qbox-project/qbx_core/blob/main/shared/main.lua
QBX.Functions -- invoke core functions Ex: 'QBX.Functions.<function name>()'
QBX.IsLoggedIn -- whether the player has finished selecting a character
```

###### server
```lua
QBX.Config -- access global config created in config.lua
QBX.Shared -- access tables of jobs, gangs, locations, etc. https://github.com/Qbox-project/qbx_core/blob/main/shared/main.lua
QBX.Functions -- invoke core functions Ex: 'QBX.Functions.<function name>()'

---@type table<Source, Player>
QBX.Players = {}

---@type table<itemName, table>
QBX.UsableItems = {}
```

## playerdata
Adds global QBX.PlayerData and keeps it updated
https://github.com/Qbox-project/qbx_core/blob/14edd8e082b6579ef30a5e34df29f5a26bc29a21/server/player.lua#L3

## utils
Import global utility functions
4 changes: 0 additions & 4 deletions style.css
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
a {
text-decoration: none !important;
}

pre {
background-color: #1b1b1b !important;
}

0 comments on commit fbdac29

Please sign in to comment.