Skip to content

Commit

Permalink
Merge branch 'ox_core'
Browse files Browse the repository at this point in the history
  • Loading branch information
thelindat committed Jun 12, 2024
2 parents 9fad439 + 026c598 commit c20a89b
Show file tree
Hide file tree
Showing 101 changed files with 1,130 additions and 755 deletions.
100 changes: 47 additions & 53 deletions pages/ox_core.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { NpmButton } from '@components/button';

<ResourceLinks repo="https://github.com/overextended/ox_core" />

An experimental framework for FiveM. Limited support and breaking changes guaranteed.
A modern FiveM framework. Limited support and breaking changes guaranteed.

<Callout type="warning">

Expand All @@ -20,106 +20,100 @@ Documentation may not be kept updated in some cases.

<Callout type="info">

We **strongly** recommend referring to [Guides](../guides) for setting up Git, Node.js, and pnpm.
We **strongly** recommend referring to [Guides](../guides) to setup necessary development tools.

</Callout>

<Steps>
### Install all resource dependencies.
- [oxmysql](../oxmysql)
- [ox_lib](../ox_lib/)
- [fivem-appearance](https://github.com/pedr0fontoura/fivem-appearance)
- [ox_appearance](https://github.com/overextended/ox_appearance)

### Download a [release](https://github.com/overextended/ox_core/releases) or build the source code.
### Download the latest [release](https://github.com/overextended/ox_core/releases/latest) or build the source code.

- Setup [Git](../guides/git), [Node.js](../guides/nodejs), and [pnpm](../guides/pnpm).
- Download and setup [MariaDB](https://mariadb.com/downloads/community/community-server/), if you do not already have a database server.
- Run the following commands in your CLI (e.g. Terminal, Command Prompt).

```bash
git clone https://github.com/overextended/ox_core.git
cd ox_core/web
cd ox_core
pnpm i
pnpm build
```

### Install optional dependencies.

These resources aren't required but provide additional functionality.
These resources aren't strictly required, but they are strongly recommended.

- [ox_inventory](../ox_inventory/)
- [npwd](https://github.com/project-error/npwd)
- [pefcl](https://github.com/project-error/pefcl)

### (Optional) Configure pefcl

If using it with ox_inventory, open `pefcl/config.json` and enable framework integration.

```json
"frameworkIntegration": {
"enabled": true,
"resource": "ox_inventory",
"syncInitialBankBalance": false
},
```
- [illenium-appearance](https://github.com/iLLeniumStudios/illenium-appearance/archive/refs/heads/main.zip)

</Steps>

## Importing into resources
## Using ox_core in your resources

### Lua

Lua imports can be defined as part of fxmanifest, or loaded with the load function.
You can import ox_core definitions by loading `@ox_core/lib/init.lua` into your resource.

<Tabs items={['fxmanifest', 'load']}>
<Tabs items={['fxmanifest.lua', 'require']}>
<Tab>

Add the import path into your resource's fxmanifest.lua, like any other script file.
This can be a client_script or server_script, if necessary.
```lua
client_scripts {
'@ox_core/imports/client.lua',
'client/main.lua',
}

server_scripts {
'@oxmysql/lib/MySQL.lua',
'@ox_core/imports/server.lua',
'server/main.lua',
}
shared_script '@ox_core/lib/init.lua'
```

</Tab>
<Tab>

If you prefer, you can use our [require](../ox_lib/Modules/Require/Shared) function from [ox_lib](../ox_lib).
```lua
local file = ('imports/%s.lua'):format(IsDuplicityVersion() and 'server' or 'client')
local import = LoadResourceFile('ox_core', file)
local chunk = assert(load(import, ('@@ox_core/%s'):format(file)))
chunk()
local Ox = require '@ox_core/lib/init.lua'
```

</Tab>
</Tabs>

### JavaScript

To use ox_core with your JS/TS resources you'll need to use our npm package, allowing you to import core functions with full type and intellisense support.
To use ox_core with your JavaScript resources you'll need to use our npm package, providing full support for TypeScript and Intellisense.

<NpmButton link="https://www.npmjs.com/package/@overextended/ox_core" />

## Config

Resource configuration is handled using [convars](https://docs.fivem.net/docs/scripting-reference/convars/).
To get started, try our [fivem-typescript-boilerplate](https://github.com/overextended/fivem-typescript-boilerplate) and install the ox_core package.

```bash
# Players must have a valid identifier to join the server. Used to fetch userid from the database.
set ox:primaryIdentifier "fivem"

# Set the number of active characters a user can have registered.
setr ox:characterSlots 5
pnpm i @overextended/ox_core
```

# Enables debug and development features. Should only be used in a development environment.
setr ox:debug 0
## Config

# Disable death system handle by core.
setr ox:deathSystem 0
Resource configuration is handled using [convars](https://docs.fivem.net/docs/scripting-reference/convars/).

# Disable the spawn selection.
setr ox:spawnSelect 0
```
### Replicated

These convars should use the `setr` command to be read by clients.

- `ox:debug`
- Default: `false`
- Enables debug messages and commands. Enabled by default when using `pnpm watch`.
- `ox:characterSlots`
- Default: `1`
- Sets the number of character slots available for character selection resources (e.g. ox_charselect).
- `ox:plateFormat`
- Default: `"........"`
- See [SET_DEFAULT_VEHICLE_NUMBER_PLATE_TEXT_PATTERN](https://docs.fivem.net/natives/?_0x79780FD2).
- `ox:deathSystem`
- Default: `true`
- Enables the built-in death and respawn system.
- `ox:characterSelect`
- Default: `true`
- Enables built-in character registration, and uses uses that character when joining.
- `ox:spawnLocation`
- Default: `[-258.211, -293.077, 21.6132, 206.0]`
- Sets the default spawn location for newly created characters.

10 changes: 10 additions & 0 deletions pages/ox_core/Classes/Client/OxPlayer.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
title: OxPlayer
---

# OxPlayer

- state: `StateBagInterface`
- userId: `number`
- charId?: `number`
- stateId?: `string`
11 changes: 11 additions & 0 deletions pages/ox_core/Classes/Client/OxPlayer/addStatus.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
title: addStatus
---

# OxPlayer.addStatus

Description..

```lua
player.addStatus(statusName: string, value: number): boolean
```
11 changes: 11 additions & 0 deletions pages/ox_core/Classes/Client/OxPlayer/get.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
title: get
---

# OxPlayer.get

Description..

```lua
player.get(key: string): unknown
```
11 changes: 11 additions & 0 deletions pages/ox_core/Classes/Client/OxPlayer/getCoords.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
title: getCoords
---

# OxPlayer.getCoords

Description..

```lua
player.getCoords(getShared?: boolean): Vector3
```
13 changes: 13 additions & 0 deletions pages/ox_core/Classes/Client/OxPlayer/getGroup.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
title: getGroup
---

# OxPlayer.getGroup

Description..

```lua
player.getGroup(filter: string): number
player.getGroup(filter: string[]): [string, number]
player.getGroup(filter: Record<string, number>): [string, number]
```
11 changes: 11 additions & 0 deletions pages/ox_core/Classes/Client/OxPlayer/getGroupByType.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
title: getGroupByType
---

# OxPlayer.getGroupByType

Description..

```lua
player.getGroupByType(type: string): [string, number]
```
11 changes: 11 additions & 0 deletions pages/ox_core/Classes/Client/OxPlayer/getGroups.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
title: getGroups
---

# OxPlayer.getGroups

Description..

```lua
player.getGroups(): Record<string, number>
```
11 changes: 11 additions & 0 deletions pages/ox_core/Classes/Client/OxPlayer/getStatus.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
title: getStatus
---

# OxPlayer.getStatus

Description..

```lua
player.getStatus(statusName: string): number
```
11 changes: 11 additions & 0 deletions pages/ox_core/Classes/Client/OxPlayer/getStatuses.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
title: getStatuses
---

# OxPlayer.getStatuses

Description..

```lua
player.getStatuses(): Record<string, number>
```
11 changes: 11 additions & 0 deletions pages/ox_core/Classes/Client/OxPlayer/hasPermission.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
title: hasPermission
---

# OxPlayer.hasPermission

Description..

```lua
player.hasPermission(permission: string): boolean
```
11 changes: 11 additions & 0 deletions pages/ox_core/Classes/Client/OxPlayer/on.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
title: on
---

# OxPlayer.on

Description..

```lua
player.on(key: string, cb: (data: unknown) => void): unknown
```
11 changes: 11 additions & 0 deletions pages/ox_core/Classes/Client/OxPlayer/removeStatus.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
title: removeStatus
---

# OxPlayer.removeStatus

Description..

```lua
player.removeStatus(statusName: string, value: number): boolean
```
11 changes: 11 additions & 0 deletions pages/ox_core/Classes/Client/OxPlayer/setStatus.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
title: setStatus
---

# OxPlayer.setStatus

Description..

```lua
player.setStatus(statusName: string, value: number): boolean
```
14 changes: 14 additions & 0 deletions pages/ox_core/Classes/Server/OxPlayer.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
title: OxPlayer
---

# OxPlayer

- charId: `number`
- identifier: `string`
- ped: `number`
- source: `number`
- state: `StateBagInterface`
- stateId: `string`
- userId: `number`
- username: `string`
11 changes: 11 additions & 0 deletions pages/ox_core/Classes/Server/OxPlayer/addLicense.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
title: addLicense
---

# OxPlayer.addLicense

Description..

```lua
player.addLicense(licenseName: string): Promise<boolean>
```
11 changes: 11 additions & 0 deletions pages/ox_core/Classes/Server/OxPlayer/addStatus.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
title: addStatus
---

# OxPlayer.addStatus

Description..

```lua
player.addStatus(statusName: string, value: number): boolean
```
11 changes: 11 additions & 0 deletions pages/ox_core/Classes/Server/OxPlayer/createCharacter.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
title: createCharacter
---

# OxPlayer.createCharacter

Description..

```lua
player.createCharacter(data: object): Promise<number>
```
11 changes: 11 additions & 0 deletions pages/ox_core/Classes/Server/OxPlayer/deleteCharacter.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
title: deleteCharacter
---

# OxPlayer.deleteCharacter

Description..

```lua
player.deleteCharacter(charId: number): Promise<boolean>
```
11 changes: 11 additions & 0 deletions pages/ox_core/Classes/Server/OxPlayer/emit.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
title: emit
---

# OxPlayer.emit

Description..

```lua
player.emit(eventName: string, ...args)
```
Loading

0 comments on commit c20a89b

Please sign in to comment.