From 26e93458effac8d234b92c5f8c52e3689428c949 Mon Sep 17 00:00:00 2001 From: Luke Date: Fri, 8 Jul 2022 12:49:29 +0200 Subject: [PATCH 1/2] context menu item icons --- docs/ox_lib/Interface/Client/context.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/docs/ox_lib/Interface/Client/context.md b/docs/ox_lib/Interface/Client/context.md index fff30f77..9f69b0d0 100644 --- a/docs/ox_lib/Interface/Client/context.md +++ b/docs/ox_lib/Interface/Client/context.md @@ -17,6 +17,8 @@ Used for registering a context menu. -- item: key as string or table -- title: string (optional - if item isn't key) -- menu: string (optional) + -- icon: string (optional) + -- iconColor: string (optional) -- arrow: boolean (optional) -- description: string (optional) -- metadata: string table or key, value table or table (optional) @@ -33,11 +35,13 @@ as you'd like. `title` - Every menu must have a title. `menu` - Menu identifier - if defined there will be a back arrow next to the menu title that will take you to the menu you defined. -`onExit` - Function that will be ran when the user closes their context menu with ESC. +`onExit` - Function that will be ran when the user closes their context menu with ESC. `options` - Contains all the clickable menu items. `item` - Defined as a key, can be empty if you don't want it to do anything. `item/title` - If not using keys then sets the title for the button. `item/image` - Image url, puts the image at the top of the metadata popover. +`item/icon` - FontAwesome icon that will be displayed on the left side, works the same as notification and textui icons. +`item/iconColor` - Color of the displayed icon. `item/menu` - Menu identifier that the button will take you to, when defined an arrow pointing to the right to indicate a menu will be shown. `item/arrow` - Shows an arrow on the right side like `menu` does, useful when you are From aeb90c297fab2e5f5cb74de1e0fdaddbe501cd47 Mon Sep 17 00:00:00 2001 From: Luke Date: Wed, 13 Jul 2022 21:34:22 +0200 Subject: [PATCH 2/2] add js/ts versions of methods --- docs/ox_core/Player/Server/index.md | 34 +++++++++ docs/ox_core/Player/Server/methods.md | 102 ++++++++++++++++++++++++++ docs/ox_core/index.md | 24 ++++++ src/components/IconButton.tsx | 3 +- 4 files changed, 162 insertions(+), 1 deletion(-) diff --git a/docs/ox_core/Player/Server/index.md b/docs/ox_core/Player/Server/index.md index dce2bfcf..da9a97f1 100644 --- a/docs/ox_core/Player/Server/index.md +++ b/docs/ox_core/Player/Server/index.md @@ -3,19 +3,39 @@ title: Server sidebar_position: 1 --- +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; + ## Ox.GetPlayer Return an instance of CPlayer for the given player source. + + ```lua local player = Ox.GetPlayer(source) print(json.encode(player, { indent = true })) ``` + + + +```ts +import { GetPlayer } from '@overextended/ox_core/server' + +const player = GetPlayer(source) +console.log(JSON.stringify(player, null, 2)) +``` + + + ## Ox.GetPlayers Returns an array containing all players. Methods will not be applied if the first argument is false. + + + ```lua local players = Ox.GetPlayers(usemetatable) @@ -24,3 +44,17 @@ for i = 1, #players do print(json.encode(player, { indent = true })) end ``` + + + +```ts +import { GetPlayers } from '@overextended/ox_core/server' + +const players = GetPlayers() +for (let i = 0; i < players.length; i++) { + const player = players[i] + console.log(JSON.stringify(player, null, 2)) +} +``` + + \ No newline at end of file diff --git a/docs/ox_core/Player/Server/methods.md b/docs/ox_core/Player/Server/methods.md index 839362d0..9d15ddd6 100644 --- a/docs/ox_core/Player/Server/methods.md +++ b/docs/ox_core/Player/Server/methods.md @@ -2,70 +2,172 @@ title: Methods --- +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; + These functions are inherited by instances of CPlayer. + + + + ```lua local player = Ox.GetPlayer(source) ``` + + + +```ts +import { GetPlayer } from '@overextended/ox_core/server' + +const player = GetPlayer(source) +``` + + ## player.set Sets the player's metadata for key to the given value. + + + + ```lua local key, value = 'iq', 300 player.set(key, value) ``` + + + +```ts +const [key, value] = ['iq', 300] +player.set(key, value) +``` + + + ## player.get Return the player's metadata. Sending an argument will retrieve a specific metadata key. + + + ```lua local data = player.get() local iq = player.get('iq') ``` + + + +```ts +const data = player.get() +const iq = player.get('iq') +``` + + ## player.getCoords Return the player's world position. The value will be cached for future calls, so send true for the first argument to update it. + + + ```lua local coords = player.getCoords(update) ``` + + + +```ts +const coords = player.getCoords(update) +``` + + ## player.setGroup Updates the player's grade for the given group. A value of 0 will remove the player + + + ```lua local group, grade = 'police', 3 player.setGroup(group, grade) ``` + + + +```ts +const [group, grade] = ['police', 3] +player.setGroup(group, grade) +``` + + ## player.hasGroup Check if the player is a member of a given group, and returns the matching group name and grade. The filter can be a string, array, or object where key is the group, and value is the minimum grade. + + + ```lua local filter = { police = 0, sheriff = 0 } local group, grade = player.hasGroup(filter) ``` + + + +```ts +const filter = { police: 0, sheriff: 0 } +const [group, grade] = player.hasGroup(filter) +``` + + ## player.isPlayerInScope Check if the given source is inside the player's scope. + + + ```lua local target = 2 local inScope = player.isPlayerInScope(target) ``` + + + +```ts +const target = 2 +const inScope = player.isPlayerInScope(target) +``` + + ## player.triggerScopedEvent Trigger a client event for all players in the player's scope. + + + ```lua player.triggerScopedEvent(eventName, ...) ``` + + + +```ts +player.triggerScopedEvent(eventName, ...) +``` + + + diff --git a/docs/ox_core/index.md b/docs/ox_core/index.md index 0583077c..a7d4c220 100644 --- a/docs/ox_core/index.md +++ b/docs/ox_core/index.md @@ -5,6 +5,8 @@ sidebar_position: 1 import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; +import IconButton from '@site/src/components/IconButton'; +import { FaNpm } from 'react-icons/fa'; :::caution @@ -66,3 +68,25 @@ pnpm build | Name | Default | Replicated | |------|------------|---------| | ox:primaryIdentifier | fivem | false + +## Importing the core functions + + + +Functions are imported by simply adding the import files to the fxmanifest. + +**Client:** +`@ox_core/imports/client.lua` + +**Server:** +`@ox_core/imports/server.lua` + + +If in case you want to write resources in JS/TS you will need to insteall our node client and server wrapper package, +which will allow you to use the core's functions with full type and intellisense support. + + +}>Package + + + \ No newline at end of file diff --git a/src/components/IconButton.tsx b/src/components/IconButton.tsx index bd3eef2f..de4b410e 100644 --- a/src/components/IconButton.tsx +++ b/src/components/IconButton.tsx @@ -1,7 +1,8 @@ import React from 'react'; interface Props { - icon: Element; + icon: React.ReactNode; + children: React.ReactNode; side: 'left' | 'right'; style?: React.CSSProperties; }