├── .circleci
└── config.yml
├── .editorconfig
├── .eslintignore
├── .eslintrc.js
├── .github
├── FUNDING.yml
└── ISSUE_TEMPLATE
│ ├── bug_report.md
│ └── feature_request.md
├── .gitignore
├── .prettierrc
├── CONTRIBUTING.md
├── DEVELOPMENT.md
├── LICENSE
├── README.md
├── examples
├── javascript
│ ├── .gitignore
│ ├── README.md
│ ├── client.config.js
│ ├── fxmanifest.lua
│ ├── package.json
│ └── src
│ │ └── index.js
└── typescript
│ ├── .gitignore
│ ├── README.md
│ ├── client.config.js
│ ├── fxmanifest.lua
│ ├── package.json
│ ├── src
│ └── index.ts
│ ├── tsconfig.json
│ └── tslint.json
├── package-lock.json
├── package.json
├── src
├── Audio.ts
├── Blip.ts
├── Camera.ts
├── Checkpoint.ts
├── Game.ts
├── GameplayCamera.ts
├── Model.ts
├── ParticleEffect.ts
├── ParticleEffectAsset.ts
├── Raycast.ts
├── RelationshipGroup.ts
├── Rope.ts
├── World.ts
├── enums
│ ├── Alignment.ts
│ ├── AudioFlag.ts
│ ├── BadgeStyle.ts
│ ├── Blip.ts
│ ├── Bone.ts
│ ├── CameraShake.ts
│ ├── CheckboxStyle.ts
│ ├── Checkpoint.ts
│ ├── CloudHat.ts
│ ├── Control.ts
│ ├── CursorSprite.ts
│ ├── Driving.ts
│ ├── ExplosionType.ts
│ ├── Font.ts
│ ├── ForceType.ts
│ ├── Gender.ts
│ ├── HelmetType.ts
│ ├── HudColor.ts
│ ├── HudComponent.ts
│ ├── InputMode.ts
│ ├── IntersectOptions.ts
│ ├── InvertAxis.ts
│ ├── Language.ts
│ ├── LoadingSpinnerType.ts
│ ├── MarkerType.ts
│ ├── NotificationType.ts
│ ├── Parachute.ts
│ ├── RadioStation.ts
│ ├── RagdollType.ts
│ ├── Relationship.ts
│ ├── RopeType.ts
│ ├── ScreenEffect.ts
│ ├── SpeechModifier.ts
│ ├── Vehicle.ts
│ ├── Weather.ts
│ ├── ZoneID.ts
│ └── index.ts
├── hashes
│ ├── MaterialHash.ts
│ ├── PedHash.ts
│ ├── VehicleHash.ts
│ ├── WeaponHash.ts
│ ├── WeatherTypeHash.ts
│ └── index.ts
├── index.ts
├── models
│ ├── Entity.ts
│ ├── EntityBone.ts
│ ├── EntityBoneCollection.ts
│ ├── Ped.ts
│ ├── PedBone.ts
│ ├── PedBoneCollection.ts
│ ├── Player.ts
│ ├── Prop.ts
│ ├── Vehicle.ts
│ ├── VehicleDoor.ts
│ ├── VehicleDoorCollection.ts
│ ├── VehicleMod.ts
│ ├── VehicleModCollection.ts
│ ├── VehicleToggleMod.ts
│ ├── VehicleWheel.ts
│ ├── VehicleWheelCollection.ts
│ ├── VehicleWindow.ts
│ ├── VehicleWindowCollection.ts
│ └── index.ts
├── ui
│ ├── Container.ts
│ ├── Effects.ts
│ ├── Fading.ts
│ ├── Hud.ts
│ ├── LoadingPrompt.ts
│ ├── Notification.ts
│ ├── Rectangle.ts
│ ├── Scaleform.ts
│ ├── Screen.ts
│ ├── Sprite.ts
│ ├── Text.ts
│ ├── Timerbar.ts
│ ├── index.ts
│ ├── interfaces
│ │ ├── IDrawable.ts
│ │ └── index.ts
│ └── menu
│ │ ├── Menu.ts
│ │ ├── MenuControl.ts
│ │ ├── MenuControls.ts
│ │ ├── MenuSettings.ts
│ │ ├── index.ts
│ │ ├── items
│ │ ├── UIMenuCheckboxItem.ts
│ │ ├── UIMenuItem.ts
│ │ ├── UIMenuListItem.ts
│ │ ├── UIMenuSeparatorItem.ts
│ │ ├── UIMenuSliderItem.ts
│ │ ├── index.ts
│ │ └── panels
│ │ │ ├── AbstractUIMenuPanel.ts
│ │ │ ├── UIMenuColorPanel.ts
│ │ │ ├── UIMenuGridPanel.ts
│ │ │ ├── UIMenuPercentagePanel.ts
│ │ │ ├── UIMenuStatisticsPanel.ts
│ │ │ ├── UIMenuStatisticsPanelItem.ts
│ │ │ └── index.ts
│ │ └── modules
│ │ ├── ListItem.ts
│ │ └── index.ts
└── utils
│ ├── Color.ts
│ ├── LiteEvent.ts
│ ├── Math.ts
│ ├── Point.ts
│ ├── PointF.ts
│ ├── Quaternion.ts
│ ├── Size.ts
│ ├── String.ts
│ ├── UUIDV4.ts
│ ├── Vector3.ts
│ └── index.ts
├── tsconfig.json
└── typedoc.json
/.circleci/config.yml:
--------------------------------------------------------------------------------
1 | version: 2
2 | jobs:
3 | build:
4 | docker:
5 | - image: circleci/node:10.16.3
6 | working_directory: ~/repo
7 |
8 | steps:
9 | - checkout
10 | - restore_cache:
11 | keys:
12 | - v1-dependencies-{{ checksum "package.json" }}
13 | - v1-dependencies-
14 |
15 | - run: npm install
16 | - save_cache:
17 | paths:
18 | - node_modules
19 | key: v1-dependencies-{{ checksum "package.json" }}
20 |
21 | # run tests!
22 | - run: npm run lint
23 | - run: npm run build
24 |
--------------------------------------------------------------------------------
/.editorconfig:
--------------------------------------------------------------------------------
1 | root = true
2 |
3 | [*]
4 | end_of_line = lf
5 | insert_final_newline = true
6 | indent_style = space
7 | indent_size = 2
8 |
9 | [*.md]
10 | trim_trailing_whitespace = false
--------------------------------------------------------------------------------
/.eslintignore:
--------------------------------------------------------------------------------
1 | .circleci/
2 | node_modules/
3 | lib/
4 | docs/
5 | examples/
--------------------------------------------------------------------------------
/.eslintrc.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | root: true,
3 | env: {
4 | 'node': true
5 | },
6 | parser: '@typescript-eslint/parser',
7 | plugins: ['@typescript-eslint'],
8 | extends: [
9 | 'eslint:recommended',
10 | 'plugin:@typescript-eslint/eslint-recommended',
11 | 'plugin:@typescript-eslint/recommended',
12 | 'prettier/@typescript-eslint',
13 | ],
14 | rules: {
15 | 'no-async-promise-executor': 'off'
16 | }
17 | };
--------------------------------------------------------------------------------
/.github/FUNDING.yml:
--------------------------------------------------------------------------------
1 | github: [d0p3t]
2 | custom: ['https://beta.gungame.store']
3 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/bug_report.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Bug report
3 | about: Create a report to help us improve
4 | title: "[BUG]"
5 | labels: bug
6 | assignees: ''
7 |
8 | ---
9 |
10 | **Describe the bug**
11 | A clear and concise description of what the bug is.
12 |
13 | **To Reproduce**
14 | Steps to reproduce the behavior:
15 | 1. Go to '...'
16 | 2. Use this code '....'
17 | 3. Download this example '....'
18 | 4. See error
19 |
20 | **Expected behavior**
21 | A clear and concise description of what you expected to happen.
22 |
23 | **Screenshots**
24 | If applicable, add screenshots to help explain your problem.
25 |
26 | **FiveM Client (please complete the following information):**
27 | - Canary: [e.g. yes, no]
28 | - Version [e.g. 2880]
29 |
30 | **FiveM Server (please complete the following information):**
31 | - OneSync: [e.g. on, off, population]
32 | - Artifact: [e.g. 2929]
33 |
34 | **Additional context**
35 | Add any other context about the problem here.
36 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/feature_request.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Feature request
3 | about: Suggest an idea for this project
4 | title: "[Request]"
5 | labels: enhancement
6 | assignees: ''
7 |
8 | ---
9 |
10 | **Is your feature request related to a problem? Please describe.**
11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
12 |
13 | **Describe the solution you'd like**
14 | A clear and concise description of what you want to happen.
15 |
16 | **Describe alternatives you've considered**
17 | A clear and concise description of any alternative solutions or features you've considered.
18 |
19 | **Additional context**
20 | Add any other context or screenshots about the feature request here.
21 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
2 | /lib
3 | /docs
4 | .idea
5 |
--------------------------------------------------------------------------------
/.prettierrc:
--------------------------------------------------------------------------------
1 | {
2 | "printWidth": 100,
3 | "trailingComma": "all",
4 | "singleQuote": true,
5 | "arrowParens": "avoid",
6 | "tabWidth": 2
7 | }
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # Contributing
2 |
3 | We welcome contributions and assistance! If you want to know where to start, check out our [Github Projects sorted by name](https://github.com/d0p3t/fivem-js/projects?query=is%3Aopen+sort%3Aname-asc).
4 |
5 | If you want to add a new feature, note that we strive to support the FiveM OneSync system, so keep that in mind when submitting feature requests.
6 |
7 | ## Development
8 |
9 | To get setup for development, refer to [DEVELOPMENT.md](./DEVELOPMENT.md)
10 |
11 | ## Issues
12 |
13 | We use GitHub issues to track public bugs and requests. Please ensure your bug description is clear and has sufficient instructions to be able to reproduce the issue. THe best way is to provide an example resource in JS that uses any of the fivem-js features directly.
14 |
15 | ## Pull Requests
16 |
17 | All active development of this project happens on GitHub. We actively welcome your [pull requests](https://help.github.com/articles/creating-a-pull-request).
18 |
19 | We require that all pull requests are made in the development branch. Please beware of that when opening a new PR.
20 |
21 | ## Commit Message Conventions
22 |
23 | We don't have any strict commit message rules, but we encourage you to keep your commit messages short and descriptive.
24 |
25 | ```
26 | docs: Scaleform + LoadingPrompt
27 | ```
28 | ```
29 | Added bone collections and Camera PointAt functions
30 | ```
31 |
32 | Both these commit messages are descriptive, short and to the point.
33 |
34 |
35 | ## License
36 |
37 | By contributing to fivem-js, you agree that your contributions will be licensed under the [LICENSE](./LICENSE) file in the project root directory.
--------------------------------------------------------------------------------
/DEVELOPMENT.md:
--------------------------------------------------------------------------------
1 | ### Getting Started
2 |
3 | 1. First, you need to have the latest git, node 12 or greater installed. OSX, Windows and Linux should all be supported as build environments. This may differ from FiveM's supported environments.
4 |
5 | **We do not use `yarn`, so it's not supported.**
6 |
7 | 1. For this repo by using the "Fork" button on the upper-right
8 | 2. Check out your fork
9 | ```
10 | git clone git@github.com:yournamehere/fivem-js.git
11 | ```
12 | 3. Install or Update all dependencies
13 | ```
14 | npm i
15 | ```
16 | 4. Get coding! If you've changed or added new functionality, update any relevant documentation. Ensure your work is committed within a feature branch.
17 | 5. Ensure the project has no linting errors and builds
18 | ```
19 | npm run lint
20 | npm run build
21 | ```
22 |
23 | ### Relevant Commands
24 | 1. `npm i` - install and link all packages
25 | 2. `npm run build` - builds using `tsc`
26 | 3. `npm run format` - autoformats with eslint --fix and prettier
27 | 4. `npm run lint` - checks for linting issues
28 | 5. `npm run docs` - builds documentation
29 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Remco Troost - https://www.d0p3t.nl
2 |
3 | Copyright © 2019
4 |
5 | -----
6 |
7 | THIS PROJECT USES A CUSTOM LICENSE. MAKE SURE TO READ IT BEFORE THINKING ABOUT DOING ANYTHING WITH FIVEM-JS.
8 |
9 | -----
10 |
11 | - YOU ARE ALLOWED TO USE FIVEM-JS ON AS MANY SERVERS AS YOU WANT.
12 | - _YOU ARE ALSO ALLOWED TO EDIT THIS RESOURCE TO ADD/CHANGE/REMOVE WHATEVER YOU WANT._ (see the exception to this rule in the "credits" section below)
13 | - **YOU ARE HOWEVER _NOT_ ALLOWED TO RE-RELEASE (EDITED OR NON-EDITED) VERSIONS OF THIS NPM PACKAGE WITHOUT WRITTEN PERMISSIONS BY MYSELF (REMCO TROOST / D0P3T). FOR ADDED FEATURES/CHANGES, FEEL FREE TO CREATE A FORK & CREATE A PULL REQUEST.**
14 |
15 | ----
16 |
17 | **Credits**
18 |
19 | Never should you change the credits (for example in the source code comment section) to claim this resource to be your own. 90% of the users will recognize this npm package as being fivem-js, so changing the name of it and removing the credits section, is just useless. You're just being extremely rude and nodoby likes you anymore if they find out you're a big fat liar.
20 |
21 | -----
22 |
23 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
24 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
fivem-js
2 |
3 |
4 | :fire: A Javascript/Typescript wrapper for the FiveM natives :video_game:
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 | Website
29 | -
30 | Documentation
31 | -
32 | Forum
33 | -
34 | Discord
35 |
36 |
37 | Functionality of this wrapper is **based on the FiveM C# wrapper** - [link](https://github.com/citizenfx/fivem/tree/master/code/client/clrcore/External). It's a feature-rich set of helper classes, objects, and functions to help you develop your project faster.
38 |
39 | ## Features
40 |
41 | - One dependency [@citizenfx/client](https://www.npmjs.com/package/@citizenfx/client)
42 | - Abstracts common used FiveM practices
43 | - Entity management through class objects (i.e. `Vehicle` and `Ped` entities)
44 | - UI elements such as `scaleforms` and loading `prompts`
45 | - Audio, Blips, Cameras and more...
46 |
47 | In other words, whatever the FiveM C# wrapper can do, this package can as well and more!
48 |
49 | ## Download & Install
50 |
51 | `npm i fivem-js`
52 |
53 | https://www.npmjs.com/package/fivem-js
54 |
55 |
56 | ## Simple Usage
57 |
58 | See [here](https://github.com/d0p3t/fivem-js/tree/master/examples) for example projects.
59 |
60 | ### Typescript
61 |
62 | ```typescript
63 | import * as Cfx from 'fivem-js';
64 |
65 | RegisterCommand(
66 | 'adder',
67 | async (source: number, args: string[]) => {
68 | const vehicle = await Cfx.World.createVehicle(
69 | new Cfx.Model('adder'),
70 | new Cfx.Vector3(1, 2, 3),
71 | 4,
72 | );
73 | Cfx.Game.PlayerPed.setIntoVehicle(vehicle, Cfx.VehicleSeat.Driver);
74 | },
75 | false,
76 | );
77 | ```
78 |
79 | You can also individually import classes.
80 |
81 | ```typescript
82 | import { World } from 'fivem-js/lib/World';
83 | ```
84 |
85 | ### Javascript
86 |
87 | ```js
88 | ///
89 | ///
90 |
91 | const Cfx = require('fivem-js');
92 |
93 | RegisterCommand(
94 | 'adder',
95 | async (source, args) => {
96 | const vehicle = await Cfx.World.createVehicle(
97 | new Cfx.Model('adder'),
98 | new Cfx.Vector3(1, 2, 3),
99 | 4,
100 | );
101 | Cfx.Game.PlayerPed.setIntoVehicle(vehicle, Cfx.VehicleSeat.Driver);
102 | },
103 | false,
104 | );
105 | ```
106 |
107 | ## Community Chat
108 |
109 | You can join our public help Discord [here](https://discord.d0p3t.nl)
110 |
111 | ## Contributing
112 |
113 | You are more than welcome to contribute to this project by submitting a pull request and creating issues.
114 |
115 | Please checkout [CONTRIBUTING.md](./CONTRIBUTING.md) for our contributing guidelines.
116 |
117 | ## License
118 |
119 | MIT with customization. See [LICENSE](https://github.com/d0p3t/fivem-js/blob/master/LICENSE)
120 |
--------------------------------------------------------------------------------
/examples/javascript/.gitignore:
--------------------------------------------------------------------------------
1 | ./dist/
2 | ./node-modules/
--------------------------------------------------------------------------------
/examples/javascript/README.md:
--------------------------------------------------------------------------------
1 | ## fivem-js Javascript Example
2 |
3 | This example compiles a JavaScript webpack project that you can use in your FiveM server. It allows a player to spawn an Adder vehicle at their current location and sets the player into the vehicle.
4 | Thanks to the [`yarn` and `webpack` resources](https://github.com/citizenfx/cfx-server-data/tree/master/resources/%5Bsystem%5D/%5Bbuilders%5D), dependencies will be installed and the project will be automagically compiled on resource start.
5 |
--------------------------------------------------------------------------------
/examples/javascript/client.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | entry: './src/index.js',
3 | output: {
4 | filename: 'index.js',
5 | path: __dirname + '/dist/',
6 | },
7 | };
8 |
--------------------------------------------------------------------------------
/examples/javascript/fxmanifest.lua:
--------------------------------------------------------------------------------
1 | fx_version 'cerulean'
2 |
3 | games { 'gta5' }
4 |
5 | dependency 'webpack'
6 | dependency 'yarn'
7 |
8 | webpack_config 'client.config.js'
9 |
10 | client_script 'dist/index.js'
11 |
--------------------------------------------------------------------------------
/examples/javascript/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "fivem-js-example-javascript",
3 | "version": "1.0.1",
4 | "description": "",
5 | "main": "index.js",
6 | "keywords": [],
7 | "author": "",
8 | "license": "ISC",
9 | "dependencies": {
10 | "fivem-js": "^1.3.0"
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/examples/javascript/src/index.js:
--------------------------------------------------------------------------------
1 | import * as Cfx from 'fivem-js';
2 |
3 | RegisterCommand(
4 | 'adder',
5 | async (source, args) => {
6 | const playerCoords = Cfx.Game.PlayerPed.Position;
7 | const vehicle = await Cfx.World.createVehicle(new Cfx.Model('adder'), playerCoords, 4);
8 | Cfx.Game.PlayerPed.setIntoVehicle(vehicle, Cfx.VehicleSeat.Driver);
9 | },
10 | false,
11 | );
12 |
--------------------------------------------------------------------------------
/examples/typescript/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules/
2 | dist/
3 | package-lock.json
--------------------------------------------------------------------------------
/examples/typescript/README.md:
--------------------------------------------------------------------------------
1 | ## fivem-js Typescript Example
2 |
3 | This example compiles a Typescript webpack project that you can use in your FiveM server. It allows a player to spawn an Adder vehicle at their current location and sets the player into the vehicle.
4 | Thanks to the [`yarn` and `webpack` resources](https://github.com/citizenfx/cfx-server-data/tree/master/resources/%5Bsystem%5D/%5Bbuilders%5D), dependencies will be installed and the project will be automagically compiled on resource start.
5 |
6 | For building without the FiveM builders, checkout [fivem-ts-boilerplate](https://github.com/d0p3t/fivem-ts-boilerplate)
--------------------------------------------------------------------------------
/examples/typescript/client.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | entry: './src/index.ts',
3 | mode: 'production',
4 | module: {
5 | rules: [
6 | {
7 | test: /\.tsx?$/,
8 | use: 'ts-loader',
9 | exclude: /node_modules/,
10 | },
11 | ],
12 | },
13 | optimization: {
14 | minimize: false,
15 | },
16 | resolve: {
17 | extensions: ['.tsx', '.ts', '.js'],
18 | },
19 | output: {
20 | filename: 'index.js',
21 | path: __dirname + '/dist/',
22 | },
23 | };
24 |
--------------------------------------------------------------------------------
/examples/typescript/fxmanifest.lua:
--------------------------------------------------------------------------------
1 | fx_version 'cerulean'
2 |
3 | games { 'gta5' }
4 |
5 | dependency 'webpack'
6 | dependency 'yarn'
7 |
8 | webpack_config 'client.config.js'
9 |
10 | client_script 'dist/index.js'
11 |
--------------------------------------------------------------------------------
/examples/typescript/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "fivem-js-example-typescript",
3 | "version": "1.0.1",
4 | "description": "",
5 | "main": "index.js",
6 | "author": "",
7 | "license": "ISC",
8 | "dependencies": {
9 | "@citizenfx/client": "^1.0.1383-1",
10 | "@types/node": "^12.0.12",
11 | "fivem-js": "^1.3.0"
12 | },
13 | "devDependencies": {
14 | "ts-loader": "^6.0.4",
15 | "typescript": "^3.3.3333"
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/examples/typescript/src/index.ts:
--------------------------------------------------------------------------------
1 | import * as Cfx from 'fivem-js';
2 |
3 | RegisterCommand(
4 | 'adder',
5 | async (source, args) => {
6 | const playerCoords = Cfx.Game.PlayerPed.Position;
7 | const vehicle = await Cfx.World.createVehicle(new Cfx.Model('adder'), playerCoords, 4);
8 | Cfx.Game.PlayerPed.setIntoVehicle(vehicle, Cfx.VehicleSeat.Driver);
9 | },
10 | false,
11 | );
12 |
--------------------------------------------------------------------------------
/examples/typescript/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "baseUrl": ".",
4 | "paths": {
5 | "*": ["types/*"]
6 | },
7 | "outDir": "./",
8 | "noImplicitAny": false,
9 | "module": "es6",
10 | "target": "es6",
11 | "allowJs": true,
12 | "lib": ["es2017"],
13 | "types": ["@citizenfx/client", "fivem-js", "@types/node"],
14 | "moduleResolution": "node"
15 | },
16 | "include": ["./**/*"],
17 | "exclude": []
18 | }
19 |
--------------------------------------------------------------------------------
/examples/typescript/tslint.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": ["tslint:recommended", "tslint-config-prettier"],
3 | "rules": {
4 | "no-console": false
5 | }
6 | }
7 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "fivem-js",
3 | "version": "1.5.2",
4 | "description": "Javascript/Typescript wrapper for the FiveM natives",
5 | "main": "lib/index.js",
6 | "types": "lib/index.d.ts",
7 | "scripts": {
8 | "build": "tsc",
9 | "format": "prettier --write \"src/**/*.ts\"",
10 | "lint": "eslint . --ext .ts",
11 | "prepare": "npm run build",
12 | "prepublishOnly": "npm run lint",
13 | "preversion": "npm run lint",
14 | "version": "npm run format && git add -A src",
15 | "postversion": "git push && git push --tags",
16 | "typedoc": "typedoc",
17 | "docs": "npm run typedoc -- --options typedoc.json"
18 | },
19 | "repository": {
20 | "type": "git",
21 | "url": "git+https://github.com/d0p3t/fivem-js.git"
22 | },
23 | "keywords": [
24 | "fivem",
25 | "wrapper",
26 | "javascript",
27 | "typescript",
28 | "citizenfx"
29 | ],
30 | "files": [
31 | "lib/**/*"
32 | ],
33 | "author": "Remco Troost ",
34 | "license": "MIT",
35 | "bugs": {
36 | "url": "https://github.com/d0p3t/fivem-js/issues"
37 | },
38 | "homepage": "https://d0p3t.nl",
39 | "devDependencies": {
40 | "@typescript-eslint/eslint-plugin": "^4.9.1",
41 | "@typescript-eslint/parser": "^4.9.1",
42 | "eslint": "^7.15.0",
43 | "eslint-config-prettier": "^7.0.0",
44 | "prettier": "^2.2.1",
45 | "typedoc": "^0.19.2",
46 | "typedoc-fivemjs-theme": "^0.2.7",
47 | "typescript": "^4.1.2"
48 | },
49 | "dependencies": {
50 | "@citizenfx/client": "^1.0.3281-1"
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/src/Audio.ts:
--------------------------------------------------------------------------------
1 | import { AudioFlag } from './enums';
2 | import { Entity } from './models';
3 | import { Vector3 } from './utils';
4 |
5 | export abstract class Audio {
6 | public static playSoundAt(position: Vector3, sound: string, set?: string): number {
7 | PlaySoundFromCoord(
8 | -1,
9 | sound,
10 | position.x,
11 | position.y,
12 | position.z,
13 | set ? set : null,
14 | false,
15 | 0,
16 | false,
17 | );
18 | return GetSoundId();
19 | }
20 |
21 | public static playSoundFromEntity(entity: Entity, sound: string, set?: string): number {
22 | PlaySoundFromEntity(-1, sound, entity.Handle, set ? set : null, false, 0);
23 | return GetSoundId();
24 | }
25 |
26 | public static playSoundFrontEnd(sound: string, set?: string): number {
27 | PlaySoundFrontend(-1, sound, set ? set : null, false);
28 | return GetSoundId();
29 | }
30 |
31 | public static stopSound(soundId: number): void {
32 | StopSound(soundId);
33 | }
34 |
35 | public static releaseSound(soundId: number): void {
36 | ReleaseSoundId(soundId);
37 | }
38 |
39 | public static hasSoundFinished(soundId: number): boolean {
40 | return !!HasSoundFinished(soundId);
41 | }
42 |
43 | public static setAudioFlag(flag: string | AudioFlag, toggle: boolean): void {
44 | if (typeof flag === 'string') {
45 | SetAudioFlag(flag, toggle);
46 | } else {
47 | SetAudioFlag(this.audioFlags[Number(flag)], toggle);
48 | }
49 | }
50 |
51 | public static playSound(soundFile: string, soundSet: string): void {
52 | this.releaseSound(this.playSoundFrontEnd(soundFile, soundSet));
53 | }
54 |
55 | public static playMusic(musicFile: string): void {
56 | if (this.cachedMusicFile !== null) {
57 | CancelMusicEvent(musicFile);
58 | }
59 | this.cachedMusicFile = musicFile;
60 | TriggerMusicEvent(musicFile);
61 | }
62 |
63 | public static stopMusic(musicFile?: string): void {
64 | if (musicFile === null) {
65 | if (this.cachedMusicFile !== null) {
66 | CancelMusicEvent(this.cachedMusicFile);
67 | this.cachedMusicFile = null;
68 | }
69 | } else {
70 | CancelMusicEvent(musicFile);
71 | }
72 | }
73 |
74 | protected static cachedMusicFile: string;
75 |
76 | private static readonly audioFlags: string[] = [
77 | 'ActivateSwitchWheelAudio',
78 | 'AllowCutsceneOverScreenFade',
79 | 'AllowForceRadioAfterRetune',
80 | 'AllowPainAndAmbientSpeechToPlayDuringCutscene',
81 | 'AllowPlayerAIOnMission',
82 | 'AllowPoliceScannerWhenPlayerHasNoControl',
83 | 'AllowRadioDuringSwitch',
84 | 'AllowRadioOverScreenFade',
85 | 'AllowScoreAndRadio',
86 | 'AllowScriptedSpeechInSlowMo',
87 | 'AvoidMissionCompleteDelay',
88 | 'DisableAbortConversationForDeathAndInjury',
89 | 'DisableAbortConversationForRagdoll',
90 | 'DisableBarks',
91 | 'DisableFlightMusic',
92 | 'DisableReplayScriptStreamRecording',
93 | 'EnableHeadsetBeep',
94 | 'ForceConversationInterrupt',
95 | 'ForceSeamlessRadioSwitch',
96 | 'ForceSniperAudio',
97 | 'FrontendRadioDisabled',
98 | 'HoldMissionCompleteWhenPrepared',
99 | 'IsDirectorModeActive',
100 | 'IsPlayerOnMissionForSpeech',
101 | 'ListenerReverbDisabled',
102 | 'LoadMPData',
103 | 'MobileRadioInGame',
104 | 'OnlyAllowScriptTriggerPoliceScanner',
105 | 'PlayMenuMusic',
106 | 'PoliceScannerDisabled',
107 | 'ScriptedConvListenerMaySpeak',
108 | 'SpeechDucksScore',
109 | 'SuppressPlayerScubaBreathing',
110 | 'WantedMusicDisabled',
111 | 'WantedMusicOnMission',
112 | ];
113 | }
114 |
--------------------------------------------------------------------------------
/src/Blip.ts:
--------------------------------------------------------------------------------
1 | import { Vector3 } from './utils';
2 | import { BlipColor, BlipSprite } from './enums';
3 | import { Entity, Player } from './models';
4 |
5 | export class Blip {
6 | protected handle: number;
7 |
8 | constructor(handle: number) {
9 | this.handle = handle;
10 | }
11 |
12 | public get Handle(): number {
13 | return this.handle;
14 | }
15 |
16 | public get Position(): Vector3 {
17 | const coords = GetBlipInfoIdCoord(this.handle);
18 | return new Vector3(coords[0], coords[1], coords[2]);
19 | }
20 |
21 | public set Position(location: Vector3) {
22 | SetBlipCoords(this.handle, location.x, location.y, location.z);
23 | }
24 |
25 | public set Rotation(rotation: number) {
26 | SetBlipRotation(this.handle, rotation);
27 | }
28 |
29 | public set Scale(scale: number) {
30 | SetBlipScale(this.handle, scale);
31 | }
32 |
33 | public get Type(): number {
34 | return GetBlipInfoIdType(this.handle);
35 | }
36 |
37 | public get Alpha(): number {
38 | return GetBlipAlpha(this.handle);
39 | }
40 |
41 | public set Alpha(alpha: number) {
42 | SetBlipAlpha(this.handle, alpha);
43 | }
44 |
45 | public set Priority(priority: number) {
46 | SetBlipPriority(this.handle, priority);
47 | }
48 |
49 | public set NumberLabel(number: number) {
50 | ShowNumberOnBlip(this.handle, number);
51 | }
52 |
53 | public get Color(): BlipColor {
54 | return GetBlipColour(this.handle);
55 | }
56 |
57 | public set Color(color: BlipColor) {
58 | SetBlipColour(this.handle, color);
59 | }
60 |
61 | public get Sprite(): BlipSprite {
62 | return GetBlipSprite(this.handle);
63 | }
64 |
65 | public set Sprite(sprite: BlipSprite) {
66 | SetBlipSprite(this.handle, sprite);
67 | }
68 |
69 | public set Display(display: number) {
70 | SetBlipDisplay(this.handle, display);
71 | }
72 |
73 | public set Name(name: string) {
74 | BeginTextCommandSetBlipName('STRING');
75 | AddTextComponentSubstringPlayerName(name);
76 | EndTextCommandSetBlipName(this.handle);
77 | }
78 |
79 | public setNameToPlayerName(player: Player): void {
80 | SetBlipNameToPlayerName(this.handle, player.Handle);
81 | }
82 |
83 | public get Entity(): Entity {
84 | return Entity.fromHandle(GetBlipInfoIdEntityIndex(this.handle));
85 | }
86 |
87 | public set ShowHeadingIndicator(show: boolean) {
88 | ShowHeadingIndicatorOnBlip(this.handle, show);
89 | }
90 |
91 | public set ShowRoute(show: boolean) {
92 | SetBlipRoute(this.handle, show);
93 | }
94 |
95 | public set IsFriendly(friendly: boolean) {
96 | SetBlipAsFriendly(this.handle, friendly);
97 | }
98 |
99 | public set IsFriend(friend: boolean) {
100 | SetBlipFriend(this.handle, friend);
101 | }
102 |
103 | public set IsCrew(crew: boolean) {
104 | SetBlipCrew(this.handle, crew);
105 | }
106 |
107 | public get IsFlashing(): boolean {
108 | return !!IsBlipFlashing(this.handle);
109 | }
110 |
111 | public set IsFlashing(flashing: boolean) {
112 | SetBlipFlashes(this.handle, flashing);
113 | }
114 |
115 | public get IsOnMinimap(): boolean {
116 | return !!IsBlipOnMinimap(this.handle);
117 | }
118 |
119 | public get IsShortRange(): boolean {
120 | return !!IsBlipShortRange(this.handle);
121 | }
122 |
123 | public set IsShortRange(shortRange: boolean) {
124 | SetBlipAsShortRange(this.handle, shortRange);
125 | }
126 |
127 | public removeNumberLabel(): void {
128 | HideNumberOnBlip(this.handle);
129 | }
130 |
131 | public delete(): void {
132 | if (this.exists()) {
133 | RemoveBlip(this.handle);
134 | }
135 | }
136 |
137 | public exists(): boolean {
138 | return !!DoesBlipExist(this.handle);
139 | }
140 | }
141 |
--------------------------------------------------------------------------------
/src/Camera.ts:
--------------------------------------------------------------------------------
1 | import { CameraShake } from './enums';
2 | import { Entity, PedBone } from './models';
3 | import { Vector3 } from './utils';
4 |
5 | export class Camera {
6 | private readonly shakeNames: string[] = [
7 | 'HAND_SHAKE',
8 | 'SMALL_EXPLOSION_SHAKE',
9 | 'MEDIUM_EXPLOSION_SHAKE',
10 | 'LARGE_EXPLOSION_SHAKE',
11 | 'JOLT_SHAKE',
12 | 'VIBRATE_SHAKE',
13 | 'ROAD_VIBRATION_SHAKE',
14 | 'DRUNK_SHAKE',
15 | 'SKY_DIVING_SHAKE',
16 | 'FAMILY5_DRUG_TRIP_SHAKE',
17 | 'DEATH_FAIL_IN_EFFECT_SHAKE',
18 | ];
19 |
20 | private handle: number;
21 |
22 | constructor(handle: number) {
23 | this.handle = handle;
24 | }
25 |
26 | public get IsActive(): boolean {
27 | return !!IsCamActive(this.handle);
28 | }
29 |
30 | public set IsActive(active: boolean) {
31 | SetCamActive(this.handle, active);
32 | }
33 |
34 | public get Position(): Vector3 {
35 | const pos = GetCamCoord(this.handle);
36 | return new Vector3(pos[0], pos[1], pos[2]);
37 | }
38 |
39 | public set Position(position: Vector3) {
40 | SetCamCoord(this.handle, position.x, position.y, position.z);
41 | }
42 |
43 | public get Rotation(): Vector3 {
44 | const rot = GetCamRot(this.handle, 2);
45 | return new Vector3(rot[0], rot[1], rot[2]);
46 | }
47 |
48 | public set Rotation(rotation: Vector3) {
49 | SetCamRot(this.handle, rotation.x, rotation.y, rotation.z, 2);
50 | }
51 |
52 | // public get Matrix() : Matrix {}
53 |
54 | /**
55 | * Gets the direction the camera is facing. Same as ForwardVector
56 | */
57 | public get Direction(): Vector3 {
58 | return this.ForwardVector;
59 | }
60 |
61 | public set Direction(direction: Vector3) {
62 | const dir = direction.normalize;
63 |
64 | const vec1 = new Vector3(dir.x, dir.y, 0);
65 | const vec2 = new Vector3(dir.z, vec1.distanceSquared(vec1), 0);
66 | const vec3 = vec2.normalize;
67 |
68 | this.Rotation = new Vector3(
69 | Math.atan2(vec3.x, vec3.y) * 57.295779513082323,
70 | this.Rotation.y,
71 | Math.atan2(dir.x, dir.y) * -57.295779513082323,
72 | );
73 | }
74 |
75 | // public get UpVector() : Vector3 {
76 | // return Matrix.Up;
77 | // }
78 |
79 | public get ForwardVector(): Vector3 {
80 | const rotation = Vector3.multiply(this.Rotation, Math.PI / 180);
81 | const normalized = Vector3.normalize(
82 | new Vector3(
83 | -Math.sin(rotation.z) * Math.abs(Math.cos(rotation.x)),
84 | Math.cos(rotation.z) * Math.abs(Math.cos(rotation.x)),
85 | Math.sin(rotation.x),
86 | ),
87 | );
88 | return new Vector3(normalized.x, normalized.y, normalized.z);
89 | }
90 |
91 | // public get RightVector() : Vector3 {
92 | // return Matrix.Right;
93 | // }
94 | // public Vector3 GetOffsetPosition(Vector3 offset) {
95 | // return Vector3.TransformCoordinate(offset, Matrix);
96 | // }
97 |
98 | // public Vector3 GetPositionOffset(Vector3 worldCoords) {
99 | // return Vector3.TransformCoordinate(worldCoords, Matrix.Invert(Matrix));
100 | // }
101 |
102 | public get FieldOfView(): number {
103 | return GetCamFov(this.handle);
104 | }
105 |
106 | public set FieldOfView(fieldOfView: number) {
107 | SetCamFov(this.handle, fieldOfView);
108 | }
109 |
110 | public get NearClip(): number {
111 | return GetCamNearClip(this.handle);
112 | }
113 |
114 | public set NearClip(nearClip: number) {
115 | SetCamNearClip(this.handle, nearClip);
116 | }
117 |
118 | public get FarClip(): number {
119 | return GetCamFarClip(this.handle);
120 | }
121 |
122 | public set FarClip(farClip: number) {
123 | SetCamFarClip(this.handle, farClip);
124 | }
125 |
126 | public set NearDepthOfField(nearDepthOfField: number) {
127 | SetCamNearDof(this.handle, nearDepthOfField);
128 | }
129 |
130 | public get FarDepthOfField(): number {
131 | return GetCamFarDof(this.handle);
132 | }
133 |
134 | public set FarDepthOfField(farDepthOfField: number) {
135 | SetCamFarDof(this.handle, farDepthOfField);
136 | }
137 |
138 | public set DepthOfFieldStrength(strength: number) {
139 | SetCamDofStrength(this.handle, strength);
140 | }
141 |
142 | public set MotionBlurStrength(strength: number) {
143 | SetCamMotionBlurStrength(this.handle, strength);
144 | }
145 |
146 | public shake(shakeType: CameraShake, amplitude: number): void {
147 | ShakeCam(this.handle, this.shakeNames[Number(shakeType)], amplitude);
148 | }
149 |
150 | public stopShaking(): void {
151 | StopCamShaking(this.handle, true);
152 | }
153 |
154 | public get IsShaking(): boolean {
155 | return !!IsCamShaking(this.handle);
156 | }
157 |
158 | public set ShakeAmplitude(amplitude: number) {
159 | SetCamShakeAmplitude(this.handle, amplitude);
160 | }
161 |
162 | public pointAt(target: Entity | PedBone | Vector3, offset: Vector3 = new Vector3(0, 0, 0)): void {
163 | if (target instanceof Entity) {
164 | PointCamAtEntity(this.handle, target.Handle, offset.x, offset.y, offset.z, true);
165 | } else if (target instanceof PedBone) {
166 | PointCamAtPedBone(
167 | this.handle,
168 | target.Owner.Handle,
169 | target.Index,
170 | offset.x,
171 | offset.y,
172 | offset.z,
173 | true,
174 | );
175 | } else {
176 | PointCamAtCoord(this.handle, target.x, target.y, target.z);
177 | }
178 | }
179 |
180 | public stopPointing(): void {
181 | StopCamPointing(this.handle);
182 | }
183 |
184 | public interpTo(
185 | to: Camera,
186 | duration: number,
187 | easePosition: boolean,
188 | easeRotation: boolean,
189 | ): void {
190 | SetCamActiveWithInterp(
191 | to.handle,
192 | this.handle,
193 | duration,
194 | Number(easePosition),
195 | Number(easeRotation),
196 | );
197 | }
198 |
199 | public get IsInterpolating(): boolean {
200 | return !!IsCamInterpolating(this.handle);
201 | }
202 |
203 | public attachTo(object: Entity | PedBone, offset: Vector3): void {
204 | if (object instanceof Entity) {
205 | AttachCamToEntity(this.handle, object.Handle, offset.x, offset.y, offset.z, true);
206 | } else if (object instanceof PedBone) {
207 | AttachCamToPedBone(
208 | this.handle,
209 | object.Owner.Handle,
210 | object.Index,
211 | offset.x,
212 | offset.y,
213 | offset.z,
214 | true,
215 | );
216 | }
217 | }
218 |
219 | public detach(): void {
220 | DetachCam(this.handle);
221 | }
222 |
223 | public delete(): void {
224 | DestroyCam(this.handle, false);
225 | }
226 |
227 | public exists(): boolean {
228 | return !!DoesCamExist(this.handle);
229 | }
230 | }
231 |
--------------------------------------------------------------------------------
/src/Checkpoint.ts:
--------------------------------------------------------------------------------
1 | import { CheckpointIcon } from './enums';
2 | import { Vector3 } from './utils';
3 |
4 | export class Checkpoint {
5 | private handle: number;
6 | private position: Vector3;
7 | private targetPosition: Vector3;
8 | private icon: CheckpointIcon;
9 | private radius: number;
10 |
11 | constructor(handle: number) {
12 | this.handle = handle;
13 | }
14 |
15 | public get Position(): Vector3 {
16 | return this.position;
17 | }
18 |
19 | public set Position(position: Vector3) {
20 | this.position = position;
21 | }
22 |
23 | public get TargetPosition(): Vector3 {
24 | return this.targetPosition;
25 | }
26 |
27 | public set TargetPosition(targetPosition: Vector3) {
28 | this.targetPosition = targetPosition;
29 | }
30 |
31 | public get Icon(): CheckpointIcon {
32 | return this.icon;
33 | }
34 |
35 | public set Icon(icon: CheckpointIcon) {
36 | this.icon = icon;
37 | }
38 |
39 | // TODO
40 | // public get CustomIcon(): CheckpointIcon {
41 | // return this.icon;
42 | // }
43 |
44 | // public set CustomIcon(icon: CheckpointIcon) {
45 | // this.icon = icon;
46 | // }
47 |
48 | public get Radius(): number {
49 | return this.radius;
50 | }
51 |
52 | public set Radius(radius: number) {
53 | this.radius = radius;
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/src/GameplayCamera.ts:
--------------------------------------------------------------------------------
1 | import { Vector3 } from './utils';
2 |
3 | /**
4 | * The current rendering gameplay camera
5 | */
6 | export abstract class GameplayCamera {
7 | /**
8 | * Get the world position of gameplay camera.
9 | */
10 | public static get Position(): Vector3 {
11 | const coords = GetGameplayCamCoords();
12 | return new Vector3(coords[0], coords[1], coords[2]);
13 | }
14 |
15 | /**
16 | * Get the rotation of gameplay camera.
17 | */
18 | public static get Rotation(): Vector3 {
19 | const rot = GetGameplayCamRot(2);
20 | return new Vector3(rot[0], rot[1], rot[2]);
21 | }
22 |
23 | /**
24 | * Get the forward vector of gameplay camera.
25 | */
26 | public static get ForwardVector(): Vector3 {
27 | const rotation = Vector3.multiply(this.Rotation, Math.PI / 180);
28 | const normalized = Vector3.normalize(
29 | new Vector3(
30 | -Math.sin(rotation.z) * Math.abs(Math.cos(rotation.x)),
31 | Math.cos(rotation.z) * Math.abs(Math.cos(rotation.x)),
32 | Math.sin(rotation.x),
33 | ),
34 | );
35 | return new Vector3(normalized.x, normalized.y, normalized.z);
36 | }
37 |
38 | /**
39 | * Get the pitch of the gameplay camera relative to player.
40 | */
41 | public static get RelativePitch(): number {
42 | return GetGameplayCamRelativePitch();
43 | }
44 |
45 | /**
46 | * Set gameplay camera pitch relative to player.
47 | */
48 | public static set RelativePitch(pitch: number) {
49 | SetGameplayCamRelativePitch(pitch, 1);
50 | }
51 |
52 | /**
53 | * Get heading of gameplay camera.
54 | */
55 | public static get RelativeHeading(): number {
56 | return GetGameplayCamRelativeHeading();
57 | }
58 |
59 | /**
60 | * Get heading of gameplay camera.
61 | */
62 | public static set RelativeHeading(heading: number) {
63 | SetGameplayCamRelativeHeading(heading);
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/src/Model.ts:
--------------------------------------------------------------------------------
1 | import { Game } from './Game';
2 | import { VehicleHash } from './hashes';
3 | import { Vector3 } from './utils';
4 |
5 | /**
6 | * Class to create and manage entity models.
7 | */
8 | export class Model {
9 | /**
10 | * Hash of this model.
11 | */
12 | private hash: number;
13 |
14 | /**
15 | * Creates a model object based on the hash key or model string.
16 | *
17 | * @param hash A number or string of the model's hash. Example: "mp_m_freemode_01"
18 | */
19 | constructor(hash: number | string) {
20 | if (typeof hash === 'string') {
21 | this.hash = Game.generateHash(hash);
22 | } else {
23 | this.hash = hash;
24 | }
25 | }
26 |
27 | /**
28 | * Gets the hash of the model.
29 | *
30 | * @returns The hash key.
31 | */
32 | public get Hash(): number {
33 | return this.hash;
34 | }
35 |
36 | /**
37 | * Gets if the model is valid or not.
38 | *
39 | * @returns Whether this model is valid.
40 | */
41 | public get IsValid(): boolean {
42 | return !!IsModelValid(this.hash);
43 | }
44 |
45 | /**
46 | * Gets if the model is in cd image or not.
47 | *
48 | * @returns Whether this model is in cd image.
49 | */
50 | public get IsInCdImage(): boolean {
51 | return !!IsModelInCdimage(this.hash);
52 | }
53 |
54 | /**
55 | * Gets if the model is loaded or not.
56 | *
57 | * @returns Whether this model is loaded.
58 | */
59 | public get IsLoaded(): boolean {
60 | return !!HasModelLoaded(this.hash);
61 | }
62 |
63 | /**
64 | * Gets if the model collision is loaded or not.
65 | *
66 | * @returns Whether this model collision is loaded.
67 | */
68 | public get IsCollisionLoaded(): boolean {
69 | return !!HasCollisionForModelLoaded(this.hash);
70 | }
71 |
72 | /**
73 | * Gets if the model is a bicycle or not.
74 | *
75 | * @returns Whether this model is a bicycle.
76 | */
77 | public get IsBicycle(): boolean {
78 | return !!IsThisModelABicycle(this.hash);
79 | }
80 |
81 | /**
82 | * Gets if the model is a motorbike or not.
83 | *
84 | * @returns Whether this model is a motorbike.
85 | */
86 | public get IsBike(): boolean {
87 | return !!IsThisModelABike(this.hash);
88 | }
89 |
90 | /**
91 | * Gets if the model is a boat or not.
92 | *
93 | * @returns Whether this model is a boat.
94 | */
95 | public get IsBoat(): boolean {
96 | return !!IsThisModelABoat(this.hash);
97 | }
98 |
99 | /**
100 | * Gets if the model is a car or not.
101 | *
102 | * @returns Whether this model is a car.
103 | */
104 | public get IsCar(): boolean {
105 | return !!IsThisModelACar(this.hash);
106 | }
107 |
108 | /**
109 | * Gets if the model is a cargobob or not.
110 | *
111 | * @returns Whether this model is a cargobob.
112 | */
113 | public get IsCargobob(): boolean {
114 | return (
115 | this.hash === VehicleHash.Cargobob ||
116 | this.hash === VehicleHash.Cargobob2 ||
117 | this.hash === VehicleHash.Cargobob3 ||
118 | this.hash === VehicleHash.Cargobob4
119 | );
120 | }
121 |
122 | /**
123 | * Gets if the model is a helicopter or not.
124 | *
125 | * @returns Whether this model is a helicopter.
126 | */
127 | public get IsHelicopter(): boolean {
128 | return !!IsThisModelAHeli(this.hash);
129 | }
130 |
131 | /**
132 | * Gets if the model is a Ped or not.
133 | *
134 | * @returns Whether this model is a Ped.
135 | */
136 | public get IsPed(): boolean {
137 | return !!IsModelAPed(this.hash);
138 | }
139 |
140 | /**
141 | * Gets if the model is a plane or not.
142 | *
143 | * @returns Whether this model is a plane.
144 | */
145 | public get IsPlane(): boolean {
146 | return !!IsThisModelAPlane(this.hash);
147 | }
148 |
149 | /**
150 | * Gets if the model is a prop or not.
151 | *
152 | * @returns Whether this model is a prop.
153 | */
154 | public get IsProp(): boolean {
155 | return this.IsValid && !this.IsPed && !this.IsVehicle && !IsWeaponValid(this.hash);
156 | }
157 |
158 | /**
159 | * Gets if the model is a quadbike or not.
160 | *
161 | * @returns Whether this model is a quadbike.
162 | */
163 | public get IsQuadbike(): boolean {
164 | return !!IsThisModelAQuadbike(this.hash);
165 | }
166 |
167 | /**
168 | * Gets if the model is a train or not.
169 | *
170 | * @returns Whether this model is a train.
171 | */
172 | public get IsTrain(): boolean {
173 | return !!IsThisModelATrain(this.hash);
174 | }
175 |
176 | /**
177 | * Gets if the model is a Vehicle or not.
178 | *
179 | * @returns Whether this model is a Vehicle.
180 | */
181 | public get IsVehicle(): boolean {
182 | return !!IsModelAVehicle(this.hash);
183 | }
184 |
185 | /**
186 | * Gets the model dimensions.
187 | *
188 | * @returns This model dimensions.
189 | */
190 | public get Dimensions(): Vector3 {
191 | const [min, max] = GetModelDimensions(this.hash);
192 | const right = new Vector3(min[0], min[1], min[2]);
193 | const left = new Vector3(max[0], max[1], max[2]);
194 | return Vector3.subtract(left, right);
195 | }
196 |
197 | /**
198 | * Request and load the model with a specified timeout. Advised timeout - 1000.
199 | *
200 | * @param timeout Maximum allowed time for model to load.
201 | */
202 | public request(timeout: number): Promise {
203 | return new Promise(resolve => {
204 | if (!this.IsInCdImage && !this.IsValid && !IsWeaponValid(this.hash)) {
205 | resolve(false);
206 | }
207 | RequestModel(this.hash);
208 | const start = GetGameTimer();
209 | const interval = setInterval(() => {
210 | if (this.IsLoaded || GetGameTimer() - start >= timeout) {
211 | clearInterval(interval);
212 | this.markAsNoLongerNeeded();
213 | resolve(this.IsLoaded);
214 | }
215 | }, 0);
216 | });
217 | }
218 |
219 | /**
220 | * Sets the model as no longer needed allowing the game engine to free memory.
221 | */
222 | public markAsNoLongerNeeded(): void {
223 | SetModelAsNoLongerNeeded(this.hash);
224 | }
225 | }
226 |
--------------------------------------------------------------------------------
/src/ParticleEffect.ts:
--------------------------------------------------------------------------------
1 | import { ParticleEffectAsset } from './';
2 | import { InvertAxis } from './enums';
3 | import { Color, Vector3 } from './utils';
4 |
5 | // TODO: Lots of Matrix stuff through memory access
6 | /**
7 | * UNFINISHED! Class to manage particle effects.
8 | */
9 | export abstract class ParticleEffect {
10 | protected readonly asset: ParticleEffectAsset;
11 | protected readonly effectName: string;
12 | protected offset: Vector3;
13 | protected rotation: Vector3;
14 | protected color: Color;
15 | protected scale: number;
16 | protected range: number;
17 | protected invertAxis: InvertAxis;
18 | private handle: number;
19 |
20 | /**
21 | * Creates a particle effect.
22 | *
23 | * @param asset Particle effect asset.
24 | * @param effectName Name of effect.
25 | */
26 | constructor(asset: ParticleEffectAsset, effectName: string) {
27 | this.handle = -1;
28 | this.asset = asset;
29 | this.effectName = effectName;
30 | }
31 |
32 | /**
33 | * Get the particle effect handle.
34 | */
35 | public get Handle(): number {
36 | return this.handle;
37 | }
38 |
39 | /**
40 | * Get whether particle effect is currently active.
41 | */
42 | public get IsActive(): boolean {
43 | return this.Handle !== -1 && !!DoesParticleFxLoopedExist(this.Handle);
44 | }
45 |
46 | public abstract start(): boolean;
47 |
48 | /**
49 | * Stop a particle effect.
50 | */
51 | public stop(): void {
52 | if (this.IsActive) {
53 | RemoveParticleFx(this.Handle, false);
54 | }
55 | this.handle = -1;
56 | }
57 |
58 | /**
59 | * Get the rotation of the particle effect.
60 | */
61 | public get Rotation(): Vector3 {
62 | return this.rotation;
63 | }
64 |
65 | /**
66 | * Set the rotation of the particle effect.
67 | */
68 | public set Rotation(rotation: Vector3) {
69 | this.rotation = rotation;
70 | if (this.IsActive) {
71 | const off = this.offset; // TODO Matrix stuff to access from memory
72 | SetParticleFxLoopedOffsets(
73 | this.Handle,
74 | off.x,
75 | off.y,
76 | off.z,
77 | rotation.x,
78 | rotation.y,
79 | rotation.z,
80 | );
81 | }
82 | }
83 |
84 | /**
85 | * Get the range of the particle effect.
86 | */
87 | public get Range(): number {
88 | return this.range;
89 | }
90 |
91 | /**
92 | * Set the range of the particle effect.
93 | */
94 | public set Range(range: number) {
95 | this.range = range;
96 | SetParticleFxLoopedRange(this.Handle, range);
97 | }
98 |
99 | /**
100 | * Get the invert axis flag of the particle effect.
101 | */
102 | public get InvertAxis(): InvertAxis {
103 | return this.invertAxis;
104 | }
105 |
106 | /**
107 | * Set the inverted axis of the particle effect.
108 | */
109 | public set InvertAxis(invertAxis: InvertAxis) {
110 | this.invertAxis = invertAxis;
111 | if (this.IsActive) {
112 | this.stop();
113 | this.start();
114 | }
115 | }
116 |
117 | /**
118 | * Set a paramaeter of a particle effect.
119 | *
120 | * @param parameterName Name of parameter.
121 | * @param value Value of parameter.
122 | */
123 | public setParameter(parameterName: string, value: number): void {
124 | if (this.IsActive) {
125 | SetParticleFxLoopedEvolution(this.Handle, parameterName, value, false);
126 | }
127 | }
128 |
129 | /**
130 | * Get the name of the particle effect asset. Same as ParticleEffect.AssetName.
131 | */
132 | public get AssetName(): string {
133 | return this.asset.AssetName;
134 | }
135 |
136 | /**
137 | * Get the name of the particle effect.
138 | */
139 | public get EffectName(): string {
140 | return this.effectName;
141 | }
142 |
143 | /**
144 | * Return the particle effect as string. `AssetName`\\`EffectName`.
145 | */
146 | public toString(): string {
147 | return `${this.AssetName}\\${this.EffectName}`;
148 | }
149 | }
150 |
--------------------------------------------------------------------------------
/src/ParticleEffectAsset.ts:
--------------------------------------------------------------------------------
1 | import { InvertAxis, InvertAxisFlags } from './enums';
2 | import { Entity } from './models/';
3 | import { Vector3 } from './utils';
4 |
5 | /**
6 | * UNFINISHED! Class that represents a particle effect asset.
7 | */
8 | export class ParticleEffectAsset {
9 | /**
10 | * Returns the name of the asset. Same as AssetName.
11 | */
12 | public get Asset(): string {
13 | return this.assetName;
14 | }
15 |
16 | private readonly assetName: string;
17 |
18 | constructor(assetName: string) {
19 | this.assetName = assetName;
20 | }
21 |
22 | /**
23 | * Get the name of the particle effect.
24 | */
25 | public get AssetName(): string {
26 | return this.assetName;
27 | }
28 |
29 | /**
30 | * Get whether the particle effect has loaded into game memory.
31 | */
32 | public get IsLoaded(): boolean {
33 | return !!HasNamedPtfxAssetLoaded(this.assetName);
34 | }
35 |
36 | /**
37 | * Start a particle effect at a world position.
38 | *
39 | * @param effectName Name of effect.
40 | * @param entity Entity to use effect on.
41 | * @param off Offset from entity position.
42 | * @param rot Rotation from entity position.
43 | * @param scale Size of the effect.
44 | * @param invertAxis Which axis to invert (default none).
45 | */
46 | public startNonLoopedAtCoord(
47 | effectName: string,
48 | pos: Vector3,
49 | rot: Vector3 = new Vector3(0, 0, 0),
50 | scale = 1.0,
51 | invertAxis: InvertAxis = { flags: InvertAxisFlags.None },
52 | ): boolean {
53 | if (!this.setNextCall()) {
54 | return false;
55 | }
56 | const invertAxisFlags = invertAxis.flags;
57 | SetPtfxAssetNextCall(this.assetName);
58 | return (
59 | StartParticleFxLoopedAtCoord(
60 | effectName,
61 | pos.x,
62 | pos.y,
63 | pos.z,
64 | rot.x,
65 | rot.y,
66 | rot.z,
67 | scale,
68 | !!(invertAxisFlags & InvertAxisFlags.X),
69 | !!(invertAxisFlags & InvertAxisFlags.Y),
70 | !!(invertAxisFlags & InvertAxisFlags.Z),
71 | false,
72 | ) > 0
73 | );
74 | }
75 |
76 | /**
77 | * Start a particle effect on an entity
78 | *
79 | * @param effectName Name of effect.
80 | * @param entity Entity to use effect on.
81 | * @param off Offset from entity position.
82 | * @param rot Rotation from entity position.
83 | * @param scale Size of the effect.
84 | * @param invertAxis Which axis to invert (default none).
85 | */
86 | public startNonLoopedOnEntity(
87 | effectName: string,
88 | entity: Entity,
89 | off: Vector3 = new Vector3(0, 0, 0),
90 | rot: Vector3 = new Vector3(0, 0, 0),
91 | scale = 1.0,
92 | invertAxis: InvertAxis = { flags: InvertAxisFlags.None },
93 | ): boolean {
94 | if (!this.setNextCall()) {
95 | return false;
96 | }
97 | const invertAxisFlags = invertAxis.flags;
98 | SetPtfxAssetNextCall(this.assetName);
99 | return !!StartParticleFxLoopedOnEntity(
100 | effectName,
101 | entity.Handle,
102 | off.x,
103 | off.y,
104 | off.z,
105 | rot.x,
106 | rot.y,
107 | rot.z,
108 | scale,
109 | !!(invertAxisFlags & InvertAxisFlags.X),
110 | !!(invertAxisFlags & InvertAxisFlags.Y),
111 | !!(invertAxisFlags & InvertAxisFlags.Z),
112 | );
113 | }
114 |
115 | /**
116 | * Load a particle effect into the game memory.
117 | *
118 | * @param timeout Max time to load Particle Effect
119 | */
120 | public request(timeout: number): Promise {
121 | return new Promise(resolve => {
122 | if (!this.IsLoaded) {
123 | RequestNamedPtfxAsset(this.assetName);
124 | const start = GetGameTimer();
125 | const interval = setInterval(() => {
126 | if (this.IsLoaded || GetGameTimer() - start >= timeout) {
127 | clearInterval(interval);
128 | resolve(this.IsLoaded);
129 | }
130 | }, 0);
131 | } else {
132 | resolve(this.IsLoaded);
133 | }
134 | });
135 | }
136 |
137 | /**
138 | * Allow game engine to safely unload particle effect model from memory.
139 | */
140 | public markAsNoLongerNeeded(): void {
141 | RemoveNamedPtfxAsset(this.assetName);
142 | }
143 |
144 | public toString(): string {
145 | return this.assetName;
146 | }
147 |
148 | private setNextCall(): boolean {
149 | if (!this.IsLoaded) {
150 | RequestNamedPtfxAsset(this.assetName);
151 | } else {
152 | SetPtfxAssetNextCall(this.assetName);
153 | return true;
154 | }
155 | return false;
156 | }
157 | }
158 |
--------------------------------------------------------------------------------
/src/Raycast.ts:
--------------------------------------------------------------------------------
1 | import { Game } from './Game';
2 | import { MaterialHash } from './hashes';
3 | import { Entity } from './models';
4 | import { Vector3 } from './utils';
5 |
6 | /**
7 | * Class that represents the result of a raycast.
8 | */
9 | export class RaycastResult {
10 | /**
11 | * Return the entity that was hit.
12 | */
13 | public get HitEntity(): Entity {
14 | return this.entityHandleArg;
15 | }
16 |
17 | /**
18 | * Get the position of the entity that was hit.
19 | */
20 | public get HitPosition(): Vector3 {
21 | return this.hitPositionArg;
22 | }
23 |
24 | /**
25 | * Return the vector perpendicular to the tangent plane.
26 | */
27 | public get SurfaceNormal(): Vector3 {
28 | return this.surfaceNormalArg;
29 | }
30 |
31 | /**
32 | * Whether we hit anything.
33 | */
34 | public get DidHit(): boolean {
35 | return this.hitSomethingArg;
36 | }
37 |
38 | /**
39 | * Whether the entity hit exists.
40 | */
41 | public get DidHitEntity(): boolean {
42 | return this.entityHandleArg.Handle !== 0;
43 | }
44 |
45 | /**
46 | * Material type that was hit.
47 | */
48 | public get Material(): MaterialHash {
49 | return this.materialArg;
50 | }
51 |
52 | /**
53 | * Raycast result's handle.
54 | */
55 | public get Result(): number {
56 | return this.result;
57 | }
58 |
59 | private handle: number;
60 | private hitPositionArg: Vector3;
61 | private hitSomethingArg: boolean;
62 | private entityHandleArg: Entity;
63 | private surfaceNormalArg: Vector3;
64 | private materialArg: MaterialHash;
65 | private result: number;
66 |
67 | /**
68 | * Create a RaycastResult object that gets the results from a StartShapeTestRay()
69 | *
70 | * @param handle The handle returned from StartShapeTestRay()
71 | */
72 | constructor(handle: number) {
73 | this.handle = handle;
74 | this.hitPositionArg = new Vector3(0, 0, 0);
75 | this.hitSomethingArg = false;
76 | this.entityHandleArg = null;
77 | this.surfaceNormalArg = new Vector3(0, 0, 0);
78 | this.materialArg = 0;
79 |
80 | const results = GetShapeTestResultEx(this.handle);
81 | this.hitSomethingArg = !!results[1];
82 | this.hitPositionArg = new Vector3(results[2][0], results[2][1], results[2][2]);
83 | this.surfaceNormalArg = new Vector3(results[3][0], results[3][1], results[3][2]);
84 | this.materialArg = results[4];
85 | this.entityHandleArg = Game.entityFromHandle(results[5]);
86 |
87 | this.result = results[0];
88 | }
89 | }
90 |
--------------------------------------------------------------------------------
/src/RelationshipGroup.ts:
--------------------------------------------------------------------------------
1 | import { Relationship } from './enums';
2 |
3 | /**
4 | * Class to create and manage a relationship group. Useful to manage behavior between Peds.
5 | */
6 | export class RelationshipGroup {
7 | /**
8 | * The hash of the relationship group
9 | */
10 | private hash: number;
11 |
12 | /**
13 | * Create a relationship group. Optionally pass a group hash.
14 | *
15 | * @param name Name of the relationship group.
16 | * @param groupHash Optional custom group hash (default: 0).
17 | */
18 | constructor(name: string, groupHash?: number) {
19 | AddRelationshipGroup(name, groupHash ? groupHash : 0);
20 |
21 | this.hash = groupHash ? groupHash : 0;
22 | }
23 |
24 | /**
25 | * Gets the hash of the relationship group.
26 | *
27 | * @returns The hash of this object.
28 | */
29 | public get Hash(): number {
30 | return this.hash;
31 | }
32 |
33 | /**
34 | * Get the relationship between two relationship groups.
35 | *
36 | * @param targetGroup The other relationship group.
37 | * @returns The relationship
38 | */
39 | public getRelationshipBetweenGroups(targetGroup: RelationshipGroup): Relationship {
40 | return GetRelationshipBetweenGroups(this.Hash, targetGroup.Hash);
41 | }
42 |
43 | /**
44 | * Set the relationship group between this relationship group and another one.
45 | *
46 | * @param targetGroup The other relationship group.
47 | * @param relationship The desired relationship.
48 | * @param biDirectionally If target group should have same relationship towards this.
49 | */
50 | public setRelationshipBetweenGroups(
51 | targetGroup: RelationshipGroup,
52 | relationship: Relationship,
53 | biDirectionally = false,
54 | ): void {
55 | SetRelationshipBetweenGroups(Number(relationship), this.Hash, targetGroup.Hash);
56 |
57 | if (biDirectionally) {
58 | SetRelationshipBetweenGroups(Number(relationship), targetGroup.Hash, this.Hash);
59 | }
60 | }
61 |
62 | /**
63 | * Clear the relationship between this relationship group and another.
64 | *
65 | * @param targetGroup The other relationship group.
66 | * @param relationship The desired relationship to clear.
67 | * @param biDirectionally Whether the target group should also clear the relationship.
68 | */
69 | public clearRelationshipBetweenGroups(
70 | targetGroup: RelationshipGroup,
71 | relationship: Relationship,
72 | biDirectionally = false,
73 | ): void {
74 | ClearRelationshipBetweenGroups(Number(relationship), this.Hash, targetGroup.Hash);
75 |
76 | if (biDirectionally) {
77 | ClearRelationshipBetweenGroups(Number(relationship), targetGroup.Hash, this.Hash);
78 | }
79 | }
80 |
81 | /**
82 | * Remove this relationship group from the game. This will not delete this object.
83 | */
84 | public remove(): void {
85 | RemoveRelationshipGroup(this.Hash);
86 | }
87 | }
88 |
--------------------------------------------------------------------------------
/src/Rope.ts:
--------------------------------------------------------------------------------
1 | import { Entity } from './models';
2 | import { Vector3 } from './utils';
3 |
4 | /**
5 | * Class to manage invisible ropes between entities.
6 | */
7 | export class Rope {
8 | /**
9 | * Id of rope entity.
10 | */
11 | private readonly handle: number;
12 |
13 | /**
14 | * Create a rope object based on an existing rope in the world.
15 | *
16 | * @param handle entity Id of rope.
17 | */
18 | constructor(handle: number) {
19 | this.handle = handle;
20 | }
21 |
22 | /**
23 | * Get the length of the rope.
24 | *
25 | * @returns The rope length.
26 | */
27 | public get Length(): number {
28 | return GetRopeLength(this.handle);
29 | }
30 |
31 | /**
32 | * Sets the length of the rope.
33 | *
34 | * @param length Desired new length of rope.
35 | */
36 | public set Length(length: number) {
37 | RopeForceLength(this.handle, length);
38 | }
39 |
40 | /**
41 | * Get the number of vertices on the rope.
42 | *
43 | * @returns Returns the number of vertices.
44 | */
45 | public get VertexCount(): number {
46 | return GetRopeVertexCount(this.handle);
47 | }
48 |
49 | /**
50 | * Resets the length of the rope to it's length upon object creation or a length of 1.
51 | *
52 | * @param reset Whether to reset the length to it's original length or 1.
53 | */
54 | public resetLength(reset: boolean): void {
55 | RopeResetLength(this.handle, reset ? 1 : this.Length);
56 | }
57 |
58 | /**
59 | * Activates world physics on the rope object.
60 | */
61 | public activatePhysics(): void {
62 | ActivatePhysics(this.handle);
63 | }
64 |
65 | /**
66 | * Attach the rope to an entity.
67 | *
68 | * @param entity Entity to attach the rope to.
69 | * @param position Location where the rope is to be attached.
70 | */
71 | public attachEntity(entity: Entity, position: Vector3): void {
72 | AttachRopeToEntity(this.handle, entity.Handle, position.x, position.y, position.z, false);
73 | }
74 |
75 | /**
76 | * Attach the rope between two entities at given locations on the entities.
77 | *
78 | * @param entityOne The first entity to attach to.
79 | * @param positionOne Where on the first entity to attach the rope to.
80 | * @param entityTwo The second entity to attach to.
81 | * @param positionTwo Where on the second entity to attach the rope to.
82 | * @param length The desired length of the rope between the two entities.
83 | */
84 | public attachEntities(
85 | entityOne: Entity,
86 | positionOne: Vector3,
87 | entityTwo: Entity,
88 | positionTwo: Vector3,
89 | length: number,
90 | ): void {
91 | AttachEntitiesToRope(
92 | this.handle,
93 | entityOne.Handle,
94 | entityTwo.Handle,
95 | positionOne.x,
96 | positionOne.y,
97 | positionOne.z,
98 | positionTwo.x,
99 | positionTwo.y,
100 | positionTwo.z,
101 | length,
102 | false,
103 | false,
104 | null,
105 | null,
106 | );
107 | }
108 |
109 | /**
110 | * Detach the rope from an entity.
111 | *
112 | * @param entity Entity to detach the rope from.
113 | */
114 | public detachEntity(entity: Entity): void {
115 | DetachRopeFromEntity(this.handle, entity.Handle);
116 | }
117 |
118 | /**
119 | * Pin a vertex of the rope to a certain location.
120 | *
121 | * @param vertex Vertex to pin.
122 | * @param position Location to pin the vertex to.
123 | */
124 | public pinVertex(vertex: number, position: Vector3): void {
125 | PinRopeVertex(this.handle, vertex, position.x, position.y, position.z);
126 | }
127 |
128 | /**
129 | * Unpin a specified vertex from it's current pinned location (if any).
130 | *
131 | * @param vertex Vertex to unpin.
132 | */
133 | public unpinVertex(vertex: number): void {
134 | UnpinRopeVertex(this.handle, vertex);
135 | }
136 |
137 | /**
138 | * Return the world location of a specified vertex on the rope.
139 | *
140 | * @param vertex Vertex to get location from.
141 | * @returns The vector location of the vertex.
142 | */
143 | public getVertexCoord(vertex: number): Vector3 {
144 | const coords = GetRopeVertexCoord(this.handle, vertex);
145 | return new Vector3(coords[0], coords[1], coords[2]);
146 | }
147 |
148 | /**
149 | * Delete the rope from the world. This does not delete the rope object.
150 | */
151 | public delete(): void {
152 | DeleteRope(this.handle);
153 | }
154 |
155 | /**
156 | * Check if the rope still exists in the world based on it's handle.
157 | *
158 | * @returns Whether the rope exists or not.
159 | */
160 | public exists(): boolean {
161 | return !!DoesRopeExist(this.handle);
162 | }
163 | }
164 |
--------------------------------------------------------------------------------
/src/enums/Alignment.ts:
--------------------------------------------------------------------------------
1 | export enum Alignment {
2 | Left,
3 | Centered,
4 | Right,
5 | }
6 |
--------------------------------------------------------------------------------
/src/enums/AudioFlag.ts:
--------------------------------------------------------------------------------
1 | export enum AudioFlag {
2 | ActivateSwitchWheelAudio,
3 | AllowCutsceneOverScreenFade,
4 | AllowForceRadioAfterRetune,
5 | AllowPainAndAmbientSpeechToPlayDuringCutscene,
6 | AllowPlayerAIOnMission,
7 | AllowPoliceScannerWhenPlayerHasNoControl,
8 | AllowRadioDuringSwitch,
9 | AllowRadioOverScreenFade,
10 | AllowScoreAndRadio,
11 | AllowScriptedSpeechInSlowMo,
12 | AvoidMissionCompleteDelay,
13 | DisableAbortConversationForDeathAndInjury,
14 | DisableAbortConversationForRagdoll,
15 | DisableBarks,
16 | DisableFlightMusic,
17 | DisableReplayScriptStreamRecording,
18 | EnableHeadsetBeep,
19 | ForceConversationInterrupt,
20 | ForceSeamlessRadioSwitch,
21 | ForceSniperAudio,
22 | FrontendRadioDisabled,
23 | HoldMissionCompleteWhenPrepared,
24 | IsDirectorModeActive,
25 | IsPlayerOnMissionForSpeech,
26 | ListenerReverbDisabled,
27 | LoadMPData,
28 | MobileRadioInGame,
29 | OnlyAllowScriptTriggerPoliceScanner,
30 | PlayMenuMusic,
31 | PoliceScannerDisabled,
32 | ScriptedConvListenerMaySpeak,
33 | SpeechDucksScore,
34 | SuppressPlayerScubaBreathing,
35 | WantedMusicDisabled,
36 | WantedMusicOnMission,
37 | }
38 |
--------------------------------------------------------------------------------
/src/enums/BadgeStyle.ts:
--------------------------------------------------------------------------------
1 | export enum BadgeStyle {
2 | None,
3 | Lock,
4 | Star,
5 | Warning,
6 | Crown,
7 | MedalBronze,
8 | MedalGold,
9 | MedalSilver,
10 | Cash,
11 | Coke,
12 | Heroin,
13 | Meth,
14 | Weed,
15 | Ammo,
16 | Armor,
17 | Barber,
18 | Clothing,
19 | Franklin,
20 | Bike,
21 | Car,
22 | Gun,
23 | HealthHeart,
24 | MakeupBrush,
25 | Mask,
26 | Michael,
27 | Tattoo,
28 | Tick,
29 | Trevor,
30 | Female,
31 | Male,
32 | LockArena,
33 | Adversary,
34 | BaseJumping,
35 | Briefcase,
36 | MissionStar,
37 | Deathmatch,
38 | Castle,
39 | Trophy,
40 | RaceFlag,
41 | RaceFlagPlane,
42 | RaceFlagBicycle,
43 | RaceFlagPerson,
44 | RaceFlagCar,
45 | RaceFlagBoatAnchor,
46 | Rockstar,
47 | Stunt,
48 | StuntPremium,
49 | RaceFlagStuntJump,
50 | Shield,
51 | TeamDeathmatch,
52 | VehicleDeathmatch,
53 | MpAmmoPickup,
54 | MpAmmo,
55 | MpCash,
56 | MpRp,
57 | MpSpectating,
58 | Sale,
59 | GlobeWhite,
60 | GlobeRed,
61 | GlobeBlue,
62 | GlobeYellow,
63 | GlobeGreen,
64 | GlobeOrange,
65 | InvArmWrestling,
66 | InvBasejump,
67 | InvMission,
68 | InvDarts,
69 | InvDeathmatch,
70 | InvDrug,
71 | InvCastle,
72 | InvGolf,
73 | InvBike,
74 | InvBoat,
75 | InvAnchor,
76 | InvCar,
77 | InvDollar,
78 | InvCoke,
79 | InvKey,
80 | InvData,
81 | InvHeli,
82 | InvHeorin,
83 | InvKeycard,
84 | InvMeth,
85 | InvBriefcase,
86 | InvLink,
87 | InvPerson,
88 | InvPlane,
89 | InvPlane2,
90 | InvQuestionmark,
91 | InvRemote,
92 | InvSafe,
93 | InvSteerWheel,
94 | InvWeapon,
95 | InvWeed,
96 | InvRaceFlagPlane,
97 | InvRaceFlagBicycle,
98 | InvRaceFlagBoatAnchor,
99 | InvRaceFlagPerson,
100 | InvRaceFlagCar,
101 | InvRaceFlagHelmet,
102 | InvShootingRange,
103 | InvSurvival,
104 | InvTeamDeathmatch,
105 | InvTennis,
106 | InvVehicleDeathmatch,
107 | AudioMute,
108 | AudioInactive,
109 | AudioVol1,
110 | AudioVol2,
111 | AudioVol3,
112 | CountryUsa,
113 | CountryUk,
114 | CountrySweden,
115 | CountryKorea,
116 | CountryJapan,
117 | CountryItaly,
118 | CountryGermany,
119 | CountryFrance,
120 | BrandAlbany,
121 | BrandAnnis,
122 | BrandBanshee,
123 | BrandBenefactor,
124 | BrandBf,
125 | BrandBollokan,
126 | BrandBravado,
127 | BrandBrute,
128 | BrandBuckingham,
129 | BrandCanis,
130 | BrandChariot,
131 | BrandCheval,
132 | BrandClassique,
133 | BrandCoil,
134 | BrandDeclasse,
135 | BrandDewbauchee,
136 | BrandDilettante,
137 | BrandDinka,
138 | BrandDundreary,
139 | BrandEmporer,
140 | BrandEnus,
141 | BrandFathom,
142 | BrandGalivanter,
143 | BrandGrotti,
144 | BrandGrotti2,
145 | BrandHijak,
146 | BrandHvy,
147 | BrandImponte,
148 | BrandInvetero,
149 | BrandJacksheepe,
150 | BrandLcc,
151 | BrandJobuilt,
152 | BrandKarin,
153 | BrandLampadati,
154 | BrandMaibatsu,
155 | BrandMammoth,
156 | BrandMtl,
157 | BrandNagasaki,
158 | BrandObey,
159 | BrandOcelot,
160 | BrandOverflod,
161 | BrandPed,
162 | BrandPegassi,
163 | BrandPfister,
164 | BrandPrincipe,
165 | BrandProgen,
166 | BrandProgen2,
167 | BrandRune,
168 | BrandSchyster,
169 | BrandShitzu,
170 | BrandSpeedophile,
171 | BrandStanley,
172 | BrandTruffade,
173 | BrandUbermacht,
174 | BrandVapid,
175 | BrandVulcar,
176 | BrandWeeny,
177 | BrandWestern,
178 | BrandWesternmotorcycle,
179 | BrandWillard,
180 | BrandZirconium,
181 | Info,
182 | }
183 |
--------------------------------------------------------------------------------
/src/enums/Blip.ts:
--------------------------------------------------------------------------------
1 | export enum BlipColor {
2 | White,
3 | Red,
4 | Green,
5 | Blue,
6 | MichaelBlue = 42,
7 | FranklinGreen,
8 | TrevorOrange,
9 | Yellow = 66,
10 | }
11 |
12 | export enum BlipSprite {
13 | Standard = 1,
14 | BigBlip,
15 | PoliceOfficer,
16 | PoliceArea,
17 | Square,
18 | Player,
19 | North,
20 | Waypoint,
21 | BigCircle,
22 | BigCircleOutline,
23 | ArrowUpOutlined,
24 | ArrowDownOutlined,
25 | ArrowUp,
26 | ArrowDown,
27 | PoliceHelicopterAnimated,
28 | Jet,
29 | Number1,
30 | Number2,
31 | Number3,
32 | Number4,
33 | Number5,
34 | Number6,
35 | Number7,
36 | Number8,
37 | Number9,
38 | Number10,
39 | GTAOCrew,
40 | GTAOFriendly,
41 | Lift = 36,
42 | RaceFinish = 38,
43 | Safehouse = 40,
44 | PoliceOfficer2,
45 | PoliceCarDot,
46 | PoliceHelicopter,
47 | ChatBubble = 47,
48 | Garage2 = 50,
49 | Drugs,
50 | Store,
51 | PoliceCar = 56,
52 | PolicePlayer = 58,
53 | PoliceStation = 60,
54 | Hospital,
55 | Helicopter = 64,
56 | StrangersAndFreaks,
57 | ArmoredTruck,
58 | TowTruck = 68,
59 | Barber = 71,
60 | LosSantosCustoms,
61 | Clothes,
62 | TattooParlor = 75,
63 | Simeon,
64 | Lester,
65 | Michael,
66 | Trevor,
67 | Rampage = 84,
68 | VinewoodTours,
69 | Lamar,
70 | Franklin = 88,
71 | Chinese,
72 | Airport,
73 | Bar = 93,
74 | BaseJump,
75 | CarWash = 100,
76 | ComedyClub = 102,
77 | Dart,
78 | FIB = 106,
79 | DollarSign = 108,
80 | Golf,
81 | AmmuNation,
82 | Exile = 112,
83 | ShootingRange = 119,
84 | Solomon,
85 | StripClub,
86 | Tennis,
87 | Triathlon = 126,
88 | OffRoadRaceFinish,
89 | Key = 134,
90 | MovieTheater,
91 | Music,
92 | Marijuana = 140,
93 | Hunting,
94 | ArmsTraffickingGround = 147,
95 | Nigel = 149,
96 | AssaultRifle,
97 | Bat,
98 | Grenade,
99 | Health,
100 | Knife,
101 | Molotov,
102 | Pistol,
103 | RPG,
104 | Shotgun,
105 | SMG,
106 | Sniper,
107 | SonicWave,
108 | PointOfInterest,
109 | GTAOPassive,
110 | GTAOUsingMenu,
111 | Link = 171,
112 | Minigun = 173,
113 | GrenadeLauncher,
114 | Armor,
115 | Castle,
116 | Camera = 184,
117 | Handcuffs = 188,
118 | Yoga = 197,
119 | Cab,
120 | Number11,
121 | Number12,
122 | Number13,
123 | Number14,
124 | Number15,
125 | Number16,
126 | Shrink,
127 | Epsilon,
128 | PersonalVehicleCar = 225,
129 | PersonalVehicleBike,
130 | Custody = 237,
131 | ArmsTraffickingAir = 251,
132 | Fairground = 266,
133 | PropertyManagement,
134 | Altruist = 269,
135 | Enemy,
136 | Chop = 273,
137 | Dead,
138 | Hooker = 279,
139 | Friend,
140 | BountyHit = 303,
141 | GTAOMission,
142 | GTAOSurvival,
143 | CrateDrop,
144 | PlaneDrop,
145 | Sub,
146 | Race,
147 | Deathmatch,
148 | ArmWrestling,
149 | AmmuNationShootingRange = 313,
150 | RaceAir,
151 | RaceCar,
152 | RaceSea,
153 | GarbageTruck = 318,
154 | SafehouseForSale = 350,
155 | Package,
156 | MartinMadrazo,
157 | EnemyHelicopter,
158 | Boost,
159 | Devin,
160 | Marina,
161 | Garage,
162 | GolfFlag,
163 | Hangar,
164 | Helipad,
165 | JerryCan,
166 | Masks,
167 | HeistSetup,
168 | Incapacitated,
169 | PickupSpawn,
170 | BoilerSuit,
171 | Completed,
172 | Rockets,
173 | GarageForSale,
174 | HelipadForSale,
175 | MarinaForSale,
176 | HangarForSale,
177 | Business = 374,
178 | BusinessForSale,
179 | RaceBike,
180 | Parachute,
181 | TeamDeathmatch,
182 | RaceFoot,
183 | VehicleDeathmatch,
184 | Barry,
185 | Dom,
186 | MaryAnn,
187 | Cletus,
188 | Josh,
189 | Minute,
190 | Omega,
191 | Tonya,
192 | Paparazzo,
193 | Crosshair,
194 | Creator = 398,
195 | CreatorDirection,
196 | Abigail,
197 | Blimp,
198 | Repair,
199 | Testosterone,
200 | Dinghy,
201 | Fanatic,
202 | Information = 407,
203 | CaptureBriefcase,
204 | LastTeamStanding,
205 | Boat,
206 | CaptureHouse,
207 | JerryCan2 = 415,
208 | RP,
209 | GTAOPlayerSafehouse,
210 | GTAOPlayerSafehouseDead,
211 | CaptureAmericanFlag,
212 | CaptureFlag,
213 | Tank,
214 | HelicopterAnimated,
215 | Plane,
216 | PlayerNoColor = 425,
217 | GunCar,
218 | Speedboat,
219 | Heist,
220 | Stopwatch = 430,
221 | DollarSignCircled,
222 | Crosshair2,
223 | DollarSignSquared = 434,
224 | }
225 |
--------------------------------------------------------------------------------
/src/enums/Bone.ts:
--------------------------------------------------------------------------------
1 | /* eslint-disable @typescript-eslint/naming-convention */
2 | export enum Bone {
3 | SKEL_ROOT,
4 | SKEL_Pelvis = 11816,
5 | SKEL_L_Thigh = 58271,
6 | SKEL_L_Calf = 63931,
7 | SKEL_L_Foot = 14201,
8 | SKEL_L_Toe0 = 2108,
9 | IK_L_Foot = 65245,
10 | PH_L_Foot = 57717,
11 | MH_L_Knee = 46078,
12 | SKEL_R_Thigh = 51826,
13 | SKEL_R_Calf = 36864,
14 | SKEL_R_Foot = 52301,
15 | SKEL_R_Toe0 = 20781,
16 | IK_R_Foot = 35502,
17 | PH_R_Foot = 24806,
18 | MH_R_Knee = 16335,
19 | RB_L_ThighRoll = 23639,
20 | RB_R_ThighRoll = 6442,
21 | SKEL_Spine_Root = 57597,
22 | SKEL_Spine0 = 23553,
23 | SKEL_Spine1 = 24816,
24 | SKEL_Spine2,
25 | SKEL_Spine3,
26 | SKEL_L_Clavicle = 64729,
27 | SKEL_L_UpperArm = 45509,
28 | SKEL_L_Forearm = 61163,
29 | SKEL_L_Hand = 18905,
30 | SKEL_L_Finger00 = 26610,
31 | SKEL_L_Finger01 = 4089,
32 | SKEL_L_Finger02,
33 | SKEL_L_Finger10 = 26611,
34 | SKEL_L_Finger11 = 4169,
35 | SKEL_L_Finger12,
36 | SKEL_L_Finger20 = 26612,
37 | SKEL_L_Finger21 = 4185,
38 | SKEL_L_Finger22,
39 | SKEL_L_Finger30 = 26613,
40 | SKEL_L_Finger31 = 4137,
41 | SKEL_L_Finger32,
42 | SKEL_L_Finger40 = 26614,
43 | SKEL_L_Finger41 = 4153,
44 | SKEL_L_Finger42,
45 | PH_L_Hand = 60309,
46 | IK_L_Hand = 36029,
47 | RB_L_ForeArmRoll = 61007,
48 | RB_L_ArmRoll = 5232,
49 | MH_L_Elbow = 22711,
50 | SKEL_R_Clavicle = 10706,
51 | SKEL_R_UpperArm = 40269,
52 | SKEL_R_Forearm = 28252,
53 | SKEL_R_Hand = 57005,
54 | SKEL_R_Finger00 = 58866,
55 | SKEL_R_Finger01 = 64016,
56 | SKEL_R_Finger02,
57 | SKEL_R_Finger10 = 58867,
58 | SKEL_R_Finger11 = 64096,
59 | SKEL_R_Finger12,
60 | SKEL_R_Finger20 = 58868,
61 | SKEL_R_Finger21 = 64112,
62 | SKEL_R_Finger22,
63 | SKEL_R_Finger30 = 58869,
64 | SKEL_R_Finger31 = 64064,
65 | SKEL_R_Finger32,
66 | SKEL_R_Finger40 = 58870,
67 | SKEL_R_Finger41 = 64080,
68 | SKEL_R_Finger42,
69 | PH_R_Hand = 28422,
70 | IK_R_Hand = 6286,
71 | RB_R_ForeArmRoll = 43810,
72 | RB_R_ArmRoll = 37119,
73 | MH_R_Elbow = 2992,
74 | SKEL_Neck_1 = 39317,
75 | SKEL_Head = 31086,
76 | IK_Head = 12844,
77 | FACIAL_facialRoot = 65068,
78 | FB_L_Brow_Out_000 = 58331,
79 | FB_L_Lid_Upper_000 = 45750,
80 | FB_L_Eye_000 = 25260,
81 | FB_L_CheekBone_000 = 21550,
82 | FB_L_Lip_Corner_000 = 29868,
83 | FB_R_Lid_Upper_000 = 43536,
84 | FB_R_Eye_000 = 27474,
85 | FB_R_CheekBone_000 = 19336,
86 | FB_R_Brow_Out_000 = 1356,
87 | FB_R_Lip_Corner_000 = 11174,
88 | FB_Brow_Centre_000 = 37193,
89 | FB_UpperLipRoot_000 = 20178,
90 | FB_UpperLip_000 = 61839,
91 | FB_L_Lip_Top_000 = 20279,
92 | FB_R_Lip_Top_000 = 17719,
93 | FB_Jaw_000 = 46240,
94 | FB_LowerLipRoot_000 = 17188,
95 | FB_LowerLip_000 = 20623,
96 | FB_L_Lip_Bot_000 = 47419,
97 | FB_R_Lip_Bot_000 = 49979,
98 | FB_Tongue_000 = 47495,
99 | RB_Neck_1 = 35731,
100 | IK_Root = 56604,
101 | }
102 |
--------------------------------------------------------------------------------
/src/enums/CameraShake.ts:
--------------------------------------------------------------------------------
1 | export enum CameraShake {
2 | Hand,
3 | SmallExplosion,
4 | MediumExplosion,
5 | LargeExplosion,
6 | Jolt,
7 | Vibrate,
8 | RoadVibration,
9 | Drunk,
10 | SkyDiving,
11 | FamilyDrugTrip,
12 | DeathFail,
13 | }
14 |
--------------------------------------------------------------------------------
/src/enums/CheckboxStyle.ts:
--------------------------------------------------------------------------------
1 | export enum CheckboxStyle {
2 | Tick,
3 | Cross,
4 | }
5 |
--------------------------------------------------------------------------------
/src/enums/Checkpoint.ts:
--------------------------------------------------------------------------------
1 | export enum CheckpointIcon {
2 | CylinderSingleArrow,
3 | CylinderDoubleArrow,
4 | CylinderTripleArrow,
5 | CylinderCycleArrow,
6 | CylinderCheckerboard,
7 | CylinderSingleArrow2,
8 | CylinderDoubleArrow2,
9 | CylinderTripleArrow2,
10 | CylinderCycleArrow2,
11 | CylinderCheckerboard2,
12 | RingSingleArrow,
13 | RingDoubleArrow,
14 | RingTripleArrow,
15 | RingCycleArrow,
16 | RingCheckerboard,
17 | SingleArrow,
18 | DoubleArrow,
19 | TripleArrow,
20 | CycleArrow,
21 | Checkerboard,
22 | CylinderSingleArrow3,
23 | CylinderDoubleArrow3,
24 | CylinderTripleArrow3,
25 | CylinderCycleArrow3,
26 | CylinderCheckerboard3,
27 | CylinderSingleArrow4,
28 | CylinderDoubleArrow4,
29 | CylinderTripleArrow4,
30 | CylinderCycleArrow4,
31 | CylinderCheckerboard4,
32 | CylinderSingleArrow5,
33 | CylinderDoubleArrow5,
34 | CylinderTripleArrow5,
35 | CylinderCycleArrow5,
36 | CylinderCheckerboard5,
37 | RingPlaneUp,
38 | RingPlaneLeft,
39 | RingPlaneRight,
40 | RingPlaneDown,
41 | Empty,
42 | Ring,
43 | Empty2,
44 | // CylinderCustomShape,
45 | // CylinderCustomShape2,
46 | // CylinderCustomShape3,
47 | Cyclinder = 45,
48 | Cyclinder2,
49 | Cyclinder3,
50 | }
51 |
52 | export enum CheckpointCustomIconStyle {
53 | Number,
54 | SingleArrow,
55 | DoubleArrow,
56 | TripleArrow,
57 | Ring,
58 | CycleArrow,
59 | Ring2,
60 | RingPointer,
61 | SegmentedRing,
62 | Sphere,
63 | Dollar,
64 | QuintupleLines,
65 | BeastIcon,
66 | }
67 |
--------------------------------------------------------------------------------
/src/enums/CloudHat.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * List of cloud hats. Used to change cloud patterns
3 | */
4 | export enum CloudHat {
5 | Unknown = 1,
6 | Altostratus,
7 | Cirrus,
8 | Cirrocumulus,
9 | Clear,
10 | Cloudy,
11 | Contrails,
12 | Horizon,
13 | HorizonBand1,
14 | HorizonBand2,
15 | HorizonBand3,
16 | Horsey,
17 | Nimbus,
18 | Puffs,
19 | Rain,
20 | Snowy,
21 | Stormy,
22 | Stratoscumulus,
23 | Stripey,
24 | Shower,
25 | Wispy,
26 | }
27 |
--------------------------------------------------------------------------------
/src/enums/CursorSprite.ts:
--------------------------------------------------------------------------------
1 | export enum CursorSprite {
2 | Normal = 1,
3 | LightArrow,
4 | OpenHand,
5 | GrabHand,
6 | MiddleFinger,
7 | LeftArrow,
8 | RightArrow,
9 | UpArrow,
10 | DownArrow,
11 | HorizontalDoubleArrow,
12 | NormalWithPlus,
13 | NormalWithMinus,
14 | }
15 |
--------------------------------------------------------------------------------
/src/enums/Driving.ts:
--------------------------------------------------------------------------------
1 | export enum DrivingStyle {
2 | None = 0,
3 | Normal = 786603,
4 | IgnoreLights = 2883621,
5 | SometimesOvertakeTraffic = 5,
6 | Rushed = 1074528293,
7 | AvoidTraffic = 786468,
8 | AvoidTrafficExtremely = 6,
9 | AvoidHighwaysWhenPossible = 536870912,
10 | IgnorePathing = 16777216,
11 | IgnoreRoads = 4194304,
12 | ShortestPath = 262144,
13 | Backwards = 1024,
14 | }
15 |
16 | export enum VehicleDrivingFlags {
17 | None = 0,
18 | FollowTraffic = 1,
19 | YieldToPeds = 2,
20 | AvoidVehicles = 4,
21 | AvoidEmptyVehicles = 8,
22 | AvoidPeds = 16,
23 | AvoidObjects = 32,
24 | StopAtTrafficLights = 128,
25 | UseBlinkers = 256,
26 | AllowGoingWrongWay = 512,
27 | Reverse = 1024,
28 | AllowMedianCrossing = 262144,
29 | DriveBySight = 4194304,
30 | IgnorePathFinding = 16777216,
31 | TryToAvoidHighways = 536870912,
32 | StopAtDestination = 2147483648,
33 | }
34 |
--------------------------------------------------------------------------------
/src/enums/ExplosionType.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * List of explosion sources.
3 | */
4 | export enum ExplosionType {
5 | Grenade,
6 | GrenadeL,
7 | StickyBomb,
8 | Molotov1,
9 | Rocket,
10 | TankShell,
11 | HiOctane,
12 | Car,
13 | Plane,
14 | PetrolPump,
15 | Bike,
16 | Steam,
17 | Flame,
18 | WaterHydrant,
19 | GasCanister,
20 | Boat,
21 | ShipDestroy,
22 | Truck,
23 | Bullet,
24 | SmokeGL,
25 | SmokeG,
26 | BZGas,
27 | Flare,
28 | GasCanister2,
29 | Extinguisher,
30 | ProgramAR,
31 | Train,
32 | Barrel,
33 | Propane,
34 | Blimp,
35 | FlameExplode,
36 | Tanker,
37 | PlaneRocket,
38 | VehicleBullet,
39 | GasTank,
40 | FireWork,
41 | SnowBall,
42 | ProxMine,
43 | Valkyrie,
44 | }
45 |
--------------------------------------------------------------------------------
/src/enums/Font.ts:
--------------------------------------------------------------------------------
1 | export enum Font {
2 | ChaletLondon,
3 | HouseScript,
4 | Monospace,
5 | ChaletComprimeCologne = 4,
6 | Pricedown = 7,
7 | }
8 |
--------------------------------------------------------------------------------
/src/enums/ForceType.ts:
--------------------------------------------------------------------------------
1 | export enum ForceType {
2 | MinForce,
3 | MaxForceRot,
4 | MinForce2,
5 | MaxForceRot2,
6 | ForceNoRot,
7 | ForceRotPlusForce,
8 | }
9 |
--------------------------------------------------------------------------------
/src/enums/Gender.ts:
--------------------------------------------------------------------------------
1 | export enum Gender {
2 | Male,
3 | Female,
4 | }
5 |
--------------------------------------------------------------------------------
/src/enums/HelmetType.ts:
--------------------------------------------------------------------------------
1 | export enum HelmetType {
2 | RegularMotorcycleHelmet = 4096,
3 | FiremanHelmet = 16384,
4 | PilotHeadset = 32768,
5 | }
6 |
--------------------------------------------------------------------------------
/src/enums/HudColor.ts:
--------------------------------------------------------------------------------
1 | export enum HudColor {
2 | NONE = -1,
3 | HUD_COLOUR_PURE_WHITE = 0,
4 | HUD_COLOUR_WHITE = 1,
5 | HUD_COLOUR_BLACK = 2,
6 | HUD_COLOUR_GREY = 3,
7 | HUD_COLOUR_GREYLIGHT = 4,
8 | HUD_COLOUR_GREYDARK = 5,
9 | HUD_COLOUR_RED = 6,
10 | HUD_COLOUR_REDLIGHT = 7,
11 | HUD_COLOUR_REDDARK = 8,
12 | HUD_COLOUR_BLUE = 9,
13 | HUD_COLOUR_BLUELIGHT = 10,
14 | HUD_COLOUR_BLUEDARK = 11,
15 | HUD_COLOUR_YELLOW = 12,
16 | HUD_COLOUR_YELLOWLIGHT = 13,
17 | HUD_COLOUR_YELLOWDARK = 14,
18 | HUD_COLOUR_ORANGE = 15,
19 | HUD_COLOUR_ORANGELIGHT = 16,
20 | HUD_COLOUR_ORANGEDARK = 17,
21 | HUD_COLOUR_GREEN = 18,
22 | HUD_COLOUR_GREENLIGHT = 19,
23 | HUD_COLOUR_GREENDARK = 20,
24 | HUD_COLOUR_PURPLE = 21,
25 | HUD_COLOUR_PURPLELIGHT = 22,
26 | HUD_COLOUR_PURPLEDARK = 23,
27 | HUD_COLOUR_PINK = 24,
28 | HUD_COLOUR_RADAR_HEALTH = 25,
29 | HUD_COLOUR_RADAR_ARMOUR = 26,
30 | HUD_COLOUR_RADAR_DAMAGE = 27,
31 | HUD_COLOUR_NET_PLAYER1 = 28,
32 | HUD_COLOUR_NET_PLAYER2 = 29,
33 | HUD_COLOUR_NET_PLAYER3 = 30,
34 | HUD_COLOUR_NET_PLAYER4 = 31,
35 | HUD_COLOUR_NET_PLAYER5 = 32,
36 | HUD_COLOUR_NET_PLAYER6 = 33,
37 | HUD_COLOUR_NET_PLAYER7 = 34,
38 | HUD_COLOUR_NET_PLAYER8 = 35,
39 | HUD_COLOUR_NET_PLAYER9 = 36,
40 | HUD_COLOUR_NET_PLAYER10 = 37,
41 | HUD_COLOUR_NET_PLAYER11 = 38,
42 | HUD_COLOUR_NET_PLAYER12 = 39,
43 | HUD_COLOUR_NET_PLAYER13 = 40,
44 | HUD_COLOUR_NET_PLAYER14 = 41,
45 | HUD_COLOUR_NET_PLAYER15 = 42,
46 | HUD_COLOUR_NET_PLAYER16 = 43,
47 | HUD_COLOUR_NET_PLAYER17 = 44,
48 | HUD_COLOUR_NET_PLAYER18 = 45,
49 | HUD_COLOUR_NET_PLAYER19 = 46,
50 | HUD_COLOUR_NET_PLAYER20 = 47,
51 | HUD_COLOUR_NET_PLAYER21 = 48,
52 | HUD_COLOUR_NET_PLAYER22 = 49,
53 | HUD_COLOUR_NET_PLAYER23 = 50,
54 | HUD_COLOUR_NET_PLAYER24 = 51,
55 | HUD_COLOUR_NET_PLAYER25 = 52,
56 | HUD_COLOUR_NET_PLAYER26 = 53,
57 | HUD_COLOUR_NET_PLAYER27 = 54,
58 | HUD_COLOUR_NET_PLAYER28 = 55,
59 | HUD_COLOUR_NET_PLAYER29 = 56,
60 | HUD_COLOUR_NET_PLAYER30 = 57,
61 | HUD_COLOUR_NET_PLAYER31 = 58,
62 | HUD_COLOUR_NET_PLAYER32 = 59,
63 | HUD_COLOUR_SIMPLEBLIP_DEFAULT = 60,
64 | HUD_COLOUR_MENU_BLUE = 61,
65 | HUD_COLOUR_MENU_GREY_LIGHT = 62,
66 | HUD_COLOUR_MENU_BLUE_EXTRA_DARK = 63,
67 | HUD_COLOUR_MENU_YELLOW = 64,
68 | HUD_COLOUR_MENU_YELLOW_DARK = 65,
69 | HUD_COLOUR_MENU_GREEN = 66,
70 | HUD_COLOUR_MENU_GREY = 67,
71 | HUD_COLOUR_MENU_GREY_DARK = 68,
72 | HUD_COLOUR_MENU_HIGHLIGHT = 69,
73 | HUD_COLOUR_MENU_STANDARD = 70,
74 | HUD_COLOUR_MENU_DIMMED = 71,
75 | HUD_COLOUR_MENU_EXTRA_DIMMED = 72,
76 | HUD_COLOUR_BRIEF_TITLE = 73,
77 | HUD_COLOUR_MID_GREY_MP = 74,
78 | HUD_COLOUR_NET_PLAYER1_DARK = 75,
79 | HUD_COLOUR_NET_PLAYER2_DARK = 76,
80 | HUD_COLOUR_NET_PLAYER3_DARK = 77,
81 | HUD_COLOUR_NET_PLAYER4_DARK = 78,
82 | HUD_COLOUR_NET_PLAYER5_DARK = 79,
83 | HUD_COLOUR_NET_PLAYER6_DARK = 80,
84 | HUD_COLOUR_NET_PLAYER7_DARK = 81,
85 | HUD_COLOUR_NET_PLAYER8_DARK = 82,
86 | HUD_COLOUR_NET_PLAYER9_DARK = 83,
87 | HUD_COLOUR_NET_PLAYER10_DARK = 84,
88 | HUD_COLOUR_NET_PLAYER11_DARK = 85,
89 | HUD_COLOUR_NET_PLAYER12_DARK = 86,
90 | HUD_COLOUR_NET_PLAYER13_DARK = 87,
91 | HUD_COLOUR_NET_PLAYER14_DARK = 88,
92 | HUD_COLOUR_NET_PLAYER15_DARK = 89,
93 | HUD_COLOUR_NET_PLAYER16_DARK = 90,
94 | HUD_COLOUR_NET_PLAYER17_DARK = 91,
95 | HUD_COLOUR_NET_PLAYER18_DARK = 92,
96 | HUD_COLOUR_NET_PLAYER19_DARK = 93,
97 | HUD_COLOUR_NET_PLAYER20_DARK = 94,
98 | HUD_COLOUR_NET_PLAYER21_DARK = 95,
99 | HUD_COLOUR_NET_PLAYER22_DARK = 96,
100 | HUD_COLOUR_NET_PLAYER23_DARK = 97,
101 | HUD_COLOUR_NET_PLAYER24_DARK = 98,
102 | HUD_COLOUR_NET_PLAYER25_DARK = 99,
103 | HUD_COLOUR_NET_PLAYER26_DARK = 100,
104 | HUD_COLOUR_NET_PLAYER27_DARK = 101,
105 | HUD_COLOUR_NET_PLAYER28_DARK = 102,
106 | HUD_COLOUR_NET_PLAYER29_DARK = 103,
107 | HUD_COLOUR_NET_PLAYER30_DARK = 104,
108 | HUD_COLOUR_NET_PLAYER31_DARK = 105,
109 | HUD_COLOUR_NET_PLAYER32_DARK = 106,
110 | HUD_COLOUR_BRONZE = 107,
111 | HUD_COLOUR_SILVER = 108,
112 | HUD_COLOUR_GOLD = 109,
113 | HUD_COLOUR_PLATINUM = 110,
114 | HUD_COLOUR_GANG1 = 111,
115 | HUD_COLOUR_GANG2 = 112,
116 | HUD_COLOUR_GANG3 = 113,
117 | HUD_COLOUR_GANG4 = 114,
118 | HUD_COLOUR_SAME_CREW = 115,
119 | HUD_COLOUR_FREEMODE = 116,
120 | HUD_COLOUR_PAUSE_BG = 117,
121 | HUD_COLOUR_FRIENDLY = 118,
122 | HUD_COLOUR_ENEMY = 119,
123 | HUD_COLOUR_LOCATION = 120,
124 | HUD_COLOUR_PICKUP = 121,
125 | HUD_COLOUR_PAUSE_SINGLEPLAYER = 122,
126 | HUD_COLOUR_FREEMODE_DARK = 123,
127 | HUD_COLOUR_INACTIVE_MISSION = 124,
128 | HUD_COLOUR_DAMAGE = 125,
129 | HUD_COLOUR_PINKLIGHT = 126,
130 | HUD_COLOUR_PM_MITEM_HIGHLIGHT = 127,
131 | HUD_COLOUR_SCRIPT_VARIABLE = 128,
132 | HUD_COLOUR_YOGA = 129,
133 | HUD_COLOUR_TENNIS = 130,
134 | HUD_COLOUR_GOLF = 131,
135 | HUD_COLOUR_SHOOTING_RANGE = 132,
136 | HUD_COLOUR_FLIGHT_SCHOOL = 133,
137 | HUD_COLOUR_NORTH_BLUE = 134,
138 | HUD_COLOUR_SOCIAL_CLUB = 135,
139 | HUD_COLOUR_PLATFORM_BLUE = 136,
140 | HUD_COLOUR_PLATFORM_GREEN = 137,
141 | HUD_COLOUR_PLATFORM_GREY = 138,
142 | HUD_COLOUR_FACEBOOK_BLUE = 139,
143 | HUD_COLOUR_INGAME_BG = 140,
144 | HUD_COLOUR_DARTS = 141,
145 | HUD_COLOUR_WAYPOINT = 142,
146 | HUD_COLOUR_MICHAEL = 143,
147 | HUD_COLOUR_FRANKLIN = 144,
148 | HUD_COLOUR_TREVOR = 145,
149 | HUD_COLOUR_GOLF_P1 = 146,
150 | HUD_COLOUR_GOLF_P2 = 147,
151 | HUD_COLOUR_GOLF_P3 = 148,
152 | HUD_COLOUR_GOLF_P4 = 149,
153 | HUD_COLOUR_WAYPOINTLIGHT = 150,
154 | HUD_COLOUR_WAYPOINTDARK = 151,
155 | HUD_COLOUR_PANEL_LIGHT = 152,
156 | HUD_COLOUR_MICHAEL_DARK = 153,
157 | HUD_COLOUR_FRANKLIN_DARK = 154,
158 | HUD_COLOUR_TREVOR_DARK = 155,
159 | HUD_COLOUR_OBJECTIVE_ROUTE = 156,
160 | HUD_COLOUR_PAUSEMAP_TINT = 157,
161 | HUD_COLOUR_PAUSE_DESELECT = 158,
162 | HUD_COLOUR_PM_WEAPONS_PURCHASABLE = 159,
163 | HUD_COLOUR_PM_WEAPONS_LOCKED = 160,
164 | HUD_COLOUR_END_SCREEN_BG = 161,
165 | HUD_COLOUR_CHOP = 162,
166 | HUD_COLOUR_PAUSEMAP_TINT_HALF = 163,
167 | HUD_COLOUR_NORTH_BLUE_OFFICIAL = 164,
168 | HUD_COLOUR_SCRIPT_VARIABLE_2 = 165,
169 | HUD_COLOUR_H = 166,
170 | HUD_COLOUR_HDARK = 167,
171 | HUD_COLOUR_T = 168,
172 | HUD_COLOUR_TDARK = 169,
173 | HUD_COLOUR_HSHARD = 170,
174 | HUD_COLOUR_CONTROLLER_MICHAEL = 171,
175 | HUD_COLOUR_CONTROLLER_FRANKLIN = 172,
176 | HUD_COLOUR_CONTROLLER_TREVOR = 173,
177 | HUD_COLOUR_CONTROLLER_CHOP = 174,
178 | HUD_COLOUR_VIDEO_EDITOR_VIDEO = 175,
179 | HUD_COLOUR_VIDEO_EDITOR_AUDIO = 176,
180 | HUD_COLOUR_VIDEO_EDITOR_TEXT = 177,
181 | HUD_COLOUR_HB_BLUE = 178,
182 | HUD_COLOUR_HB_YELLOW = 179,
183 | }
184 |
--------------------------------------------------------------------------------
/src/enums/HudComponent.ts:
--------------------------------------------------------------------------------
1 | export enum HudComponent {
2 | WantedStars = 1,
3 | WeaponIcon,
4 | Cash,
5 | MpCash,
6 | MpMessage,
7 | VehicleName,
8 | AreaName,
9 | Unused,
10 | StreetName,
11 | HelpText,
12 | FloatingHelpText1,
13 | FloatingHelpText2,
14 | CashChange,
15 | Reticle,
16 | SubtitleText,
17 | RadioStationsWheel,
18 | Saving,
19 | GamingStreamUnusde,
20 | WeaponWheel,
21 | WeaponWheelStats,
22 | DrugsPurse01,
23 | DrugsPurse02,
24 | DrugsPurse03,
25 | DrugsPurse04,
26 | MpTagCashFromBank,
27 | MpTagPackages,
28 | MpTagCuffKeys,
29 | MpTagDownloadData,
30 | MpTagIfPedFollowing,
31 | MpTagKeyCard,
32 | MpTagRandomObject,
33 | MpTagRemoteControl,
34 | MpTagCashFromSafe,
35 | MpTagWeaponsPackage,
36 | MpTagKeys,
37 | MpVehicle,
38 | MpVehicleHeli,
39 | MpVehiclePlane,
40 | PlayerSwitchAlert,
41 | MpRankBar,
42 | DirectorMode,
43 | ReplayController,
44 | ReplayMouse,
45 | ReplayHeader,
46 | ReplayOptions,
47 | ReplayHelpText,
48 | ReplayMiscText,
49 | ReplayTopLine,
50 | ReplayBottomLine,
51 | ReplayLeftBar,
52 | ReplayTimer,
53 | }
54 |
--------------------------------------------------------------------------------
/src/enums/InputMode.ts:
--------------------------------------------------------------------------------
1 | export enum InputMode {
2 | MouseAndKeyboard = 0,
3 | GamePad = 2,
4 | }
5 |
--------------------------------------------------------------------------------
/src/enums/IntersectOptions.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * List of possible entity intersections. Used for raycasting.
3 | */
4 | export enum IntersectOptions {
5 | Everything = -1,
6 | Map = 1,
7 | MissionEntities,
8 | Peds1 = 12,
9 | Objects = 16,
10 | Unk1 = 32,
11 | Unk2 = 64,
12 | Unk3 = 128,
13 | Vegetation = 256,
14 | Unk4 = 512,
15 | }
16 |
--------------------------------------------------------------------------------
/src/enums/InvertAxis.ts:
--------------------------------------------------------------------------------
1 | export interface InvertAxis {
2 | flags: InvertAxisFlags;
3 | }
4 |
5 | export enum InvertAxisFlags {
6 | None = 0,
7 | X = 1,
8 | Y = 2,
9 | Z = 4,
10 | }
11 |
--------------------------------------------------------------------------------
/src/enums/Language.ts:
--------------------------------------------------------------------------------
1 | export enum Language {
2 | American,
3 | French,
4 | German,
5 | Italian,
6 | Spanish,
7 | Portuguese,
8 | Polish,
9 | Russian,
10 | Korean,
11 | Chinese,
12 | Japanese,
13 | Mexican,
14 | }
15 |
--------------------------------------------------------------------------------
/src/enums/LoadingSpinnerType.ts:
--------------------------------------------------------------------------------
1 | export enum LoadingSpinnerType {
2 | Clockwise1 = 1,
3 | Clockwise2,
4 | Clockwise3,
5 | SocialClubSaving,
6 | RegularClockwise,
7 | }
8 |
--------------------------------------------------------------------------------
/src/enums/MarkerType.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * List of markers. Markers are 3D visual objects in the world.
3 | *
4 | * See native [DRAW_MARKER](https://docs.fivem.net/game-references/markers/) for pictures.
5 | */
6 | export enum MarkerType {
7 | UpsideDownCone,
8 | VerticalCylinder,
9 | ThickChevronUp,
10 | ThinChevronUp,
11 | CheckeredFlagRect,
12 | CheckeredFlagCircle,
13 | VerticleCircle,
14 | PlaneModel,
15 | LostMCDark,
16 | LostMCLight,
17 | Number0,
18 | Number1,
19 | Number2,
20 | Number3,
21 | Number4,
22 | Number5,
23 | Number6,
24 | Number7,
25 | Number8,
26 | Number9,
27 | ChevronUpx1,
28 | ChevronUpx2,
29 | ChevronUpx3,
30 | HorizontalCircleFat,
31 | ReplayIcon,
32 | HorizontalCircleSkinny,
33 | HorizontalCircleSkinnyArrow,
34 | HorizontalSplitArrowCircle,
35 | DebugSphere,
36 | DollarSign,
37 | HorizontalBars,
38 | WolfHead,
39 | QuestionMark,
40 | PlaneSymbol,
41 | HelicopterSymbol,
42 | BoatSymbol,
43 | CarSymbol,
44 | MotorcycleSymbol,
45 | BikeSymbol,
46 | TruckSymbol,
47 | ParachuteSymbol,
48 | SawbladeSymbol,
49 | }
50 |
--------------------------------------------------------------------------------
/src/enums/NotificationType.ts:
--------------------------------------------------------------------------------
1 | export enum NotificationType {
2 | Default = 0,
3 | Bubble = 1,
4 | Mail = 2,
5 | FriendRequest = 3,
6 | Default2 = 4,
7 | Reply = 7,
8 | ReputationPoints = 8,
9 | Money = 9,
10 | }
11 |
--------------------------------------------------------------------------------
/src/enums/Parachute.ts:
--------------------------------------------------------------------------------
1 | export enum ParachuteLandingType {
2 | None = -1,
3 | Stumbling = 1,
4 | Rolling,
5 | Ragdoll,
6 | }
7 |
8 | export enum ParachuteState {
9 | None = -1,
10 | FreeFalling,
11 | Deploying,
12 | Gliding,
13 | LandingOrFallingToDoom,
14 | }
15 |
--------------------------------------------------------------------------------
/src/enums/RadioStation.ts:
--------------------------------------------------------------------------------
1 | export enum RadioStation {
2 | LosSantosRockRadio = 'RADIO_01_CLASS_ROCK',
3 | NonStopPopFM = 'RADIO_02_POP',
4 | RadioLosSantos = 'RADIO_03_HIPHOP_NEW',
5 | ChannelX = 'RADIO_04_PUNK',
6 | WestCoastTalkRadio = 'RADIO_05_TALK_01',
7 | RebelRadio = 'RADIO_06_COUNTRY',
8 | SoulwaxFM = 'RADIO_07_DANCE_01',
9 | EastLosFM = 'RADIO_08_MEXICAN',
10 | WestCoastClassics = 'RADIO_09_HIPHOP_OLD',
11 | BlaineCountyRadio = 'RADIO_11_TALK_02',
12 | TheBlueArk = 'RADIO_12_REGGAE',
13 | WorldWideFM = 'RADIO_13_JAZZ',
14 | FlyloFM = 'RADIO_14_DANCE_02',
15 | TheLowdown = 'RADIO_15_MOTOWN',
16 | RadioMirrorPark = 'RADIO_16_SILVERLAKE',
17 | Space = 'RADIO_17_FUNK',
18 | VinewoodBoulevardRadio = 'RADIO_18_90S_ROCK',
19 | SelfRadio = 'RADIO_19_USER',
20 | TheLab = 'RADIO_20_THELAB',
21 | BlondedLosSantos = 'RADIO_21_DLC_XM17',
22 | LosSantosUndergroundRadio = 'RADIO_22_DLC_BATTLE_MIX1_RADIO',
23 | RadioOff = 'OFF',
24 | }
25 |
--------------------------------------------------------------------------------
/src/enums/RagdollType.ts:
--------------------------------------------------------------------------------
1 | export enum RagdollType {
2 | Normal = 0,
3 | StiffLegs = 1,
4 | NarrowLegs = 2,
5 | WideLegs = 3,
6 | }
7 |
--------------------------------------------------------------------------------
/src/enums/Relationship.ts:
--------------------------------------------------------------------------------
1 | export enum Relationship {
2 | Hate = 5,
3 | Dislike = 4,
4 | Neutral = 3,
5 | Like = 2,
6 | Respect = 1,
7 | Companion = 0,
8 | Pedestrians = 255,
9 | }
10 |
--------------------------------------------------------------------------------
/src/enums/RopeType.ts:
--------------------------------------------------------------------------------
1 | export enum RopeType {
2 | ThickRope = 4,
3 | ThinMetalWire = 5,
4 | }
5 |
--------------------------------------------------------------------------------
/src/enums/ScreenEffect.ts:
--------------------------------------------------------------------------------
1 | export enum ScreenEffect {
2 | SwitchHudIn,
3 | SwitchHudOut,
4 | FocusIn,
5 | FocusOut,
6 | MinigameEndNeutral,
7 | MinigameEndTrevor,
8 | MinigameEndFranklin,
9 | MinigameEndMichael,
10 | MinigameTransitionOut,
11 | MinigameTransitionIn,
12 | SwitchShortNeutralIn,
13 | SwitchShortFranklinIn,
14 | SwitchShortTrevorIn,
15 | SwitchShortMichaelIn,
16 | SwitchOpenMichaelIn,
17 | SwitchOpenFranklinIn,
18 | SwitchOpenTrevorIn,
19 | SwitchHudMichaelOut,
20 | SwitchHudFranklinOut,
21 | SwitchHudTrevorOut,
22 | SwitchShortFranklinMid,
23 | SwitchShortMichaelMid,
24 | SwitchShortTrevorMid,
25 | DeathFailOut,
26 | CamPushInNeutral,
27 | CamPushInFranklin,
28 | CamPushInMichael,
29 | CamPushInTrevor,
30 | SwitchSceneFranklin,
31 | SwitchSceneTrevor,
32 | SwitchSceneMichael,
33 | SwitchSceneNeutral,
34 | MpCelebWin,
35 | MpCelebWinOut,
36 | MpCelebLose,
37 | MpCelebLoseOut,
38 | DeathFailNeutralIn,
39 | DeathFailMpDark,
40 | DeathFailMpIn,
41 | MpCelebPreloadFade,
42 | PeyoteEndOut,
43 | PeyoteEndIn,
44 | PeyoteIn,
45 | PeyoteOut,
46 | MpRaceCrash,
47 | SuccessFranklin,
48 | SuccessTrevor,
49 | SuccessMichael,
50 | DrugsMichaelAliensFightIn,
51 | DrugsMichaelAliensFight,
52 | DrugsMichaelAliensFightOut,
53 | DrugsTrevorClownsFightIn,
54 | DrugsTrevorClownsFight,
55 | DrugsTrevorClownsFightOut,
56 | HeistCelebPass,
57 | HeistCelebPassBw,
58 | HeistCelebEnd,
59 | HeistCelebToast,
60 | MenuMgHeistIn,
61 | MenuMgTournamentIn,
62 | MenuMgSelectionIn,
63 | ChopVision,
64 | DmtFlightIntro,
65 | DmtFlight,
66 | DrugsDrivingIn,
67 | DrugsDrivingOut,
68 | SwitchOpenNeutralFib5,
69 | HeistLocate,
70 | MpJobLoad,
71 | RaceTurbo,
72 | MpIntroLogo,
73 | HeistTripSkipFade,
74 | MenuMgHeistOut,
75 | MpCoronaSwitch,
76 | MenuMgSelectionTint,
77 | SuccessNeutral,
78 | ExplosionJosh3,
79 | SniperOverlay,
80 | RampageOut,
81 | Rampage,
82 | DontTazemeBro,
83 | }
84 |
--------------------------------------------------------------------------------
/src/enums/SpeechModifier.ts:
--------------------------------------------------------------------------------
1 | export enum SpeechModifier {
2 | Standard = 0,
3 | AllowRepeat = 1,
4 | Beat = 2,
5 | Force = 3,
6 | ForceFrontend = 4,
7 | ForceNoRepeatFrontend = 5,
8 | ForceNormal = 6,
9 | ForceNormalClear = 7,
10 | ForceNormalCritical = 8,
11 | ForceShouted = 9,
12 | ForceShoutedClear = 10,
13 | ForceShoutedCritical = 11,
14 | ForcePreloadOnly = 12,
15 | Megaphone = 13,
16 | Helicopter = 14,
17 | ForceMegaphone = 15,
18 | ForceHelicopter = 16,
19 | Interrupt = 17,
20 | InterruptShouted = 18,
21 | InterruptShoutedClear = 19,
22 | InterruptShoutedCritical = 20,
23 | InterruptNoForce = 21,
24 | InterruptFrontend = 22,
25 | InterruptNoForceFrontend = 23,
26 | AddBlip = 24,
27 | AddBlipAllowRepeat = 25,
28 | AddBlipForce = 26,
29 | AddBlipShouted = 27,
30 | AddBlipShoutedForce = 28,
31 | AddBlipInterrupt = 29,
32 | AddBlipInterruptForce = 30,
33 | ForcePreloadOnlyShouted = 31,
34 | ForcePreloadOnlyShoutedClear = 32,
35 | ForcePreloadOnlyShoutedCritical = 33,
36 | Shouted = 34,
37 | ShoutedClear = 35,
38 | ShoutedCritical = 36,
39 | }
40 |
--------------------------------------------------------------------------------
/src/enums/Vehicle.ts:
--------------------------------------------------------------------------------
1 | export enum CargobobHook {
2 | Hook,
3 | Magnet,
4 | }
5 |
6 | export enum LicensePlateStyle {
7 | BlueOnWhite1 = 3,
8 | BlueOnWhite2 = 0,
9 | BlueOnWhite3 = 4,
10 | YellowOnBlack = 1,
11 | YellowOnBlue = 2,
12 | NorthYankton = 5,
13 | }
14 |
15 | export enum LicensePlateType {
16 | FrontAndRearPlates,
17 | FrontPlate,
18 | RearPlate,
19 | None,
20 | }
21 |
22 | export enum VehicleClass {
23 | Compacts,
24 | Sedans,
25 | SUVs,
26 | Coupes,
27 | Muscle,
28 | SportsClassics,
29 | Sports,
30 | Super,
31 | Motorcycles,
32 | OffRoad,
33 | Industrial,
34 | Utility,
35 | Vans,
36 | Cycles,
37 | Boats,
38 | Helicopters,
39 | Planes,
40 | Service,
41 | Emergency,
42 | Military,
43 | Commercial,
44 | Trains,
45 | }
46 |
47 | export enum VehicleColor {
48 | MetallicBlack,
49 | MetallicGraphiteBlack,
50 | MetallicBlackSteel,
51 | MetallicDarkSilver,
52 | MetallicSilver,
53 | MetallicBlueSilver,
54 | MetallicSteelGray,
55 | MetallicShadowSilver,
56 | MetallicStoneSilver,
57 | MetallicMidnightSilver,
58 | MetallicGunMetal,
59 | MetallicAnthraciteGray,
60 | MatteBlack,
61 | MatteGray,
62 | MatteLightGray,
63 | UtilBlack,
64 | UtilBlackPoly,
65 | UtilDarksilver,
66 | UtilSilver,
67 | UtilGunMetal,
68 | UtilShadowSilver,
69 | WornBlack,
70 | WornGraphite,
71 | WornSilverGray,
72 | WornSilver,
73 | WornBlueSilver,
74 | WornShadowSilver,
75 | MetallicRed,
76 | MetallicTorinoRed,
77 | MetallicFormulaRed,
78 | MetallicBlazeRed,
79 | MetallicGracefulRed,
80 | MetallicGarnetRed,
81 | MetallicDesertRed,
82 | MetallicCabernetRed,
83 | MetallicCandyRed,
84 | MetallicSunriseOrange,
85 | MetallicClassicGold,
86 | MetallicOrange,
87 | MatteRed,
88 | MatteDarkRed,
89 | MatteOrange,
90 | MatteYellow,
91 | UtilRed,
92 | UtilBrightRed,
93 | UtilGarnetRed,
94 | WornRed,
95 | WornGoldenRed,
96 | WornDarkRed,
97 | MetallicDarkGreen,
98 | MetallicRacingGreen,
99 | MetallicSeaGreen,
100 | MetallicOliveGreen,
101 | MetallicGreen,
102 | MetallicGasolineBlueGreen,
103 | MatteLimeGreen,
104 | UtilDarkGreen,
105 | UtilGreen,
106 | WornDarkGreen,
107 | WornGreen,
108 | WornSeaWash,
109 | MetallicMidnightBlue,
110 | MetallicDarkBlue,
111 | MetallicSaxonyBlue,
112 | MetallicBlue,
113 | MetallicMarinerBlue,
114 | MetallicHarborBlue,
115 | MetallicDiamondBlue,
116 | MetallicSurfBlue,
117 | MetallicNauticalBlue,
118 | MetallicBrightBlue,
119 | MetallicPurpleBlue,
120 | MetallicSpinnakerBlue,
121 | MetallicUltraBlue,
122 | UtilDarkBlue = 75,
123 | UtilMidnightBlue,
124 | UtilBlue,
125 | UtilSeaFoamBlue,
126 | UtilLightningBlue,
127 | UtilMauiBluePoly,
128 | UtilBrightBlue,
129 | MatteDarkBlue,
130 | MatteBlue,
131 | MatteMidnightBlue,
132 | WornDarkBlue,
133 | WornBlue,
134 | WornLightBlue,
135 | MetallicTaxiYellow,
136 | MetallicRaceYellow,
137 | MetallicBronze,
138 | MetallicYellowBird,
139 | MetallicLime,
140 | MetallicChampagne,
141 | MetallicPuebloBeige,
142 | MetallicDarkIvory,
143 | MetallicChocoBrown,
144 | MetallicGoldenBrown,
145 | MetallicLightBrown,
146 | MetallicStrawBeige,
147 | MetallicMossBrown,
148 | MetallicBistonBrown,
149 | MetallicBeechwood,
150 | MetallicDarkBeechwood,
151 | MetallicChocoOrange,
152 | MetallicBeachSand,
153 | MetallicSunBleechedSand,
154 | MetallicCream,
155 | UtilBrown,
156 | UtilMediumBrown,
157 | UtilLightBrown,
158 | MetallicWhite,
159 | MetallicFrostWhite,
160 | WornHoneyBeige,
161 | WornBrown,
162 | WornDarkBrown,
163 | WornStrawBeige,
164 | BrushedSteel,
165 | BrushedBlackSteel,
166 | BrushedAluminium,
167 | Chrome,
168 | WornOffWhite,
169 | UtilOffWhite,
170 | WornOrange,
171 | WornLightOrange,
172 | MetallicSecuricorGreen,
173 | WornTaxiYellow,
174 | PoliceCarBlue,
175 | MatteGreen,
176 | MatteBrown,
177 | MatteWhite = 131,
178 | WornWhite,
179 | WornOliveArmyGreen,
180 | PureWhite,
181 | HotPink,
182 | Salmonpink,
183 | MetallicVermillionPink,
184 | Orange,
185 | Green,
186 | Blue,
187 | MettalicBlackBlue,
188 | MetallicBlackPurple,
189 | MetallicBlackRed,
190 | HunterGreen,
191 | MetallicPurple,
192 | MetaillicVDarkBlue,
193 | ModshopBlack1,
194 | MattePurple,
195 | MatteDarkPurple,
196 | MetallicLavaRed,
197 | MatteForestGreen,
198 | MatteOliveDrab,
199 | MatteDesertBrown,
200 | MatteDesertTan,
201 | MatteFoliageGreen,
202 | DefaultAlloyColor,
203 | EpsilonBlue,
204 | PureGold,
205 | BrushedGold,
206 | }
207 |
208 | export enum VehicleLandingGearState {
209 | Deployed,
210 | Closing,
211 | Opening,
212 | Retracted,
213 | }
214 |
215 | export enum VehicleLockStatus {
216 | None,
217 | Unlocked,
218 | Locked,
219 | LockedForPlayer,
220 | StickPlayerInside,
221 | CanBeBrokenInto = 7,
222 | CanBeBrokenIntoPersist,
223 | CannotBeTriedToEnter = 10,
224 | }
225 |
226 | export enum VehicleNeonLight {
227 | Left,
228 | Right,
229 | Front,
230 | Back,
231 | }
232 |
233 | export enum VehicleRoofState {
234 | Closed,
235 | Opening,
236 | Opened,
237 | Closing,
238 | }
239 |
240 | export enum VehicleSeat {
241 | None = -3,
242 | Any,
243 | Driver,
244 | Passenger,
245 | LeftFront = -1,
246 | RightFront,
247 | LeftRear,
248 | RightRear,
249 | ExtraSeat1,
250 | ExtraSeat2,
251 | ExtraSeat3,
252 | ExtraSeat4,
253 | ExtraSeat5,
254 | ExtraSeat6,
255 | ExtraSeat7,
256 | ExtraSeat8,
257 | ExtraSeat9,
258 | ExtraSeat10,
259 | ExtraSeat11,
260 | ExtraSeat12,
261 | }
262 |
263 | export enum VehicleWindowTint {
264 | None,
265 | PureBlack,
266 | DarkSmoke,
267 | LightSmoke,
268 | Stock,
269 | Limo,
270 | Green,
271 | }
272 |
273 | export enum VehicleWindowIndex {
274 | FrontRightWindow = 1,
275 | FrontLeftWindow = 0,
276 | BackRightWindow = 3,
277 | BackLeftWindow = 2,
278 | ExtraWindow1 = 4,
279 | ExtraWindow2 = 5,
280 | ExtraWindow3 = 6,
281 | ExtraWindow4 = 7,
282 | }
283 |
284 | export enum VehicleModType {
285 | Spoilers,
286 | FrontBumper,
287 | RearBumper,
288 | SideSkirt,
289 | Exhaust,
290 | Frame,
291 | Grille,
292 | Hood,
293 | Fender,
294 | RightFender,
295 | Roof,
296 | Engine,
297 | Brakes,
298 | Transmission,
299 | Horns,
300 | Suspension,
301 | Armor,
302 | FrontWheel = 23,
303 | RearWheel,
304 | PlateHolder,
305 | VanityPlates,
306 | TrimDesign,
307 | Ornaments,
308 | Dashboard,
309 | DialDesign,
310 | DoorSpeakers,
311 | Seats,
312 | SteeringWheels,
313 | ColumnShifterLevers,
314 | Plaques,
315 | Speakers,
316 | Trunk,
317 | Hydraulics,
318 | EngineBlock,
319 | AirFilter,
320 | Struts,
321 | ArchCover,
322 | Aerials,
323 | Trim,
324 | Tank,
325 | Windows,
326 | Livery = 48,
327 | }
328 |
329 | export enum VehicleToggleModType {
330 | Turbo = 18,
331 | TireSmoke = 20,
332 | XenonHeadlights = 22,
333 | }
334 |
335 | export enum VehiclePaintType {
336 | Normal,
337 | Metallic,
338 | Pearl,
339 | Matte,
340 | Metal,
341 | Chrome,
342 | }
343 |
344 | export enum VehicleDoorIndex {
345 | FrontRightDoor = 1,
346 | FrontLeftDoor = 0,
347 | BackRightDoor = 3,
348 | BackLeftDoor = 2,
349 | Hood = 4,
350 | Trunk = 5,
351 | }
352 |
353 | export enum VehicleWheelType {
354 | Sport,
355 | Muscle,
356 | Lowrider,
357 | SUV,
358 | Offroad,
359 | Tuner,
360 | BikeWheels,
361 | HighEnd,
362 | BennysOriginals,
363 | BennysBespoke,
364 | }
365 |
366 | export enum VehicleWheelIndex {
367 | FrontLeftWheel,
368 | FrontRightWheel,
369 | MidLeftWheel,
370 | MidRightWheel,
371 | RearLeftWheel,
372 | RearRightWheel,
373 | TrailerMidLeftWheel = 45,
374 | TrailerMidRightWheel = 47,
375 | }
376 |
--------------------------------------------------------------------------------
/src/enums/Weather.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * List of weather types. Used for manipulating weather.
3 | */
4 | export enum Weather {
5 | Unknown = -1,
6 | ExtraSunny,
7 | Clear,
8 | Clouds,
9 | Smog,
10 | Foggy,
11 | Overcast,
12 | Raining,
13 | ThunderStorm,
14 | Clearing,
15 | Neutral,
16 | Snowing,
17 | Blizzard,
18 | Snowlight,
19 | Christmas,
20 | Halloween,
21 | }
22 |
--------------------------------------------------------------------------------
/src/enums/ZoneID.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * List of Zones. Useful for using world zone related natives.
3 | */
4 | export enum ZoneID {
5 | AIRP,
6 | ALAMO,
7 | ALTA,
8 | ARMYB,
9 | BANHAMC,
10 | BANNING,
11 | BEACH,
12 | BHAMCA,
13 | BRADP,
14 | BRADT,
15 | BURTON,
16 | CALAFB,
17 | CANNY,
18 | CCREAK,
19 | CHAMH,
20 | CHIL,
21 | CHU,
22 | CMSW,
23 | CYPRE,
24 | DAVIS,
25 | DELBE,
26 | DELPE,
27 | DELSOL,
28 | DESRT,
29 | DOWNT,
30 | DTVINE,
31 | EAST_V,
32 | EBURO,
33 | ELGORL,
34 | ELYSIAN,
35 | GALFISH,
36 | golf,
37 | GRAPES,
38 | GREATC,
39 | HARMO,
40 | HAWICK,
41 | HORS,
42 | HUMLAB,
43 | JAIL,
44 | KOREAT,
45 | LACT,
46 | LAGO,
47 | LDAM,
48 | LEGSQU,
49 | LMESA,
50 | LOSPUER,
51 | MIRR,
52 | MORN,
53 | MOVIE,
54 | MTCHIL,
55 | MTGORDO,
56 | MTJOSE,
57 | MURRI,
58 | NCHU,
59 | NOOSE,
60 | OCEANA,
61 | PALCOV,
62 | PALETO,
63 | PALFOR,
64 | PALHIGH,
65 | PALMPOW,
66 | PBLUFF,
67 | PBOX,
68 | PROCOB,
69 | RANCHO,
70 | RGLEN,
71 | RICHM,
72 | ROCKF,
73 | RTRAK,
74 | SanAnd,
75 | SANCHIA,
76 | SANDY,
77 | SKID,
78 | SLAB,
79 | STAD,
80 | STRAW,
81 | TATAMO,
82 | TERMINA,
83 | TEXTI,
84 | TONGVAH,
85 | TONGVAV,
86 | VCANA,
87 | VESP,
88 | VINE,
89 | WINDF,
90 | WVINE,
91 | ZANCUDO,
92 | ZP_ORT,
93 | ZQ_UAR,
94 | }
95 |
--------------------------------------------------------------------------------
/src/enums/index.ts:
--------------------------------------------------------------------------------
1 | export { Alignment } from './Alignment';
2 | export { AudioFlag } from './AudioFlag';
3 | export { BadgeStyle } from './BadgeStyle';
4 | export { BlipColor, BlipSprite } from './Blip';
5 | export { Bone } from './Bone';
6 | export { CameraShake } from './CameraShake';
7 | export { CheckboxStyle } from './CheckboxStyle';
8 | export { CheckpointCustomIconStyle, CheckpointIcon } from './Checkpoint';
9 | export { CloudHat } from './CloudHat';
10 | export { Control } from './Control';
11 | export { CursorSprite } from './CursorSprite';
12 | export { DrivingStyle, VehicleDrivingFlags } from './Driving';
13 | export { ExplosionType } from './ExplosionType';
14 | export { Font } from './Font';
15 | export { ForceType } from './ForceType';
16 | export { Gender } from './Gender';
17 | export { HelmetType } from './HelmetType';
18 | export { HudColor } from './HudColor';
19 | export { HudComponent } from './HudComponent';
20 | export { InputMode } from './InputMode';
21 | export { IntersectOptions } from './IntersectOptions';
22 | export { InvertAxis, InvertAxisFlags } from './InvertAxis';
23 | export { Language } from './Language';
24 | export { LoadingSpinnerType } from './LoadingSpinnerType';
25 | export { MarkerType } from './MarkerType';
26 | export { NotificationType } from './NotificationType';
27 | export { ParachuteLandingType, ParachuteState } from './Parachute';
28 | export { RadioStation } from './RadioStation';
29 | export { RagdollType } from './RagdollType';
30 | export { Relationship } from './Relationship';
31 | export { RopeType } from './RopeType';
32 | export { ScreenEffect } from './ScreenEffect';
33 | export { SpeechModifier } from './SpeechModifier';
34 | export {
35 | VehicleClass,
36 | VehicleColor,
37 | VehicleLandingGearState,
38 | VehicleLockStatus,
39 | VehicleNeonLight,
40 | VehicleRoofState,
41 | VehicleSeat,
42 | VehicleWindowTint,
43 | VehicleWindowIndex,
44 | VehicleModType,
45 | VehicleToggleModType,
46 | VehiclePaintType,
47 | VehicleDoorIndex,
48 | VehicleWheelType,
49 | VehicleWheelIndex,
50 | } from './Vehicle';
51 | export { Weather } from './Weather';
52 | export { ZoneID } from './ZoneID';
53 |
--------------------------------------------------------------------------------
/src/hashes/MaterialHash.ts:
--------------------------------------------------------------------------------
1 | export enum MaterialHash {
2 | None = 0x0,
3 | Unk = 0x962c3f7b,
4 | Concrete = 0x46ca81e8,
5 | ConcretePothole = 0x1567bf52,
6 | ConcreteDusty = 0xbf59b491,
7 | Tarmac = 0x10dd5498,
8 | TarmacPainted = 0xb26eefb0,
9 | TarmacPothole = 0x70726a55,
10 | RumbleStrip = 0xf116bc2d,
11 | BreezeBlock = 0xc72165d6,
12 | Rock = 0xcdeb5023,
13 | RockMossy = 0xf8902ac8,
14 | Stone = 0x2d9c1e0d,
15 | Cobblestone = 0x2257a573,
16 | Brick = 0x61b1f936,
17 | Marble = 0x73ef7697,
18 | PavingSlab = 0x71ab3fee,
19 | SandstoneSolid = 0x23500534,
20 | SandstoneBrittle = 0x7209440e,
21 | SandLoose = 0xa0ebf7e4,
22 | SandCompact = 0x1e6d775e,
23 | SandWet = 0x363cbcd5,
24 | SandTrack = 0x8e4d8aff,
25 | SandUnderwater = 0xbc4922a4,
26 | SandDryDeep = 0x1e5e7a48,
27 | SandWetDeep = 0x4ccc2aff,
28 | Ice = 0xd125aa55,
29 | IceTarmac = 0x8ce6e7d9,
30 | SnowLoose = 0x8c8308ca,
31 | SnowCompact = 0xcba23987,
32 | SnowDeep = 0x608abc80,
33 | SnowTarmac = 0x5c67c62a,
34 | GravelSmall = 0x38bbd00c,
35 | GravelLarge = 0x7edc5571,
36 | GravelDeep = 0xeabd174e,
37 | GravelTrainTrack = 0x72c668b6,
38 | DirtTrack = 0x8f9cd58f,
39 | MudHard = 0x8c31b7ea,
40 | MudPothole = 0x129eca2a,
41 | MudSoft = 0x61826e7a,
42 | MudUnderwater = 0xefb2df09,
43 | MudDeep = 0x42251dc0,
44 | Marsh = 0xd4c07e2,
45 | MarshDeep = 0x5e73a22e,
46 | Soil = 0xd63ccddb,
47 | ClayHard = 0x4434dfe7,
48 | ClaySoft = 0x216ff3f0,
49 | GrassLong = 0xe47a3e41,
50 | Grass = 0x4f747b87,
51 | GrassShort = 0xb34e900d,
52 | Hay = 0x92b69883,
53 | Bushes = 0x22ad7b72,
54 | Twigs = 0xc98f5b61,
55 | Leaves = 0x8653c6cd,
56 | Woodchips = 0xed932e53,
57 | TreeBark = 0x8dd4ebb9,
58 | MetalSolidSmall = 0xa9bc4217,
59 | MetalSolidMedium = 0xea34e8f8,
60 | MetalSolidLarge = 0x2cd49bd1,
61 | MetalHollowSmall = 0xf3b93b,
62 | MetalHollowMedium = 0x6e3dbfb8,
63 | MetalHollowLarge = 0xdd3cdcf9,
64 | MetalChainlinkSmall = 0x2d6e26cd,
65 | MetalChainlinkLarge = 0x781fa34,
66 | MetalCorrugatedIron = 0x31b80ad6,
67 | MetalGrille = 0xe699f485,
68 | MetalRailing = 0x7d368d93,
69 | MetalDuct = 0x68feb9fd,
70 | MetalGarageDoor = 0xf2373de9,
71 | MetalManhole = 0xd2ffa63d,
72 | WoodSolidSmall = 0xe82a6f1c,
73 | WoodSolidMedium = 0x2114b37d,
74 | WoodSolidLarge = 0x309f8bb7,
75 | WoodSolidPolished = 0x789c7ab,
76 | WoodFloorDusty = 0xd35443de,
77 | WoodHollowSmall = 0x76d9ac2f,
78 | WoodHollowMedium = 0xea3746bd,
79 | WoodHollowLarge = 0xc8d738e7,
80 | WoodChipboard = 0x461d0e9b,
81 | WoodOldCreaky = 0x2b13503d,
82 | WoodHighDensity = 0x981e5200,
83 | WoodLattice = 0x77e08a22,
84 | Ceramic = 0xb94a2eb5,
85 | RoofTile = 0x689e0e75,
86 | RoofFelt = 0xab87c845,
87 | Fibreglass = 0x50b728db,
88 | Tarpaulin = 0xd9b1cde0,
89 | Plastic = 0x846bc4ff,
90 | PlasticHollow = 0x25612338,
91 | PlasticHighDensity = 0x9f154729,
92 | PlasticClear = 0x9126e8cb,
93 | PlasticHollowClear = 0x2e0ecf63,
94 | PlasticHighDensityClear = 0xb038852e,
95 | FibreglassHollow = 0xd256ed46,
96 | Rubber = 0xf7503f13,
97 | RubberHollow = 0xd1461b30,
98 | Linoleum = 0x11436942,
99 | Laminate = 0x6e02c9aa,
100 | CarpetSolid = 0x27e49616,
101 | CarpetSolidDusty = 0x973ae44,
102 | CarpetFloorboard = 0xacc354b1,
103 | Cloth = 0x7519e5d,
104 | PlasterSolid = 0xddc7963f,
105 | PlasterBrittle = 0xf0fc7afe,
106 | CardboardSheet = 0xe18dff5,
107 | CardboardBox = 0xac038918,
108 | Paper = 0x1c42f3bc,
109 | Foam = 0x30341454,
110 | FeatherPillow = 0x4ffb413f,
111 | Polystyrene = 0x97476a9d,
112 | Leather = 0xddff4e0c,
113 | Tvscreen = 0x553be97c,
114 | SlattedBlinds = 0x2827cbd9,
115 | GlassShootThrough = 0x37e12a0b,
116 | GlassBulletproof = 0xe931a0e,
117 | GlassOpaque = 0x596c55d1,
118 | Perspex = 0x9f73e76c,
119 | CarMetal = 0xfa73fca1,
120 | CarPlastic = 0x7f630ae2,
121 | CarSofttop = 0xc59bc28a,
122 | CarSofttopClear = 0x7efdf110,
123 | CarGlassWeak = 0x4a57ffca,
124 | CarGlassMedium = 0x23ef48bc,
125 | CarGlassStrong = 0x3fd6150a,
126 | CarGlassBulletproof = 0x995da5e6,
127 | CarGlassOpaque = 0x1e94b2b7,
128 | Water = 0x19f81600,
129 | Blood = 0x4fe54a,
130 | Oil = 0xda2e9567,
131 | Petrol = 0x9e98536c,
132 | FreshMeat = 0x33c7d38f,
133 | DriedMeat = 0xa9dc9a13,
134 | EmissiveGlass = 0x5978a2ed,
135 | EmissivePlastic = 0x3f28abac,
136 | VfxMetalElectrified = 0xed92fc47,
137 | VfxMetalWaterTower = 0x2473b1bf,
138 | VfxMetalSteam = 0xd6cbf212,
139 | VfxMetalFlame = 0x13d5cb0d,
140 | PhysNoFriction = 0x63545f03,
141 | PhysGolfBall = 0x9b0a74ca,
142 | PhysTennisBall = 0xf0b2ff05,
143 | PhysCaster = 0xf1f990e5,
144 | PhysCasterRusty = 0x7830c8f1,
145 | PhysCarVoid = 0x50384f9d,
146 | PhysPedCapsule = 0xee9e1045,
147 | PhysElectricFence = 0xba428cab,
148 | PhysElectricMetal = 0x87f87187,
149 | PhysBarbedWire = 0xa402c0c0,
150 | PhysPooltableSurface = 0x241b6c19,
151 | PhysPooltableCushion = 0x39fde2bb,
152 | PhysPooltableBall = 0xd36536c6,
153 | Buttocks = 0x1cd01a28,
154 | ThighLeft = 0xe48cc7c1,
155 | ShinLeft = 0x26e885f4,
156 | FootLeft = 0x72d0c8e7,
157 | ThighRight = 0xf1dff3f9,
158 | ShinRight = 0xe56a0745,
159 | FootRight = 0xae64a1d4,
160 | Spine0 = 0x8d6c3adc,
161 | Spine1 = 0xbc0b421b,
162 | Spine2 = 0x56e0ca1d,
163 | Spine3 = 0x1f3c404,
164 | ClavicleLeft = 0xa8676eaf,
165 | UpperArmLeft = 0xe194cb2a,
166 | LowerArmLeft = 0x3e4a6464,
167 | HandLeft = 0x6bdcca1,
168 | ClavicleRight = 0xa32da7da,
169 | UpperArmRight = 0x5979c903,
170 | LowerArmRight = 0x69f8ee36,
171 | HandRight = 0x774441b4,
172 | Neck = 0x666b1694,
173 | Head = 0xd42acc0f,
174 | AnimalDefault = 0x110f7216,
175 | CarEngine = 0x8dbdd298,
176 | Puddle = 0x3b982e13,
177 | ConcretePavement = 0x78239b1a,
178 | BrickPavement = 0xbb9ca6d8,
179 | PhysDynamicCoverBound = 0x85f61ac9,
180 | VfxWoodBeerBarrel = 0x3b7f59ce,
181 | WoodHighFriction = 0x8070dcf9,
182 | RockNoinst = 0x79e4953,
183 | BushesNoinst = 0x55e5aaee,
184 | MetalSolidRoadSurface = 0xd48aa0f2,
185 | StuntRampSurface = 0x8388fa6c,
186 | Temp01 = 0x2c848051,
187 | Temp02 = 0x8a1a9241,
188 | Temp03 = 0x71e96559,
189 | Temp04 = 0x72add5e0,
190 | Temp05 = 0xacee6610,
191 | Temp06 = 0x3f4163f1,
192 | Temp07 = 0x96c43f1e,
193 | Temp08 = 0x5016ecd6,
194 | Temp09 = 0x3d285b19,
195 | Temp10 = 0x3c5f90a,
196 | Temp11 = 0x2d45692,
197 | Temp12 = 0x29e0c642,
198 | Temp13 = 0x9e65f2a7,
199 | Temp14 = 0xd97f800a,
200 | Temp15 = 0xa1961c15,
201 | Temp16 = 0xa5d57dd7,
202 | Temp17 = 0x3c514932,
203 | Temp18 = 0x50c38df2,
204 | Temp19 = 0xd0356f62,
205 | Temp20 = 0x85a387eb,
206 | Temp21 = 0xc2251964,
207 | Temp22 = 0xdb059fff,
208 | Temp23 = 0x1bb7608f,
209 | Temp24 = 0x750d8481,
210 | Temp25 = 0x745d8e31,
211 | Temp26 = 0xbd775456,
212 | Temp27 = 0x3500f64a,
213 | Temp28 = 0xb9af9a0e,
214 | Temp29 = 0x40475ab5,
215 | Temp30 = 0xcfebb4,
216 | }
217 |
--------------------------------------------------------------------------------
/src/hashes/WeaponHash.ts:
--------------------------------------------------------------------------------
1 | export enum WeaponHash {
2 | Knife = 2578778090,
3 | Nightstick = 1737195953,
4 | Hammer = 1317494643,
5 | Bat = 2508868239,
6 | GolfClub = 1141786504,
7 | Crowbar = 2227010557,
8 | Bottle = 4192643659,
9 | SwitchBlade = 3756226112,
10 | Pistol = 453432689,
11 | CombatPistol = 1593441988,
12 | APPistol = 584646201,
13 | Pistol50 = 2578377531,
14 | FlareGun = 1198879012,
15 | MarksmanPistol = 3696079510,
16 | Revolver = 3249783761,
17 | MicroSMG = 324215364,
18 | SMG = 736523883,
19 | AssaultSMG = 4024951519,
20 | CombatPDW = 171789620,
21 | AssaultRifle = 3220176749,
22 | CarbineRifle = 2210333304,
23 | AdvancedRifle = 2937143193,
24 | CompactRifle = 1649403952,
25 | MG = 2634544996,
26 | CombatMG = 2144741730,
27 | PumpShotgun = 487013001,
28 | SawnOffShotgun = 2017895192,
29 | AssaultShotgun = 3800352039,
30 | BullpupShotgun = 2640438543,
31 | DoubleBarrelShotgun = 4019527611,
32 | StunGun = 911657153,
33 | SniperRifle = 100416529,
34 | HeavySniper = 205991906,
35 | GrenadeLauncher = 2726580491,
36 | GrenadeLauncherSmoke = 1305664598,
37 | RPG = 2982836145,
38 | Minigun = 1119849093,
39 | Grenade = 2481070269,
40 | StickyBomb = 741814745,
41 | SmokeGrenade = 4256991824,
42 | BZGas = 2694266206,
43 | Molotov = 615608432,
44 | FireExtinguisher = 101631238,
45 | PetrolCan = 883325847,
46 | SNSPistol = 3218215474,
47 | SpecialCarbine = 3231910285,
48 | HeavyPistol = 3523564046,
49 | BullpupRifle = 2132975508,
50 | HomingLauncher = 1672152130,
51 | ProximityMine = 2874559379,
52 | Snowball = 126349499,
53 | VintagePistol = 137902532,
54 | Dagger = 2460120199,
55 | Firework = 2138347493,
56 | Musket = 2828843422,
57 | MarksmanRifle = 3342088282,
58 | HeavyShotgun = 984333226,
59 | Gusenberg = 1627465347,
60 | Hatchet = 4191993645,
61 | Railgun = 1834241177,
62 | Unarmed = 2725352035,
63 | KnuckleDuster = 3638508604,
64 | Machete = 3713923289,
65 | MachinePistol = 3675956304,
66 | Flashlight = 2343591895,
67 | Ball = 600439132,
68 | Flare = 1233104067,
69 | NightVision = 2803906140,
70 | Parachute = 4222310262,
71 | SweeperShotgun = 317205821,
72 | BattleAxe = 3441901897,
73 | CompactGrenadeLauncher = 125959754,
74 | MiniSMG = 3173288789,
75 | PipeBomb = 3125143736,
76 | PoolCue = 2484171525,
77 | Wrench = 419712736,
78 | PistolMk2 = 0xbfe256d4,
79 | AssaultRifleMk2 = 0x394f415c,
80 | CarbineRifleMk2 = 0xfad1f1c9,
81 | CombatMGMk2 = 0xdbbd7280,
82 | HeavySniperMk2 = 0xa914799,
83 | SMGMk2 = 0x78a97cd0,
84 | }
85 |
86 | export enum VehicleWeaponHash {
87 | Invalid = -1,
88 | Tank = 1945616459,
89 | SpaceRocket = -123497569,
90 | PlaneRocket = -821520672,
91 | PlayerLaser = -268631733,
92 | PlayerBullet = 1259576109,
93 | PlayerBuzzard = 1186503822,
94 | PlayerHunter = -1625648674,
95 | PlayerLazer = -494786007,
96 | EnemyLaser = 1566990507,
97 | SearchLight = -844344963,
98 | Radar = -764006018,
99 | }
100 |
101 | export enum AmmoType {
102 | Melee = 0,
103 | FireExtinguisher = 0x5106b43c,
104 | Flare = 0x6bccf76f,
105 | FlareGun = 0x45f0e965,
106 | PetrolCan = 0xca6318a1,
107 | Shotgun = 0x90083d3b,
108 | Pistol = 0x743d4f54,
109 | Ball = 0xff956666,
110 | Snowball = 0x8218416d,
111 | Sniper = 0x4c98087b,
112 | AssaultRifle = 0xd05319f,
113 | SMG = 0x6c7d23b8,
114 | Molotov = 0x5633f9d5,
115 | StunGun = 0xb02eade0,
116 | MG = 0x6aa1343f,
117 | GrenadeLauncher = 0x3bcca5ee,
118 | RPG = 0x67dd81f2,
119 | Minigun = 0x9fc5c882,
120 | Firework = 0xaf23ee0f,
121 | Railgun = 0x794446fd,
122 | HomingLauncher = 0x99150e2d,
123 | Grenade = 0x3bd313b1,
124 | StickyBomb = 0x5424b617,
125 | ProximityMine = 0xaf2208a7,
126 | PipeBomb = 0x155663f8,
127 | SmokeGrenade = 0xe60e08a6,
128 | BZGas = 0x9b747ea4,
129 | }
130 |
--------------------------------------------------------------------------------
/src/hashes/WeatherTypeHash.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * Same list as Weather enum, but as hashes.
3 | */
4 | export enum WeatherTypeHash {
5 | Unknown = -1,
6 | ExtraSunny = -1750463879,
7 | Clear = 916995460,
8 | Neutral = -1530260698,
9 | Smog = 282916021,
10 | Foggy = -1368164796,
11 | Clouds = 821931868,
12 | Overcast = -1148613331,
13 | Clearing = 1840358669,
14 | Raining = 1420204096,
15 | ThunderStorm = -1233681761,
16 | Blizzard = 669657108,
17 | Snowing = -273223690,
18 | Snowlight = 603685163,
19 | Christmas = -1429616491,
20 | Halloween = -921030142,
21 | }
22 |
--------------------------------------------------------------------------------
/src/hashes/index.ts:
--------------------------------------------------------------------------------
1 | export { MaterialHash } from './MaterialHash';
2 | export { PedHash } from './PedHash';
3 | export { VehicleHash } from './VehicleHash';
4 | export { AmmoType, WeaponHash, VehicleWeaponHash } from './WeaponHash';
5 | export { WeatherTypeHash } from './WeatherTypeHash';
6 |
--------------------------------------------------------------------------------
/src/index.ts:
--------------------------------------------------------------------------------
1 | export { Game } from './Game';
2 | export { World } from './World';
3 | export { Model } from './Model';
4 | export { Audio } from './Audio';
5 | export { Blip } from './Blip';
6 | export { Camera } from './Camera';
7 | export { Checkpoint } from './Checkpoint';
8 | export { GameplayCamera } from './GameplayCamera';
9 | export { ParticleEffect } from './ParticleEffect';
10 | export { ParticleEffectAsset } from './ParticleEffectAsset';
11 | export { RaycastResult } from './Raycast';
12 | export { RelationshipGroup } from './RelationshipGroup';
13 |
14 | // Lets export all from folders
15 | export * from './models';
16 | export * from './utils';
17 | export * from './enums';
18 | export * from './hashes';
19 | export * from './ui';
20 |
--------------------------------------------------------------------------------
/src/models/EntityBone.ts:
--------------------------------------------------------------------------------
1 | import { Vector3 } from '../utils';
2 | import { Entity } from './';
3 |
4 | export class EntityBone {
5 | public get Index(): number {
6 | return this.index;
7 | }
8 |
9 | public get Owner(): Entity {
10 | return this.owner;
11 | }
12 |
13 | public get Position(): Vector3 {
14 | const coords = GetWorldPositionOfEntityBone(this.owner.Handle, this.index);
15 | return new Vector3(coords[0], coords[1], coords[2]);
16 | }
17 |
18 | public get IsValid(): boolean {
19 | return this.owner.exists() && this.index !== -1;
20 | }
21 |
22 | protected readonly owner: Entity;
23 | protected readonly index: number;
24 |
25 | constructor(owner: Entity, boneIndex?: number, boneName?: string) {
26 | this.owner = owner;
27 | this.index = boneIndex ? boneIndex : GetEntityBoneIndexByName(this.owner.Handle, boneName);
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/models/EntityBoneCollection.ts:
--------------------------------------------------------------------------------
1 | import { Entity, EntityBone } from './';
2 |
3 | export class EntityBoneCollection {
4 | protected readonly owner: Entity;
5 |
6 | private readonly _collection: Enumerator;
7 | private _currentIndex = -1;
8 |
9 | constructor(owner: Entity) {
10 | this.owner = owner;
11 | }
12 |
13 | public hasBone(name: string): boolean {
14 | return GetEntityBoneIndexByName(this.owner.Handle, name) !== -1;
15 | }
16 |
17 | public get Core(): EntityBone {
18 | return new EntityBone(this.owner, -1);
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/src/models/PedBone.ts:
--------------------------------------------------------------------------------
1 | import { Bone } from '../enums';
2 | import { EntityBone, Ped } from './';
3 |
4 | export class PedBone extends EntityBone {
5 | constructor(owner: Ped, boneId: Bone) {
6 | super(owner, GetPedBoneIndex(owner.Handle, Number(boneId)));
7 | }
8 |
9 | public get IsValid(): boolean {
10 | return Ped.exists(this.Owner as Ped) && this.Index !== -1;
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/src/models/PedBoneCollection.ts:
--------------------------------------------------------------------------------
1 | import { EntityBoneCollection, Ped, PedBone } from './';
2 |
3 | export class PedBoneCollection extends EntityBoneCollection {
4 | constructor(owner: Ped) {
5 | super(owner);
6 | }
7 |
8 | public get Core(): PedBone {
9 | return new PedBone(this.owner as Ped, -1);
10 | }
11 |
12 | public get LastDamaged(): PedBone {
13 | // const for now until native tested
14 | const outBone = 0;
15 |
16 | // This native may be returning an object instead (bool, outBone)
17 | if (GetPedLastDamageBone(this.owner.Handle, outBone)) {
18 | return this[outBone];
19 | }
20 | }
21 |
22 | public clearLastDamaged(): void {
23 | ClearPedLastDamageBone(this.owner.Handle);
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/src/models/Player.ts:
--------------------------------------------------------------------------------
1 | import { Ped } from './';
2 |
3 | export class Player {
4 | public get Handle(): number {
5 | return this.handle;
6 | }
7 |
8 | public get Character(): Ped {
9 | const handle = GetPlayerPed(this.handle);
10 |
11 | if (typeof this.ped === 'undefined' || handle !== this.ped.Handle) {
12 | this.ped = new Ped(handle);
13 | }
14 |
15 | return this.ped;
16 | }
17 |
18 | public get Name(): string {
19 | return GetPlayerName(this.handle);
20 | }
21 |
22 | public get PvPEnabled(): boolean {
23 | return this.pvp;
24 | }
25 |
26 | public set PvPEnabled(value: boolean) {
27 | NetworkSetFriendlyFireOption(value);
28 | SetCanAttackFriendly(this.Character.Handle, value, value);
29 | this.pvp = value;
30 | }
31 |
32 | private handle: number;
33 | private ped: Ped;
34 | private pvp: boolean;
35 |
36 | constructor(handle: number) {
37 | this.handle = handle;
38 | this.PvPEnabled = true;
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/src/models/Prop.ts:
--------------------------------------------------------------------------------
1 | import { Entity } from './';
2 |
3 | export class Prop extends Entity {
4 | public static exists(prop: Prop): boolean {
5 | return typeof prop !== 'undefined' && prop.exists();
6 | }
7 |
8 | constructor(handle: number) {
9 | super(handle);
10 | }
11 |
12 | public exists(): boolean {
13 | return super.exists() && GetEntityType(this.handle) === 3;
14 | }
15 |
16 | public placeOnGround(): void {
17 | PlaceObjectOnGroundProperly(this.handle);
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/src/models/VehicleDoor.ts:
--------------------------------------------------------------------------------
1 | import { Vehicle } from './Vehicle';
2 | import { VehicleDoorIndex } from '../enums';
3 |
4 | export class VehicleDoor {
5 | private _owner: Vehicle;
6 | private _index: VehicleDoorIndex;
7 |
8 | constructor(owner: Vehicle, index: VehicleDoorIndex) {
9 | this._owner = owner;
10 | this.Index = index;
11 | }
12 |
13 | public get Index(): VehicleDoorIndex {
14 | return this._index;
15 | }
16 |
17 | public set Index(index: VehicleDoorIndex) {
18 | this._index = index;
19 | }
20 |
21 | public get AngleRatio(): number {
22 | return GetVehicleDoorAngleRatio(this._owner.Handle, this.Index);
23 | }
24 |
25 | public set AngleRatio(value: number) {
26 | SetVehicleDoorControl(this._owner.Handle, this.Index, 1, value);
27 | }
28 |
29 | public set CanBeBroken(value: boolean) {
30 | SetVehicleDoorBreakable(this._owner.Handle, this.Index, value);
31 | }
32 |
33 | public get IsOpen(): boolean {
34 | return this.AngleRatio > 0;
35 | }
36 |
37 | public get IsFullyOpen(): boolean {
38 | return !!IsVehicleDoorFullyOpen(this._owner.Handle, this.Index);
39 | }
40 |
41 | public get IsBroken(): boolean {
42 | return !!IsVehicleDoorDamaged(this._owner.Handle, this.Index);
43 | }
44 |
45 | public get Vehicle(): Vehicle {
46 | return this._owner;
47 | }
48 |
49 | public open(loose = false, instantly = false): void {
50 | SetVehicleDoorOpen(this._owner.Handle, this.Index, loose, instantly);
51 | }
52 |
53 | public close(instantly = false): void {
54 | SetVehicleDoorShut(this._owner.Handle, this.Index, instantly);
55 | }
56 |
57 | public break(stayInTheWorld = true): void {
58 | SetVehicleDoorBroken(this._owner.Handle, this.Index, stayInTheWorld);
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/src/models/VehicleDoorCollection.ts:
--------------------------------------------------------------------------------
1 | import { Vehicle } from './Vehicle';
2 | import { VehicleDoorIndex } from '../enums';
3 | import { VehicleDoor } from './VehicleDoor';
4 |
5 | export class VehicleDoorCollection {
6 | private _owner: Vehicle;
7 | private readonly _vehicleDoors: Map = new Map<
8 | VehicleDoorIndex,
9 | VehicleDoor
10 | >();
11 |
12 | constructor(owner: Vehicle) {
13 | this._owner = owner;
14 | }
15 |
16 | public getDoors(index: VehicleDoorIndex): VehicleDoor {
17 | if (!this._vehicleDoors.has(index)) {
18 | this._vehicleDoors.set(index, new VehicleDoor(this._owner, index));
19 | }
20 | return this._vehicleDoors.get(index);
21 | }
22 |
23 | public getAllDoors(): VehicleDoor[] {
24 | return Object.keys(VehicleDoorIndex)
25 | .filter(key => !isNaN(Number(key)))
26 | .map(key => {
27 | const index = Number(key);
28 | if (this.hasDoor(index)) {
29 | return this.getDoors(index);
30 | }
31 | return null;
32 | })
33 | .filter(d => d);
34 | }
35 |
36 | public openAllDoors(loose?: boolean, instantly?: boolean): void {
37 | this.getAllDoors().forEach(door => {
38 | door.open(loose, instantly);
39 | });
40 | }
41 |
42 | public closeAllDoors(instantly?: boolean): void {
43 | this.getAllDoors().forEach(door => {
44 | door.close(instantly);
45 | });
46 | }
47 |
48 | public breakAllDoors(stayInTheWorld?: boolean): void {
49 | this.getAllDoors().forEach(door => {
50 | door.break(stayInTheWorld);
51 | });
52 | }
53 |
54 | public hasDoor(index: VehicleDoorIndex): boolean {
55 | switch (index) {
56 | case VehicleDoorIndex.FrontLeftDoor:
57 | return this._owner.Bones.hasBone('door_dside_f');
58 | case VehicleDoorIndex.FrontRightDoor:
59 | return this._owner.Bones.hasBone('door_pside_f');
60 | case VehicleDoorIndex.BackLeftDoor:
61 | return this._owner.Bones.hasBone('door_dside_r');
62 | case VehicleDoorIndex.BackRightDoor:
63 | return this._owner.Bones.hasBone('door_pside_r');
64 | case VehicleDoorIndex.Hood:
65 | return this._owner.Bones.hasBone('bonnet');
66 | case VehicleDoorIndex.Trunk:
67 | return this._owner.Bones.hasBone('boot');
68 | }
69 | return false;
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/src/models/VehicleMod.ts:
--------------------------------------------------------------------------------
1 | import { Vehicle } from './Vehicle';
2 | import { VehicleModType } from '../enums';
3 |
4 | export class VehicleMod {
5 | private _owner: Vehicle;
6 | private _modType: VehicleModType;
7 |
8 | constructor(owner: Vehicle, modType: VehicleModType) {
9 | this._owner = owner;
10 | this.ModType = modType;
11 | }
12 |
13 | public get ModType(): VehicleModType {
14 | return this._modType;
15 | }
16 |
17 | public set ModType(modType: VehicleModType) {
18 | this._modType = modType;
19 | }
20 |
21 | public get Index(): number {
22 | return GetVehicleMod(this._owner.Handle, this.ModType);
23 | }
24 |
25 | public set Index(value: number) {
26 | SetVehicleMod(this._owner.Handle, this.ModType, value, this.Variation);
27 | }
28 |
29 | public get Variation(): boolean {
30 | return !!GetVehicleModVariation(this._owner.Handle, this.ModType);
31 | }
32 |
33 | public set Variation(value: boolean) {
34 | SetVehicleMod(this._owner.Handle, this.ModType, this.Index, value);
35 | }
36 |
37 | public get ModCount(): number {
38 | return GetNumVehicleMods(this._owner.Handle, this.ModType);
39 | }
40 |
41 | public get Vehicle(): Vehicle {
42 | return this._owner;
43 | }
44 |
45 | public remove(): void {
46 | RemoveVehicleMod(this._owner.Handle, this.ModType);
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/src/models/VehicleToggleMod.ts:
--------------------------------------------------------------------------------
1 | import { Vehicle } from './Vehicle';
2 | import { VehicleToggleModType } from '../enums';
3 |
4 | export class VehicleToggleMod {
5 | private _owner: Vehicle;
6 | private _modType: VehicleToggleModType;
7 |
8 | constructor(owner: Vehicle, modType: VehicleToggleModType) {
9 | this._owner = owner;
10 | this.ModType = modType;
11 | }
12 |
13 | public get ModType(): VehicleToggleModType {
14 | return this._modType;
15 | }
16 |
17 | public set ModType(modType: VehicleToggleModType) {
18 | this._modType = modType;
19 | }
20 |
21 | public get IsInstalled(): boolean {
22 | return !!IsToggleModOn(this._owner.Handle, this.ModType);
23 | }
24 |
25 | public set IsInstalled(value: boolean) {
26 | ToggleVehicleMod(this._owner.Handle, this.ModType, value);
27 | }
28 |
29 | public get LocalizedModTypeName(): string {
30 | return GetModSlotName(this._owner.Handle, this.ModType);
31 | }
32 |
33 | public get Vehicle(): Vehicle {
34 | return this._owner;
35 | }
36 |
37 | public remove(): void {
38 | RemoveVehicleMod(this._owner.Handle, this.ModType);
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/src/models/VehicleWheel.ts:
--------------------------------------------------------------------------------
1 | import { Vehicle } from './Vehicle';
2 |
3 | export class VehicleWheel {
4 | private _owner: Vehicle;
5 | private _index: number;
6 |
7 | constructor(owner: Vehicle, index: number) {
8 | this._owner = owner;
9 | this.Index = index;
10 | }
11 |
12 | public get Index(): number {
13 | return this._index;
14 | }
15 |
16 | public set Index(index: number) {
17 | this._index = index;
18 | }
19 |
20 | public get Vehicle(): Vehicle {
21 | return this._owner;
22 | }
23 |
24 | public burst(): void {
25 | SetVehicleTyreBurst(this._owner.Handle, this.Index, true, 1000);
26 | }
27 |
28 | public fix(): void {
29 | SetVehicleTyreFixed(this._owner.Handle, this.Index);
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/src/models/VehicleWheelCollection.ts:
--------------------------------------------------------------------------------
1 | import { Vehicle } from './Vehicle';
2 | import { VehicleWheel } from './VehicleWheel';
3 | import { VehicleWheelIndex } from '../enums';
4 |
5 | export class VehicleWheelCollection {
6 | private _owner: Vehicle;
7 | private readonly _vehicleWheels: Map = new Map();
8 |
9 | constructor(owner: Vehicle) {
10 | this._owner = owner;
11 | }
12 |
13 | public getWheel(index: VehicleWheelIndex): VehicleWheel {
14 | if (!this._vehicleWheels.has(index)) {
15 | this._vehicleWheels.set(index, new VehicleWheel(this._owner, index));
16 | }
17 | return this._vehicleWheels.get(index);
18 | }
19 |
20 | public getAllWheels(): VehicleWheel[] {
21 | return Object.keys(VehicleWheelIndex)
22 | .filter(key => !isNaN(Number(key)))
23 | .map(key => {
24 | const index = Number(key);
25 | if (this.hasWheel(index)) {
26 | return this.getWheel(index);
27 | }
28 | return null;
29 | })
30 | .filter(w => w);
31 | }
32 |
33 | public burstAllWheels(): void {
34 | this.getAllWheels().forEach(wheel => {
35 | wheel.burst();
36 | });
37 | }
38 |
39 | public fixAllWheels(): void {
40 | this.getAllWheels().forEach(wheel => {
41 | wheel.fix();
42 | });
43 | }
44 |
45 | public hasWheel(wheel: VehicleWheelIndex): boolean {
46 | switch (wheel) {
47 | case VehicleWheelIndex.FrontLeftWheel:
48 | return this._owner.Bones.hasBone('wheel_lf');
49 | case VehicleWheelIndex.FrontRightWheel:
50 | return this._owner.Bones.hasBone('wheel_rf');
51 | case VehicleWheelIndex.MidLeftWheel:
52 | return this._owner.Bones.hasBone('wheel_lm');
53 | case VehicleWheelIndex.MidRightWheel:
54 | return this._owner.Bones.hasBone('wheel_rm');
55 | case VehicleWheelIndex.RearLeftWheel:
56 | return this._owner.Bones.hasBone('wheel_lr');
57 | case VehicleWheelIndex.RearRightWheel:
58 | return this._owner.Bones.hasBone('wheel_rr');
59 | default:
60 | return false;
61 | }
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/src/models/VehicleWindow.ts:
--------------------------------------------------------------------------------
1 | import { Vehicle } from './Vehicle';
2 | import { VehicleWindowIndex } from '../enums';
3 |
4 | export class VehicleWindow {
5 | private _owner: Vehicle;
6 | private _index: VehicleWindowIndex;
7 |
8 | constructor(owner: Vehicle, index: VehicleWindowIndex) {
9 | this._owner = owner;
10 | this.Index = index;
11 | }
12 |
13 | public get Index(): VehicleWindowIndex {
14 | return this._index;
15 | }
16 |
17 | public set Index(index: VehicleWindowIndex) {
18 | this._index = index;
19 | }
20 |
21 | public get IsIntact(): boolean {
22 | return !!IsVehicleWindowIntact(this._owner.Handle, this.Index);
23 | }
24 |
25 | public get Vehicle(): Vehicle {
26 | return this._owner;
27 | }
28 |
29 | public repair(): void {
30 | FixVehicleWindow(this._owner.Handle, this.Index);
31 | }
32 |
33 | public smash(): void {
34 | SmashVehicleWindow(this._owner.Handle, this.Index);
35 | }
36 |
37 | public rollUp(): void {
38 | RollUpWindow(this._owner.Handle, this.Index);
39 | }
40 |
41 | public rollDown(): void {
42 | RollDownWindow(this._owner.Handle, this.Index);
43 | }
44 |
45 | public remove(): void {
46 | RemoveVehicleWindow(this._owner.Handle, this.Index);
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/src/models/VehicleWindowCollection.ts:
--------------------------------------------------------------------------------
1 | import { Vehicle } from './Vehicle';
2 | import { VehicleWindowIndex } from '../enums';
3 | import { VehicleWindow } from './VehicleWindow';
4 |
5 | export class VehicleWindowCollection {
6 | private _owner: Vehicle;
7 | private readonly _vehicleWindows: Map = new Map<
8 | VehicleWindowIndex,
9 | VehicleWindow
10 | >();
11 |
12 | constructor(owner: Vehicle) {
13 | this._owner = owner;
14 | }
15 |
16 | public getWindow(index: VehicleWindowIndex): VehicleWindow {
17 | if (!this._vehicleWindows.has(index)) {
18 | this._vehicleWindows.set(index, new VehicleWindow(this._owner, index));
19 | }
20 | return this._vehicleWindows.get(index);
21 | }
22 |
23 | public getAllWindows(): VehicleWindow[] {
24 | return Object.keys(VehicleWindowIndex)
25 | .filter(key => !isNaN(Number(key)))
26 | .map(key => {
27 | const index = Number(key);
28 | if (this.hasWindow(index)) {
29 | return this.getWindow(index);
30 | }
31 | return null;
32 | })
33 | .filter(w => w);
34 | }
35 |
36 | public get AreAllWindowsIntact(): boolean {
37 | return !!AreAllVehicleWindowsIntact(this._owner.Handle);
38 | }
39 |
40 | public rollDownAllWindows(): void {
41 | this.getAllWindows().forEach(window => {
42 | window.rollDown();
43 | });
44 | }
45 |
46 | public rollUpAllWindows(): void {
47 | this.getAllWindows().forEach(window => {
48 | window.rollUp();
49 | });
50 | }
51 |
52 | public hasWindow(window: VehicleWindowIndex): boolean {
53 | switch (window) {
54 | case VehicleWindowIndex.FrontLeftWindow:
55 | return this._owner.Bones.hasBone('window_lf');
56 | case VehicleWindowIndex.FrontRightWindow:
57 | return this._owner.Bones.hasBone('window_rf');
58 | case VehicleWindowIndex.BackLeftWindow:
59 | return this._owner.Bones.hasBone('window_lr');
60 | case VehicleWindowIndex.BackRightWindow:
61 | return this._owner.Bones.hasBone('window_rr');
62 | default:
63 | return false;
64 | }
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/src/models/index.ts:
--------------------------------------------------------------------------------
1 | export { Entity } from './Entity';
2 | export { EntityBone } from './EntityBone';
3 | export { EntityBoneCollection } from './EntityBoneCollection';
4 | export { Ped } from './Ped';
5 | export { PedBone } from './PedBone';
6 | export { PedBoneCollection } from './PedBoneCollection';
7 | export { Player } from './Player';
8 | export { Prop } from './Prop';
9 | export { Vehicle } from './Vehicle';
10 | export { VehicleDoor } from './VehicleDoor';
11 | export { VehicleDoorCollection } from './VehicleDoorCollection';
12 | export { VehicleMod } from './VehicleMod';
13 | export { VehicleToggleMod } from './VehicleToggleMod';
14 | export { VehicleModCollection } from './VehicleModCollection';
15 | export { VehicleWheel } from './VehicleWheel';
16 | export { VehicleWheelCollection } from './VehicleWheelCollection';
17 | export { VehicleWindow } from './VehicleWindow';
18 | export { VehicleWindowCollection } from './VehicleWindowCollection';
19 |
--------------------------------------------------------------------------------
/src/ui/Container.ts:
--------------------------------------------------------------------------------
1 | import { Color, Point, Size } from '../utils';
2 | import { IDrawable, Screen } from './';
3 |
4 | export class Container implements IDrawable {
5 | public pos: Point;
6 | public size: Size;
7 | public color: Color;
8 | public items: IDrawable[] = [];
9 |
10 | constructor(pos: Point, size: Size, color: Color) {
11 | this.pos = pos;
12 | this.size = size;
13 | this.color = color;
14 | }
15 |
16 | public addItem(items: IDrawable | IDrawable[]): void {
17 | if (!Array.isArray(items)) {
18 | items = [items];
19 | }
20 | this.items.push(...items);
21 | }
22 |
23 | public draw(offset?: Size, resolution?: Size): void {
24 | resolution = resolution || new Size(Screen.ScaledWidth, Screen.Height);
25 | offset = offset || new Size();
26 |
27 | const w = this.size.width / resolution.width;
28 | const h = this.size.height / resolution.height;
29 | const x = (this.pos.X + offset.width) / resolution.width + w * 0.5;
30 | const y = (this.pos.Y + offset.height) / resolution.height + h * 0.5;
31 |
32 | DrawRect(x, y, w, h, this.color.r, this.color.g, this.color.b, this.color.a);
33 |
34 | for (const item of this.items) {
35 | item.draw(new Size(this.pos.X + offset.width, this.pos.Y + offset.height), resolution);
36 | }
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/src/ui/Effects.ts:
--------------------------------------------------------------------------------
1 | import { ScreenEffect } from '../enums';
2 |
3 | export abstract class Effects {
4 | public static start(effectName: ScreenEffect, duration = 0, looped = false): void {
5 | StartScreenEffect(this.effectToString(effectName), duration, looped);
6 | }
7 |
8 | public static stop(screenEffect?: ScreenEffect): void {
9 | if (typeof screenEffect === 'undefined') {
10 | StopAllScreenEffects();
11 | } else {
12 | StopScreenEffect(this.effectToString(screenEffect));
13 | }
14 | }
15 |
16 | public static isActive(screenEffect: ScreenEffect): boolean {
17 | return !!GetScreenEffectIsActive(this.effectToString(screenEffect));
18 | }
19 |
20 | private static readonly effects: string[] = [
21 | 'SwitchHUDIn',
22 | 'SwitchHUDOut',
23 | 'FocusIn',
24 | 'FocusOut',
25 | 'MinigameEndNeutral',
26 | 'MinigameEndTrevor',
27 | 'MinigameEndFranklin',
28 | 'MinigameEndMichael',
29 | 'MinigameTransitionOut',
30 | 'MinigameTransitionIn',
31 | 'SwitchShortNeutralIn',
32 | 'SwitchShortFranklinIn',
33 | 'SwitchShortTrevorIn',
34 | 'SwitchShortMichaelIn',
35 | 'SwitchOpenMichaelIn',
36 | 'SwitchOpenFranklinIn',
37 | 'SwitchOpenTrevorIn',
38 | 'SwitchHUDMichaelOut',
39 | 'SwitchHUDFranklinOut',
40 | 'SwitchHUDTrevorOut',
41 | 'SwitchShortFranklinMid',
42 | 'SwitchShortMichaelMid',
43 | 'SwitchShortTrevorMid',
44 | 'DeathFailOut',
45 | 'CamPushInNeutral',
46 | 'CamPushInFranklin',
47 | 'CamPushInMichael',
48 | 'CamPushInTrevor',
49 | 'SwitchSceneFranklin',
50 | 'SwitchSceneTrevor',
51 | 'SwitchSceneMichael',
52 | 'SwitchSceneNeutral',
53 | 'MP_Celeb_Win',
54 | 'MP_Celeb_Win_Out',
55 | 'MP_Celeb_Lose',
56 | 'MP_Celeb_Lose_Out',
57 | 'DeathFailNeutralIn',
58 | 'DeathFailMPDark',
59 | 'DeathFailMPIn',
60 | 'MP_Celeb_Preload_Fade',
61 | 'PeyoteEndOut',
62 | 'PeyoteEndIn',
63 | 'PeyoteIn',
64 | 'PeyoteOut',
65 | 'MP_race_crash',
66 | 'SuccessFranklin',
67 | 'SuccessTrevor',
68 | 'SuccessMichael',
69 | 'DrugsMichaelAliensFightIn',
70 | 'DrugsMichaelAliensFight',
71 | 'DrugsMichaelAliensFightOut',
72 | 'DrugsTrevorClownsFightIn',
73 | 'DrugsTrevorClownsFight',
74 | 'DrugsTrevorClownsFightOut',
75 | 'HeistCelebPass',
76 | 'HeistCelebPassBW',
77 | 'HeistCelebEnd',
78 | 'HeistCelebToast',
79 | 'MenuMGHeistIn',
80 | 'MenuMGTournamentIn',
81 | 'MenuMGSelectionIn',
82 | 'ChopVision',
83 | 'DMT_flight_intro',
84 | 'DMT_flight',
85 | 'DrugsDrivingIn',
86 | 'DrugsDrivingOut',
87 | 'SwitchOpenNeutralFIB5',
88 | 'HeistLocate',
89 | 'MP_job_load',
90 | 'RaceTurbo',
91 | 'MP_intro_logo',
92 | 'HeistTripSkipFade',
93 | 'MenuMGHeistOut',
94 | 'MP_corona_switch',
95 | 'MenuMGSelectionTint',
96 | 'SuccessNeutral',
97 | 'ExplosionJosh3',
98 | 'SniperOverlay',
99 | 'RampageOut',
100 | 'Rampage',
101 | 'Dont_tazeme_bro',
102 | ];
103 |
104 | private static effectToString(screenEffect: ScreenEffect): string {
105 | const effect = Number(screenEffect);
106 | if (effect >= 0 && effect <= this.effects.length) {
107 | return this.effects[effect];
108 | }
109 | return 'INVALID';
110 | }
111 | }
112 |
--------------------------------------------------------------------------------
/src/ui/Fading.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * Static class for screen fading
3 | */
4 | export abstract class Fading {
5 | /**
6 | * Gets whether the screen is faded in
7 | *
8 | * @returns True or false
9 | */
10 | public static get IsFadedIn(): boolean {
11 | return !!IsScreenFadedIn();
12 | }
13 |
14 | /**
15 | * Gets whether the screen is faded out
16 | *
17 | * @returns True or false
18 | */
19 | public static get IsFadedOut(): boolean {
20 | return !!IsScreenFadedOut();
21 | }
22 |
23 | /**
24 | * Gets whether the screen is currently fading in
25 | *
26 | * @returns True or false
27 | */
28 | public static get IsFadingIn(): boolean {
29 | return !!IsScreenFadingIn();
30 | }
31 |
32 | /**
33 | * Gets whether the screen is currently fading out
34 | *
35 | * @returns True or false
36 | */
37 | public static get IsFadingOut(): boolean {
38 | return !!IsScreenFadingOut();
39 | }
40 |
41 | /**
42 | * Fade in the screen for a certain duration.
43 | *
44 | * @param duration Time to fade in
45 | */
46 | public static fadeIn(duration: number): Promise {
47 | return new Promise(resolve => {
48 | DoScreenFadeIn(duration);
49 |
50 | const interval = setInterval(() => {
51 | if (this.IsFadedIn) {
52 | clearInterval(interval);
53 | resolve();
54 | }
55 | }, 0);
56 | });
57 | }
58 |
59 | /**
60 | * Fade out the screen for a certain duration.
61 | *
62 | * @param duration Time to fade out
63 | */
64 | public static fadeOut(duration: number): Promise {
65 | return new Promise(resolve => {
66 | DoScreenFadeOut(duration);
67 |
68 | const interval = setInterval(() => {
69 | if (this.IsFadedOut) {
70 | clearInterval(interval);
71 | resolve();
72 | }
73 | }, 0);
74 | });
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/src/ui/Hud.ts:
--------------------------------------------------------------------------------
1 | import { CursorSprite, HudComponent } from '../enums';
2 | import { Point } from '../utils';
3 |
4 | export abstract class Hud {
5 | public static isComponentActive(component: HudComponent): boolean {
6 | return !!IsHudComponentActive(Number(component));
7 | }
8 |
9 | public static showComponentThisFrame(component: HudComponent): void {
10 | ShowHudComponentThisFrame(Number(component));
11 | }
12 |
13 | public static hideComponentThisFrame(component: HudComponent): void {
14 | HideHudComponentThisFrame(Number(component));
15 | }
16 |
17 | public static showCursorThisFrame(): void {
18 | ShowCursorThisFrame();
19 | }
20 |
21 | public static set CursorPosition(position: Point) {
22 | SetCursorLocation(position.X, position.Y);
23 | }
24 |
25 | public static get CursorSprite(): CursorSprite {
26 | return CursorSprite.DownArrow;
27 | }
28 |
29 | public static set CursorSprite(sprite: CursorSprite) {
30 | SetCursorSprite(Number(sprite));
31 | }
32 |
33 | public static get IsVisible(): boolean {
34 | return !(IsHudHidden() || !IsHudPreferenceSwitchedOn());
35 | }
36 |
37 | public static set IsVisible(toggle: boolean) {
38 | DisplayHud(toggle);
39 | }
40 |
41 | public static get IsRadarVisible(): boolean {
42 | return !(IsRadarHidden() || IsRadarPreferenceSwitchedOn());
43 | }
44 |
45 | public static set IsRadarVisible(toggle: boolean) {
46 | DisplayRadar(toggle);
47 | }
48 |
49 | public static set RadarZoom(zoomLevel: number) {
50 | SetRadarZoom(zoomLevel);
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/src/ui/LoadingPrompt.ts:
--------------------------------------------------------------------------------
1 | import { LoadingSpinnerType } from '../enums';
2 |
3 | /**
4 | * Show and hide loading prompt on the bottom right of the screen.
5 | *
6 | * Example:
7 | *
8 | * ```typescript
9 | * import { LoadingPrompt } from 'fivem-js/ui';
10 | *
11 | * LoadingPrompt.show("Hello World");
12 | *
13 | * setTimeout(() => {
14 | * LoadingPrompt.hide();
15 | * }, 10000)'
16 | * ```
17 | */
18 | export abstract class LoadingPrompt {
19 | /**
20 | * Shows a loading prompt.
21 | *
22 | * @param loadingText Text to be displayed inside loading prompt.
23 | * @param spinnerType Type of spinner.
24 | */
25 | public static show(
26 | loadingText: string = null,
27 | spinnerType: LoadingSpinnerType = LoadingSpinnerType.RegularClockwise,
28 | ): void {
29 | if (this.IsActive) {
30 | this.hide();
31 | }
32 |
33 | if (loadingText === null) {
34 | BeginTextCommandBusyString(null);
35 | } else {
36 | BeginTextCommandBusyString('STRING');
37 | AddTextComponentSubstringPlayerName(loadingText);
38 | }
39 |
40 | EndTextCommandBusyString(Number(spinnerType));
41 | }
42 |
43 | public static hide(): void {
44 | if (this.IsActive) {
45 | RemoveLoadingPrompt();
46 | }
47 | }
48 |
49 | public static get IsActive(): boolean {
50 | return !!IsLoadingPromptBeingDisplayed();
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/src/ui/Notification.ts:
--------------------------------------------------------------------------------
1 | export class Notification {
2 | private handle: number;
3 |
4 | constructor(handle: number) {
5 | this.handle = handle;
6 | }
7 |
8 | public hide(): void {
9 | RemoveNotification(this.handle);
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/src/ui/Rectangle.ts:
--------------------------------------------------------------------------------
1 | import { Color, Point, Size } from '../utils';
2 | import { IDrawable, Screen } from './';
3 |
4 | export class Rectangle implements IDrawable {
5 | public pos: Point;
6 | public size: Size;
7 | public color: Color;
8 |
9 | constructor(pos: Point, size: Size, color: Color) {
10 | this.pos = pos;
11 | this.size = size;
12 | this.color = color;
13 | }
14 |
15 | public draw(offset?: Size, resolution?: Size): void;
16 | public draw(pos: Point, size: Size, color: Color, resolution?: Size): void;
17 | public draw(arg1?: Point | Size, arg2?: Size, color?: Color, resolution?: Size): void {
18 | resolution = color === undefined ? arg2 : resolution;
19 | resolution = resolution || new Size(Screen.ScaledWidth, Screen.Height);
20 |
21 | if (color === undefined) {
22 | if (arg1 && arg1 instanceof Size) {
23 | arg1 = new Point(this.pos.X + arg1.width, this.pos.Y + arg1.height);
24 | } else {
25 | arg1 = this.pos;
26 | }
27 | arg2 = this.size;
28 | } else {
29 | if (!arg1) {
30 | arg1 = this.pos;
31 | } else {
32 | arg1 = arg1 as Point;
33 | }
34 | arg2 = arg2 || this.size;
35 | }
36 |
37 | color = color || this.color;
38 |
39 | const w = arg2.width / resolution.width;
40 | const h = arg2.height / resolution.height;
41 | const x = arg1.X / resolution.width + w * 0.5;
42 | const y = arg1.Y / resolution.height + h * 0.5;
43 |
44 | DrawRect(x, y, w, h, color.r, color.g, color.b, color.a);
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/src/ui/Scaleform.ts:
--------------------------------------------------------------------------------
1 | import { PointF, Vector3 } from '../utils';
2 |
3 | /**
4 | * Scaleforms will automatically load when calling any of the render functions.
5 | *
6 | * Example:
7 | *
8 | * ```typescript
9 | * import { Scaleform } from 'fivem-js/ui';
10 | *
11 | * const scaleform = new Cfx.Scaleform("MIDSIZED_MESSAGE");
12 | *
13 | * scaleform.callFunction("SHOW_MIDSIZED_MESSAGE", ["Title", "Message"]);
14 | *
15 | * setTick(() => {
16 | * await scaleform.render2D();
17 | * });
18 | * ```
19 | */
20 | export class Scaleform {
21 | public static render2DMasked(scaleform1: Scaleform, scaleform2: Scaleform): Promise {
22 | return new Promise(async resolve => {
23 | if (scaleform1.IsLoaded && scaleform2.IsLoaded) {
24 | DrawScaleformMovieFullscreenMasked(
25 | scaleform1.Handle,
26 | scaleform2.Handle,
27 | 255,
28 | 255,
29 | 255,
30 | 255,
31 | );
32 | } else {
33 | await scaleform1.load();
34 | await scaleform2.load();
35 | }
36 | resolve();
37 | });
38 | }
39 |
40 | protected handle: number;
41 | protected name: string;
42 | protected loaded: boolean;
43 |
44 | constructor(name: string) {
45 | this.name = name;
46 | this.handle = RequestScaleformMovie(this.name);
47 | }
48 |
49 | /**
50 | * Get the handle of the scaleform.
51 | */
52 | public get Handle(): number {
53 | return this.handle;
54 | }
55 |
56 | /**
57 | * Get whether the handle is a valid handle.
58 | */
59 | public get IsValid(): boolean {
60 | return this.handle !== 0;
61 | }
62 |
63 | /**
64 | * Get whether the scaleform is loaded.
65 | */
66 | public get IsLoaded(): boolean {
67 | if (!this.loaded) {
68 | this.loaded = !!HasScaleformMovieLoaded(this.handle);
69 | }
70 |
71 | return this.loaded;
72 | }
73 |
74 | /**
75 | * Dispose the scaleform allowing the GTA engine to free memory when wanted.
76 | */
77 | public dispose(): void {
78 | if (this.IsLoaded) {
79 | SetScaleformMovieAsNoLongerNeeded(this.handle);
80 | this.loaded = false;
81 | }
82 | }
83 |
84 | /**
85 | * Call a function on the scaleform.
86 | *
87 | * @param name Name of the function
88 | * @param args Additional arguments
89 | */
90 | public callFunction(name: string, ...args: unknown[]): void {
91 | BeginScaleformMovieMethod(this.handle, name);
92 | args.forEach(arg => {
93 | switch (typeof arg) {
94 | case 'number':
95 | PushScaleformMovieFunctionParameterInt(arg);
96 | break;
97 | case 'string':
98 | PushScaleformMovieFunctionParameterString(arg);
99 | break;
100 | case 'boolean':
101 | PushScaleformMovieFunctionParameterBool(arg);
102 | break;
103 | default:
104 | throw new Error(
105 | `Unknown argument type [${typeof arg}] passed to scaleform with handle [${
106 | this.handle
107 | }]`,
108 | );
109 | }
110 | });
111 | EndScaleformMovieMethod();
112 | }
113 |
114 | /**
115 | * Sets a duration the scaleform should be shown.
116 | * Useful for showing a scaleform for a known amount of time, such as messages.
117 | *
118 | * This only works for any scaleform using {@linkcode render2D};
119 | *
120 | * @param duration Duration in milliseconds
121 | */
122 | public setDuration(duration: number): void {
123 | if (duration <= 0) {
124 | return;
125 | }
126 |
127 | const start = GetGameTimer();
128 | const interval = setInterval(async () => {
129 | if (GetGameTimer() - start < duration) {
130 | await this.render2D();
131 | } else {
132 | clearInterval(interval);
133 | }
134 | }, 0);
135 | }
136 |
137 | public render2D(): Promise {
138 | return new Promise(async resolve => {
139 | if (this.IsLoaded) {
140 | DrawScaleformMovieFullscreen(this.handle, 255, 255, 255, 255, 0);
141 | } else {
142 | await this.load();
143 | }
144 | resolve();
145 | });
146 | }
147 |
148 | public render2DScreenSpace(location: PointF, size: PointF): Promise {
149 | return new Promise(async resolve => {
150 | if (this.IsLoaded) {
151 | const x = location.x; /* UI.Screen.Width*/
152 | const y = location.y; /* UI.Screen.Height*/
153 | const width = size.x; /* UI.Screen.Width*/
154 | const height = size.y; /* UI.Screen.Height*/
155 |
156 | DrawScaleformMovie(
157 | this.handle,
158 | x + width / 2,
159 | y + height / 2,
160 | width,
161 | height,
162 | 255,
163 | 255,
164 | 255,
165 | 255,
166 | 0,
167 | );
168 | } else {
169 | await this.load();
170 | }
171 | resolve();
172 | });
173 | }
174 |
175 | public render3D(position: Vector3, rotation: Vector3, scale: Vector3): Promise {
176 | return new Promise(async resolve => {
177 | if (this.IsLoaded) {
178 | DrawScaleformMovie_3dNonAdditive(
179 | this.handle,
180 | position.x,
181 | position.y,
182 | position.z,
183 | rotation.x,
184 | rotation.y,
185 | rotation.z,
186 | 2,
187 | 2,
188 | 1,
189 | scale.x,
190 | scale.y,
191 | scale.z,
192 | 2,
193 | );
194 | } else {
195 | await this.load();
196 | }
197 | resolve();
198 | });
199 | }
200 |
201 | public render3DAdditive(position: Vector3, rotation: Vector3, scale: Vector3): Promise {
202 | return new Promise(async resolve => {
203 | if (this.IsLoaded) {
204 | DrawScaleformMovie_3d(
205 | this.handle,
206 | position.x,
207 | position.y,
208 | position.z,
209 | rotation.x,
210 | rotation.y,
211 | rotation.z,
212 | 2,
213 | 2,
214 | 1,
215 | scale.x,
216 | scale.y,
217 | scale.z,
218 | 2,
219 | );
220 | } else {
221 | await this.load();
222 | }
223 | resolve();
224 | });
225 | }
226 |
227 | public load(): Promise {
228 | return new Promise(resolve => {
229 | if (this.IsLoaded) {
230 | resolve(true);
231 | } else {
232 | const start = GetGameTimer();
233 | const interval = setInterval(() => {
234 | if (this.IsLoaded) {
235 | clearInterval(interval);
236 | resolve(true);
237 | } else if (GetGameTimer() - start > 5000) {
238 | clearInterval(interval);
239 | console.log(`^1[fivem-js] Could not load scaleform ${this.name}!^7`);
240 | resolve(false);
241 | }
242 | }, 0);
243 | }
244 | });
245 | }
246 | }
247 |
--------------------------------------------------------------------------------
/src/ui/Screen.ts:
--------------------------------------------------------------------------------
1 | import { Audio } from '../Audio';
2 | import { HudColor, NotificationType } from '../enums';
3 | import { Color, PointF, Size, stringToArray, Vector3 } from '../utils';
4 | import { Notification } from './';
5 |
6 | export abstract class Screen {
7 | public static get Resolution(): Size {
8 | const [width, height] = GetScreenActiveResolution();
9 | return new Size(width, height);
10 | }
11 |
12 | public static get ScaledResolution(): Size {
13 | const height = this.Height;
14 | return new Size(height * this.AspectRatio, height);
15 | }
16 |
17 | public static get Width(): number {
18 | return this.Resolution.width;
19 | }
20 |
21 | public static get ScaledWidth(): number {
22 | return this.Height * this.AspectRatio;
23 | }
24 |
25 | public static get Height(): number {
26 | return this.Resolution.height;
27 | }
28 |
29 | public static get AspectRatio(): number {
30 | return GetAspectRatio(false);
31 | }
32 |
33 | public static showSubtitle(message: string, duration = 2500): void {
34 | const strings: string[] = stringToArray(message);
35 |
36 | BeginTextCommandPrint('CELL_EMAIL_BCON');
37 |
38 | strings.forEach(element => {
39 | AddTextComponentSubstringPlayerName(element);
40 | });
41 |
42 | EndTextCommandPrint(duration, true);
43 | }
44 |
45 | public static displayHelpTextThisFrame(message: string): void {
46 | const strings: string[] = stringToArray(message);
47 |
48 | BeginTextCommandDisplayHelp('CELL_EMAIL_BCON');
49 |
50 | strings.forEach(element => {
51 | AddTextComponentSubstringPlayerName(element);
52 | });
53 |
54 | EndTextCommandDisplayHelp(0, false, false, -1);
55 | }
56 |
57 | public static showNotification(message: string, blinking = false): Notification {
58 | const strings: string[] = stringToArray(message);
59 |
60 | SetNotificationTextEntry('CELL_EMAIL_BCON');
61 |
62 | strings.forEach(element => {
63 | AddTextComponentSubstringPlayerName(element);
64 | });
65 |
66 | return new Notification(DrawNotification(blinking, true));
67 | }
68 |
69 | public static showAdvancedNotification(
70 | message: string,
71 | title: string,
72 | subtitle: string,
73 | iconSet: string,
74 | icon: string,
75 | bgColor: HudColor = HudColor.NONE,
76 | flashColor: Color = Color.empty,
77 | blinking = false,
78 | type: NotificationType = NotificationType.Default,
79 | showInBrief = true,
80 | sound = true,
81 | ): Notification {
82 | const strings: string[] = stringToArray(message);
83 |
84 | SetNotificationTextEntry('CELL_EMAIL_BCON');
85 |
86 | strings.forEach(element => {
87 | AddTextComponentSubstringPlayerName(element);
88 | });
89 |
90 | if (bgColor !== HudColor.NONE) {
91 | SetNotificationBackgroundColor(Number(bgColor));
92 | }
93 |
94 | if (flashColor !== Color.empty && blinking) {
95 | SetNotificationFlashColor(flashColor.r, flashColor.g, flashColor.b, flashColor.a);
96 | }
97 |
98 | if (sound) {
99 | Audio.playSoundFrontEnd('DELETE', 'HUD_DEATHMATCH_SOUNDSET');
100 | }
101 |
102 | SetNotificationMessage(iconSet, icon, true, Number(type), title, subtitle);
103 | return new Notification(DrawNotification(blinking, showInBrief));
104 | }
105 |
106 | public static worldToScreen(position: Vector3, scaleWidth = false): PointF {
107 | const coords = GetScreenCoordFromWorldCoord(position.x, position.y, position.z);
108 | return new PointF(
109 | coords[0] * (scaleWidth ? this.ScaledWidth : this.Width),
110 | coords[1] * this.Height,
111 | coords[2],
112 | );
113 | }
114 | }
115 |
--------------------------------------------------------------------------------
/src/ui/Sprite.ts:
--------------------------------------------------------------------------------
1 | import { Color, Point, Size } from '../utils';
2 | import { Screen } from './';
3 |
4 | export class Sprite {
5 | public textureName: string;
6 | public pos: Point;
7 | public size: Size;
8 | public heading: number;
9 | public color: Color;
10 | public visible: boolean;
11 |
12 | private _textureDict: string;
13 |
14 | constructor(
15 | textureDict: string,
16 | textureName: string,
17 | pos?: Point,
18 | size?: Size,
19 | heading = 0,
20 | color = Color.white,
21 | ) {
22 | this._textureDict = textureDict;
23 | this.textureName = textureName;
24 | this.pos = pos || new Point();
25 | this.size = size || new Size();
26 | this.heading = heading || 0;
27 | this.color = color || Color.white;
28 | this.visible = true;
29 | }
30 |
31 | public loadTextureDictionary(): void {
32 | RequestStreamedTextureDict(this._textureDict, true);
33 | const interval = setInterval(() => {
34 | if (this.IsTextureDictionaryLoaded) {
35 | clearInterval(interval);
36 | }
37 | }, 0);
38 | }
39 |
40 | public set TextureDict(v: string) {
41 | this._textureDict = v;
42 | if (!this.IsTextureDictionaryLoaded) {
43 | this.loadTextureDictionary();
44 | }
45 | }
46 |
47 | public get TextureDict(): string {
48 | return this._textureDict;
49 | }
50 |
51 | public get IsTextureDictionaryLoaded(): boolean {
52 | return !!HasStreamedTextureDictLoaded(this._textureDict);
53 | }
54 |
55 | public draw(resolution?: Size): void;
56 | public draw(
57 | textureDictionary?: string,
58 | textureName?: string,
59 | pos?: Point,
60 | size?: Size,
61 | heading?: number,
62 | color?: Color,
63 | loadTexture?: boolean,
64 | resolution?: Size,
65 | ): void;
66 | public draw(
67 | arg1?: Size | string,
68 | textureName?: string,
69 | pos?: Point,
70 | size?: Size,
71 | heading?: number,
72 | color?: Color,
73 | loadTexture = true,
74 | resolution?: Size,
75 | ): void {
76 | const textureDictionary = arg1 && typeof arg1 === 'string' ? arg1 : this.TextureDict;
77 |
78 | textureName = textureName || this.textureName;
79 | pos = pos || this.pos;
80 | size = size || this.size;
81 | heading = heading || this.heading;
82 | color = color || this.color;
83 |
84 | if (loadTexture) {
85 | if (!HasStreamedTextureDictLoaded(textureDictionary)) {
86 | RequestStreamedTextureDict(textureDictionary, false);
87 | }
88 | }
89 |
90 | resolution = arg1 instanceof Size ? arg1 : resolution;
91 | resolution = resolution || new Size(Screen.ScaledWidth, Screen.Height);
92 |
93 | const w = size.width / resolution.width;
94 | const h = size.height / resolution.height;
95 | const x = pos.X / resolution.width + w * 0.5;
96 | const y = pos.Y / resolution.height + h * 0.5;
97 |
98 | DrawSprite(
99 | textureDictionary,
100 | textureName,
101 | x,
102 | y,
103 | w,
104 | h,
105 | heading,
106 | color.r,
107 | color.g,
108 | color.b,
109 | color.a,
110 | );
111 | }
112 | }
113 |
--------------------------------------------------------------------------------
/src/ui/Text.ts:
--------------------------------------------------------------------------------
1 | import { Alignment, Font } from '../enums';
2 | import { Color, Point, Size } from '../utils';
3 | import { IDrawable, Screen } from './';
4 |
5 | export class Text implements IDrawable {
6 | public static draw(
7 | caption: string,
8 | pos: Point,
9 | scale = 1,
10 | color = Color.white,
11 | font = Font.ChaletLondon,
12 | alignment = Alignment.Left,
13 | dropShadow = false,
14 | outline = false,
15 | wordWrap?: Size,
16 | resolution?: Size,
17 | ): void {
18 | resolution = resolution || new Size(Screen.ScaledWidth, Screen.Height);
19 | const x = pos.X / resolution.width;
20 | const y = pos.Y / resolution.height;
21 |
22 | SetTextFont(Number(font));
23 | SetTextScale(1.0, scale);
24 | SetTextColour(color.r, color.g, color.b, color.a);
25 |
26 | if (dropShadow) {
27 | SetTextDropshadow(2, 0, 0, 0, 0);
28 | }
29 |
30 | if (outline) {
31 | SetTextOutline();
32 | }
33 |
34 | switch (alignment) {
35 | case Alignment.Centered:
36 | SetTextCentre(true);
37 | break;
38 | case Alignment.Right:
39 | SetTextRightJustify(true);
40 | if (!wordWrap) {
41 | SetTextWrap(0.0, x);
42 | }
43 | break;
44 | }
45 |
46 | if (wordWrap) {
47 | SetTextWrap(x, (pos.X + wordWrap.width) / resolution.width);
48 | }
49 |
50 | SetTextEntry('STRING');
51 | Text.addLongString(caption);
52 | DrawText(x, y);
53 | }
54 |
55 | public static addLongString(str: string): void {
56 | const strLen = 99;
57 | for (let i = 0; i < str.length; i += strLen) {
58 | const substr = str.substr(i, Math.min(strLen, str.length - i));
59 | AddTextComponentSubstringPlayerName(substr);
60 | }
61 | }
62 |
63 | public caption: string;
64 | public pos: Point;
65 | public scale: number;
66 | public color: Color;
67 | public font: Font;
68 | public alignment: Alignment;
69 | public dropShadow: boolean;
70 | public outline: boolean;
71 | public wordWrap: Size;
72 |
73 | /**
74 | *
75 | * @param caption Text to display
76 | * @param pos Position of text relative to alignment. In pixels.
77 | * @param scale Size of text. Default 1.0
78 | * @param color Color of text. Default black.
79 | * @param font Font of text. Default Chalet London.
80 | * @param alignment Alignment of text. Default Left.
81 | * @param dropShadow
82 | * @param outline
83 | * @param wordWrap
84 | */
85 | constructor(
86 | caption: string,
87 | pos: Point,
88 | scale = 1,
89 | color = Color.white,
90 | font = Font.ChaletLondon,
91 | alignment = Alignment.Left,
92 | dropShadow = false,
93 | outline = false,
94 | wordWrap?: Size,
95 | ) {
96 | this.caption = caption;
97 | this.pos = pos;
98 | this.scale = scale;
99 | this.color = color;
100 | this.font = font;
101 | this.alignment = alignment;
102 | this.dropShadow = dropShadow;
103 | this.outline = outline;
104 | this.wordWrap = wordWrap;
105 | }
106 |
107 | public draw(offset?: Size, resolution?: Size): void;
108 | public draw(
109 | caption: string,
110 | pos: Point,
111 | scale: number,
112 | color?: Color,
113 | font?: Font,
114 | alignment?: Alignment,
115 | dropShadow?: boolean,
116 | outline?: boolean,
117 | wordWrap?: Size,
118 | resolution?: Size,
119 | ): void;
120 | public draw(
121 | arg1?: Size | string,
122 | arg2?: Size | Point,
123 | scale?: number,
124 | color?: Color,
125 | font?: Font,
126 | alignment?: Alignment,
127 | dropShadow?: boolean,
128 | outline?: boolean,
129 | wordWrap?: Size,
130 | resolution?: Size,
131 | ): void {
132 | resolution = arg2 instanceof Size ? arg2 : resolution;
133 |
134 | if (scale === undefined) {
135 | if (arg1 && arg1 instanceof Size) {
136 | arg2 = new Point(this.pos.X + arg1.width, this.pos.Y + arg1.height);
137 | } else {
138 | arg2 = this.pos;
139 | }
140 | arg1 = this.caption;
141 | scale = this.scale;
142 | color = this.color;
143 | font = this.font;
144 | alignment = this.alignment;
145 | dropShadow = this.dropShadow;
146 | outline = this.outline;
147 | wordWrap = this.wordWrap;
148 | } else {
149 | arg1 = arg1 || this.caption;
150 | if (!arg2) {
151 | arg2 = this.pos;
152 | } else {
153 | arg2 = arg2 as Point;
154 | }
155 | scale = scale !== undefined && scale !== null ? scale : this.scale;
156 | color = color || this.color;
157 | font = font !== undefined && font !== null ? font : this.font;
158 | alignment = alignment !== undefined && alignment !== null ? alignment : this.alignment;
159 | dropShadow = typeof dropShadow === 'boolean' ? dropShadow : dropShadow;
160 | outline = typeof outline === 'boolean' ? outline : outline;
161 | wordWrap = wordWrap || this.wordWrap;
162 | }
163 |
164 | Text.draw(
165 | arg1 as string,
166 | arg2,
167 | scale,
168 | color,
169 | font,
170 | alignment,
171 | dropShadow,
172 | outline,
173 | wordWrap,
174 | resolution,
175 | );
176 | }
177 | }
178 |
--------------------------------------------------------------------------------
/src/ui/index.ts:
--------------------------------------------------------------------------------
1 | export * from './interfaces';
2 | export { Rectangle } from './Rectangle';
3 | export { Container } from './Container';
4 | export { Effects } from './Effects';
5 | export { Fading } from './Fading';
6 | export { Hud } from './Hud';
7 | export { LoadingPrompt } from './LoadingPrompt';
8 | export { Notification } from './Notification';
9 | export { Scaleform } from './Scaleform';
10 | export { Screen } from './Screen';
11 | export { Sprite } from './Sprite';
12 | export { Text } from './Text';
13 | export { Timerbar } from './Timerbar';
14 | export * from './menu';
15 |
--------------------------------------------------------------------------------
/src/ui/interfaces/IDrawable.ts:
--------------------------------------------------------------------------------
1 | import { Color, Point, Size } from '../../utils/';
2 |
3 | export interface IDrawable {
4 | pos: Point;
5 | size?: Size;
6 | color?: Color;
7 | draw(offset?: Size, resolution?: Size): void;
8 | }
9 |
--------------------------------------------------------------------------------
/src/ui/interfaces/index.ts:
--------------------------------------------------------------------------------
1 | export { IDrawable } from './IDrawable';
2 |
--------------------------------------------------------------------------------
/src/ui/menu/MenuControl.ts:
--------------------------------------------------------------------------------
1 | export class MenuControl {
2 | private _enabled: boolean;
3 |
4 | constructor(enabled = true) {
5 | this._enabled = enabled;
6 | }
7 |
8 | public get Enabled(): boolean {
9 | return this._enabled;
10 | }
11 |
12 | public set Enabled(value: boolean) {
13 | this._enabled = value;
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/src/ui/menu/MenuControls.ts:
--------------------------------------------------------------------------------
1 | import { MenuControl } from './MenuControl';
2 |
3 | export class MenuControls {
4 | public back = new MenuControl();
5 | public select = new MenuControl();
6 | public left = new MenuControl();
7 | public right = new MenuControl();
8 | public up = new MenuControl();
9 | public down = new MenuControl();
10 | }
11 |
--------------------------------------------------------------------------------
/src/ui/menu/MenuSettings.ts:
--------------------------------------------------------------------------------
1 | import { InputMode } from '../../index';
2 | import { Control } from '../../enums';
3 |
4 | export class MenuSettings {
5 | public scaleWithSafezone = true;
6 | public resetCursorOnOpen = true;
7 | public mouseControlsEnabled = true;
8 | public mouseEdgeEnabled = true;
9 | public controlDisablingEnabled = true;
10 | public audio = {
11 | library: 'HUD_FRONTEND_DEFAULT_SOUNDSET',
12 | upDown: 'NAV_UP_DOWN',
13 | leftRight: 'NAV_LEFT_RIGHT',
14 | select: 'SELECT',
15 | back: 'BACK',
16 | error: 'ERROR',
17 | };
18 | public enabledControls = {
19 | [InputMode.GamePad]: [Control.LookUpDown, Control.LookLeftRight, Control.Aim, Control.Attack],
20 | [InputMode.MouseAndKeyboard]: [
21 | Control.FrontendAccept,
22 | Control.FrontendAxisX,
23 | Control.FrontendAxisY,
24 | Control.FrontendDown,
25 | Control.FrontendUp,
26 | Control.FrontendLeft,
27 | Control.FrontendRight,
28 | Control.FrontendCancel,
29 | Control.FrontendSelect,
30 | Control.CursorScrollDown,
31 | Control.CursorScrollUp,
32 | Control.CursorX,
33 | Control.CursorY,
34 | Control.MoveUpDown,
35 | Control.MoveLeftRight,
36 | Control.Sprint,
37 | Control.Jump,
38 | Control.Enter,
39 | Control.VehicleExit,
40 | Control.VehicleAccelerate,
41 | Control.VehicleBrake,
42 | Control.VehicleHandbrake,
43 | Control.VehicleMoveLeftRight,
44 | Control.VehicleFlyYawLeft,
45 | Control.VehicleFlyYawRight,
46 | Control.FlyLeftRight,
47 | Control.FlyUpDown,
48 | ],
49 | };
50 | }
51 |
--------------------------------------------------------------------------------
/src/ui/menu/index.ts:
--------------------------------------------------------------------------------
1 | export * from './items';
2 | export * from './modules';
3 | export { Menu } from './Menu';
4 | export { MenuControl } from './MenuControl';
5 | export { MenuControls } from './MenuControls';
6 | export { MenuSettings } from './MenuSettings';
7 |
--------------------------------------------------------------------------------
/src/ui/menu/items/UIMenuCheckboxItem.ts:
--------------------------------------------------------------------------------
1 | import { Menu, Sprite } from '../../';
2 | import { Color, LiteEvent, Point, Size } from '../../../utils';
3 | import { UIMenuItem } from './';
4 | import { CheckboxStyle } from '../../../enums';
5 |
6 | export class UIMenuCheckboxItem extends UIMenuItem {
7 | public readonly checkboxChanged = new LiteEvent();
8 |
9 | protected supportsRightBadge = false;
10 | protected supportsRightLabel = false;
11 |
12 | private _checked = false;
13 | private _style = CheckboxStyle.Tick;
14 |
15 | private readonly _checkboxSprite: Sprite;
16 |
17 | constructor(text: string, checked = false, description?: string, style: CheckboxStyle = null) {
18 | super(text, description);
19 | this._checkboxSprite = new Sprite('commonmenu', '', new Point(410, 95), new Size(50, 50));
20 | this.Checked = checked;
21 | this.Style = style;
22 | }
23 |
24 | public get Checked(): boolean {
25 | return this._checked;
26 | }
27 |
28 | public set Checked(value: boolean) {
29 | this._checked = value || false;
30 | }
31 |
32 | public get Style(): CheckboxStyle {
33 | return this._style;
34 | }
35 |
36 | public set Style(value: CheckboxStyle) {
37 | this._style = Number(value);
38 | }
39 |
40 | public setVerticalPosition(y: number): void {
41 | super.setVerticalPosition(y);
42 | this._checkboxSprite.pos.Y = y + 138 + this.offset.Y;
43 | }
44 |
45 | public draw(): void {
46 | super.draw();
47 | this._checkboxSprite.pos.X = 380 + this.offset.X + this.parent.WidthOffset;
48 | this._checkboxSprite.textureName = this._getSpriteName();
49 | this._checkboxSprite.color = this._getSpriteColor();
50 | this._checkboxSprite.draw(Menu.screenResolution);
51 | }
52 |
53 | private _getSpriteName(): string {
54 | let name = 'blank';
55 | if (this._checked) {
56 | switch (this._style) {
57 | case CheckboxStyle.Tick:
58 | name = 'tick';
59 | break;
60 | case CheckboxStyle.Cross:
61 | name = 'cross';
62 | break;
63 | }
64 | }
65 | return `shop_box_${name}${this.selected ? 'b' : ''}`;
66 | }
67 |
68 | private _getSpriteColor(): Color {
69 | return this.enabled ? Color.white : Color.fromRgb(109, 109, 109);
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/src/ui/menu/items/UIMenuListItem.ts:
--------------------------------------------------------------------------------
1 | import { Menu, Sprite, Text } from '../../';
2 | import { Alignment, Font } from '../../../enums';
3 | import { Color, LiteEvent, measureString, Point, Size } from '../../../utils';
4 | import { ListItem } from '../modules/';
5 | import { UIMenuItem } from './';
6 |
7 | export class UIMenuListItem extends UIMenuItem {
8 | public readonly listChanged = new LiteEvent();
9 | public readonly listSelected = new LiteEvent();
10 |
11 | protected supportsRightBadge = false;
12 | protected supportsRightLabel = false;
13 |
14 | private _itemText: Text;
15 | private _leftArrow: Sprite;
16 | private _rightArrow: Sprite;
17 |
18 | private _index = 0;
19 | private _arrowOnlyOnSelected: boolean;
20 | private _items: ListItem[] = [];
21 | private _textWidth: number;
22 |
23 | constructor(
24 | text: string,
25 | items: ListItem[],
26 | startIndex = 0,
27 | description?: string,
28 | arrowOnlyOnSelected = true,
29 | ) {
30 | super(text, description);
31 | this._leftArrow = new Sprite('commonmenu', 'arrowleft', new Point(), new Size(30, 30));
32 | this._rightArrow = new Sprite('commonmenu', 'arrowright', new Point(), new Size(30, 30));
33 | this._itemText = new Text(
34 | '',
35 | new Point(),
36 | 0.35,
37 | Color.white,
38 | Font.ChaletLondon,
39 | Alignment.Right,
40 | );
41 | this.ArrowOnlyOnSelected = arrowOnlyOnSelected;
42 | this.Items = items;
43 | this.Index = startIndex;
44 | }
45 |
46 | public get Items(): ListItem[] {
47 | return this._items;
48 | }
49 |
50 | public set Items(value: ListItem[]) {
51 | if (!value) {
52 | throw new Error("Items can't be null");
53 | }
54 | this._items = value;
55 | }
56 |
57 | public get SelectedItem(): ListItem {
58 | return this.Items[this.Index];
59 | }
60 |
61 | public set SelectedItem(value: ListItem) {
62 | const index = this.Items.findIndex(i => i.id === value.id);
63 | if (index >= 0) {
64 | this.Index = index;
65 | }
66 | }
67 |
68 | public get SelectedValue(): unknown {
69 | const item = this.SelectedItem;
70 | return item ? item.value : null;
71 | }
72 |
73 | public get Index(): number {
74 | return this._index % this.Items.length;
75 | }
76 |
77 | public set Index(value: number) {
78 | if (!this._items.length) {
79 | return;
80 | }
81 | value = value < 0 ? this._items.length - 1 : value > this._items.length - 1 ? 0 : value;
82 | this._index = value;
83 | delete this._textWidth;
84 | }
85 |
86 | public get ArrowOnlyOnSelected(): boolean {
87 | return this._arrowOnlyOnSelected;
88 | }
89 |
90 | public set ArrowOnlyOnSelected(value: boolean) {
91 | this._arrowOnlyOnSelected = value;
92 | }
93 |
94 | public get IsMouseInBoundsOfLeftArrow(): boolean {
95 | return this.parent.isMouseInBounds(this._leftArrow.pos, this._leftArrow.size);
96 | }
97 |
98 | public get IsMouseInBoundsOfRightArrow(): boolean {
99 | return this.parent.isMouseInBounds(this._rightArrow.pos, this._rightArrow.size);
100 | }
101 |
102 | public setVerticalPosition(y: number): void {
103 | const yOffset = y + this.offset.Y + 147;
104 | this._leftArrow.pos.Y = yOffset;
105 | this._rightArrow.pos.Y = yOffset;
106 | this._itemText.pos.Y = yOffset;
107 | super.setVerticalPosition(y);
108 | }
109 |
110 | public draw(): void {
111 | super.draw();
112 | if (this._textWidth === undefined) {
113 | const caption = this._getSelectedItemCaption();
114 | this._itemText.caption = caption;
115 | this._textWidth = measureString(
116 | caption,
117 | this._itemText.font,
118 | this._itemText.scale,
119 | Menu.screenWidth,
120 | );
121 | }
122 |
123 | this._rightArrow.pos.X = this.offset.X + this.parent.WidthOffset + 400;
124 | this._itemText.pos.X = this._rightArrow.pos.X + 5;
125 |
126 | this._itemText.color = this.enabled
127 | ? this.selected
128 | ? this.HighlightedForeColor
129 | : this.ForeColor
130 | : new Color(255, 163, 159, 148);
131 |
132 | if (this._arrowOnlyOnSelected && !this.selected) {
133 | this._itemText.pos.X += this._rightArrow.size.width / 2;
134 | } else {
135 | this._leftArrow.color = this._itemText.color;
136 | this._rightArrow.color = this._itemText.color;
137 |
138 | this._leftArrow.pos.X =
139 | this._itemText.pos.X - this._textWidth - this._leftArrow.size.width + 5;
140 |
141 | this._leftArrow.draw(Menu.screenResolution);
142 | this._rightArrow.draw(Menu.screenResolution);
143 | }
144 |
145 | this._itemText.draw(undefined, Menu.screenResolution);
146 | }
147 |
148 | private _getSelectedItemCaption(): string {
149 | const item = this.SelectedItem;
150 | return item ? item.name : '';
151 | }
152 | }
153 |
--------------------------------------------------------------------------------
/src/ui/menu/items/UIMenuSeparatorItem.ts:
--------------------------------------------------------------------------------
1 | import { UIMenuItem } from './';
2 | import { Alignment } from '../../../enums';
3 | import { Menu } from '../';
4 |
5 | export class UIMenuSeparatorItem extends UIMenuItem {
6 | protected supportsDescription = false;
7 | protected supportsPanels = false;
8 | protected supportsLeftBadge = false;
9 | protected supportsRightBadge = false;
10 | protected supportsRightLabel = false;
11 |
12 | constructor(text?: string) {
13 | super(text);
14 | this.text.alignment = Alignment.Centered;
15 | }
16 |
17 | public setVerticalPosition(y: number): void {
18 | const yOffset = y + this.offset.Y;
19 | this.rectangle.pos.Y = yOffset + 144;
20 | this.text.pos.Y = yOffset + 147;
21 | }
22 |
23 | public draw(): void {
24 | const width = 431 + this.parent.WidthOffset;
25 | this.rectangle.size.width = width;
26 | this.rectangle.pos.X = this.offset.X;
27 | this.rectangle.draw(undefined, Menu.screenResolution);
28 |
29 | if (this.text.caption !== '') {
30 | this.text.pos.X = this.offset.X + width / 2;
31 | this.text.draw(undefined, Menu.screenResolution);
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/src/ui/menu/items/index.ts:
--------------------------------------------------------------------------------
1 | export * from './panels';
2 | export { UIMenuItem } from './UIMenuItem';
3 | export { UIMenuCheckboxItem } from './UIMenuCheckboxItem';
4 | export { UIMenuListItem } from './UIMenuListItem';
5 | export { UIMenuSeparatorItem } from './UIMenuSeparatorItem';
6 | export { UIMenuSliderItem } from './UIMenuSliderItem';
7 |
--------------------------------------------------------------------------------
/src/ui/menu/items/panels/AbstractUIMenuPanel.ts:
--------------------------------------------------------------------------------
1 | import { UIMenuItem } from '../';
2 | import { uuidv4 } from '../../../../utils';
3 | import { Rectangle, Sprite } from '../../../';
4 | import { Menu } from '../../';
5 |
6 | export abstract class AbstractUIMenuPanel {
7 | public readonly id: string = uuidv4();
8 |
9 | protected parentItem: UIMenuItem;
10 | protected enabled = true;
11 |
12 | protected readonly background: Sprite | Rectangle;
13 |
14 | public get ParentMenu(): Menu {
15 | return this.parentItem.parent;
16 | }
17 |
18 | public get ParentItem(): UIMenuItem {
19 | return this.parentItem;
20 | }
21 |
22 | public set ParentItem(value: UIMenuItem) {
23 | this.parentItem = value;
24 | }
25 |
26 | public get Enabled(): boolean {
27 | return this.enabled;
28 | }
29 |
30 | public set Enabled(value: boolean) {
31 | this.enabled = value;
32 | }
33 |
34 | public get Height(): number {
35 | return this.background.size.height;
36 | }
37 |
38 | public setVerticalPosition(y: number): void {
39 | this.background.pos.Y = y;
40 | }
41 |
42 | public draw(): void {
43 | this.background.size.width = 431 + this.ParentMenu.WidthOffset;
44 | this.background.pos.X = this.parentItem.offset.X;
45 | if (this.background instanceof Sprite) {
46 | this.background.draw(Menu.screenResolution);
47 | } else {
48 | this.background.draw(undefined, Menu.screenResolution);
49 | }
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/src/ui/menu/items/panels/UIMenuColorPanel.ts:
--------------------------------------------------------------------------------
1 | import { Color, Point, Size } from '../../../../utils';
2 | import { AbstractUIMenuPanel } from './';
3 | import { Rectangle, Sprite, Text } from '../../../';
4 | import { Alignment, Control, Font } from '../../../../enums';
5 | import { Game, Menu } from '../../../../';
6 |
7 | export class UIMenuColorPanel extends AbstractUIMenuPanel {
8 | protected readonly background: Sprite;
9 |
10 | private _title: string;
11 | private _text: Text;
12 | private _colors: Color[] = [];
13 | private _bar: Rectangle[] = [];
14 |
15 | private _lastColor: Color;
16 |
17 | private readonly _leftArrow: Sprite;
18 | private readonly _rightArrow: Sprite;
19 | private readonly _selectedRectangle: Rectangle;
20 |
21 | // Pagination
22 | private _min = 0;
23 | private _max = 8;
24 | private _total = 9;
25 | private _index = 0;
26 |
27 | constructor(title: string, colors: Color[]) {
28 | super();
29 | this.background = new Sprite('commonmenu', 'gradient_bgd', new Point(), new Size(431, 112));
30 | this._leftArrow = new Sprite('commonmenu', 'arrowleft', new Point(), new Size(30, 30));
31 | this._rightArrow = new Sprite('commonmenu', 'arrowright', new Point(), new Size(30, 30));
32 | this._selectedRectangle = new Rectangle(new Point(), new Size(44.5, 8), Color.white);
33 | this._text = new Text(
34 | '',
35 | new Point(),
36 | 0.35,
37 | Color.white,
38 | Font.ChaletLondon,
39 | Alignment.Centered,
40 | );
41 | this.Title = title;
42 | this.Colors = colors;
43 | }
44 |
45 | public get Title(): string {
46 | return this._title;
47 | }
48 |
49 | public set Title(value: string) {
50 | this._title = value ? value.trim() : '';
51 | this._updateText();
52 | }
53 |
54 | public get Colors(): Color[] {
55 | return this._colors;
56 | }
57 |
58 | public set Colors(value: Color[]) {
59 | if (!value) {
60 | value = [];
61 | }
62 | this._colors = value;
63 | this._bar = [];
64 | const colorRectangles = value.slice(0, this._total).map(color => {
65 | return new Rectangle(new Point(0, 0), new Size(44.5, 44.5), color);
66 | });
67 | this._bar.push(...colorRectangles);
68 | this._refreshIndex();
69 | this._updateSelection(true);
70 | }
71 |
72 | public get Color(): Color {
73 | return this._colors[this.Index];
74 | }
75 |
76 | public set Color(value: Color) {
77 | const index = this._colors.findIndex(c => {
78 | return c.a === value.a && c.r === value.r && c.g === value.g && c.b === value.b;
79 | });
80 | if (index !== -1) {
81 | this.Index = index;
82 | }
83 | }
84 |
85 | public get Index(): number {
86 | return this._index % this._colors.length;
87 | }
88 |
89 | public set Index(value: number) {
90 | value = 1000000 - (1000000 % this._colors.length) + value;
91 | if (this.Index === value % this._colors.length) {
92 | return;
93 | }
94 | this._index = value;
95 | const currentSelection = this.Index;
96 | if (currentSelection > this._max) {
97 | this._min = currentSelection - this._total + 1;
98 | this._max = currentSelection;
99 | } else if (currentSelection < this._min) {
100 | this._min = currentSelection;
101 | this._max = currentSelection + this._total - 1;
102 | }
103 | this._updateSelection();
104 | }
105 |
106 | public updateParentItem(): void {
107 | const last = this._lastColor;
108 | const current = this.Color;
109 | if (
110 | !last ||
111 | last.a !== current.a ||
112 | last.r !== current.r ||
113 | last.g !== current.g ||
114 | last.b !== current.b
115 | ) {
116 | this._lastColor = current;
117 | this.ParentMenu.panelActivated.emit(this.parentItem, this, this.Index, current);
118 | this.parentItem.panelActivated.emit(this, this.Index, current);
119 | }
120 | }
121 |
122 | public setVerticalPosition(y: number): void {
123 | super.setVerticalPosition(y);
124 | this._selectedRectangle.pos.Y = y + 47;
125 | this._leftArrow.pos.Y = y + 15;
126 | this._rightArrow.pos.Y = y + 15;
127 | this._text.pos.Y = y + 15;
128 | this._bar.forEach(async colorRect => {
129 | colorRect.pos.Y = y + 55;
130 | });
131 | }
132 |
133 | public draw(): void {
134 | if (this.enabled) {
135 | super.draw();
136 |
137 | const x = this.parentItem.offset.X + this.ParentMenu.WidthOffset / 2;
138 | this._selectedRectangle.pos.X = x + 15 + 44.5 * (this.Index - this._min);
139 | this._leftArrow.pos.X = x + 7.5;
140 | this._rightArrow.pos.X = x + 393.5;
141 | this._text.pos.X = x + 215.5;
142 |
143 | this._leftArrow.draw(Menu.screenResolution);
144 | this._rightArrow.draw(Menu.screenResolution);
145 |
146 | this._text.draw(undefined, Menu.screenResolution);
147 | this._selectedRectangle.draw(undefined, Menu.screenResolution);
148 |
149 | this._bar.forEach(async (colorRect, index) => {
150 | colorRect.pos.X = x + 15 + 44.5 * index;
151 | colorRect.draw(undefined, Menu.screenResolution);
152 | });
153 |
154 | this._processControls();
155 | }
156 | }
157 |
158 | private _refreshIndex(): void {
159 | if (!this._colors.length) {
160 | this._index = 1000;
161 | } else {
162 | this._index = 1000 - (1000 % this._colors.length);
163 | }
164 |
165 | this._max = this._total - 1;
166 | this._min = 0;
167 | }
168 |
169 | private _updateSelection(preventUpdate = false): void {
170 | if (!preventUpdate) {
171 | this.updateParentItem();
172 | }
173 | this._bar.forEach(async (colorRect, index) => {
174 | colorRect.color = this._colors[this._min + index];
175 | });
176 | this._updateText();
177 | }
178 |
179 | private _updateText(): void {
180 | this._text.caption = `${this._title} [${this.Index + 1 || 0} / ${this._colors.length}]`;
181 | }
182 |
183 | private _goLeft(): void {
184 | if (this._colors.length > this._total) {
185 | if (this.Index <= this._min) {
186 | if (this.Index === 0) {
187 | this._min = this._colors.length - this._total;
188 | this._max = this._colors.length - 1;
189 | this._index = 1000 - (1000 % this._colors.length);
190 | this._index += this._colors.length - 1;
191 | } else {
192 | this._min--;
193 | this._max--;
194 | this._index--;
195 | }
196 | } else {
197 | this._index--;
198 | }
199 | } else {
200 | this._index--;
201 | }
202 | this._updateSelection();
203 | }
204 |
205 | private _goRight(): void {
206 | if (this._colors.length > this._total) {
207 | if (this.Index >= this._max) {
208 | if (this.Index === this._colors.length - 1) {
209 | this._min = 0;
210 | this._max = this._total - 1;
211 | this._index = 1000 - (1000 % this._colors.length);
212 | } else {
213 | this._min++;
214 | this._max++;
215 | this._index++;
216 | }
217 | } else {
218 | this._index++;
219 | }
220 | } else {
221 | this._index++;
222 | }
223 | this._updateSelection();
224 | }
225 |
226 | private _processControls(): void {
227 | if (Game.isDisabledControlJustPressed(0, Control.Attack)) {
228 | if (this.ParentMenu.isMouseInBounds(this._leftArrow.pos, this._leftArrow.size)) {
229 | this._goLeft();
230 | } else if (this.ParentMenu.isMouseInBounds(this._rightArrow.pos, this._rightArrow.size)) {
231 | this._goRight();
232 | }
233 | this._bar.forEach(async (colorRect, index) => {
234 | if (this.ParentMenu.isMouseInBounds(colorRect.pos, colorRect.size)) {
235 | this.Index = this._min + index;
236 | }
237 | });
238 | }
239 | }
240 | }
241 |
--------------------------------------------------------------------------------
/src/ui/menu/items/panels/UIMenuPercentagePanel.ts:
--------------------------------------------------------------------------------
1 | import { Color, Point, Size } from '../../../../utils';
2 | import { AbstractUIMenuPanel } from './';
3 | import { Menu, Rectangle, Sprite, Text } from '../../../';
4 | import { Alignment, Control, Font } from '../../../../enums';
5 | import { Game } from '../../../../';
6 |
7 | export class UIMenuPercentagePanel extends AbstractUIMenuPanel {
8 | protected readonly background: Sprite;
9 |
10 | private _pressed = false;
11 | private _lastPercentage: number;
12 |
13 | private readonly _title: Text;
14 | private readonly _minText: Text;
15 | private readonly _maxText: Text;
16 |
17 | private readonly _activeBar: Rectangle;
18 | private readonly _backgroundBar: Rectangle;
19 |
20 | constructor(title?: string, percentage = 0, minText?: string, maxText?: string) {
21 | super();
22 | this.background = new Sprite('commonmenu', 'gradient_bgd', new Point(), new Size(431, 76));
23 | const barSize = new Size(413, 10);
24 | this._activeBar = new Rectangle(new Point(), barSize, Color.fromRgb(245, 245, 245));
25 | this._backgroundBar = new Rectangle(new Point(), { ...barSize }, Color.fromRgb(87, 87, 87));
26 | this._title = new Text(
27 | '',
28 | new Point(),
29 | 0.35,
30 | Color.white,
31 | Font.ChaletLondon,
32 | Alignment.Centered,
33 | );
34 | this._minText = new Text(
35 | '',
36 | new Point(),
37 | 0.35,
38 | Color.white,
39 | Font.ChaletLondon,
40 | Alignment.Centered,
41 | );
42 | this._maxText = new Text(
43 | '',
44 | new Point(),
45 | 0.35,
46 | Color.white,
47 | Font.ChaletLondon,
48 | Alignment.Centered,
49 | );
50 | this.Title = title;
51 | this.MinText = minText || '0%';
52 | this.MaxText = maxText || '100%';
53 | this.Percentage = percentage;
54 | }
55 |
56 | public get Title(): string {
57 | return this._title.caption;
58 | }
59 |
60 | public set Title(value: string) {
61 | this._title.caption = value ? value.trim() : '';
62 | }
63 |
64 | public get MinText(): string {
65 | return this._minText.caption;
66 | }
67 |
68 | public set MinText(value: string) {
69 | this._minText.caption = value ? value.trim() : '';
70 | }
71 |
72 | public get MaxText(): string {
73 | return this._maxText.caption;
74 | }
75 |
76 | public set MaxText(value: string) {
77 | this._maxText.caption = value ? value.trim() : '';
78 | }
79 |
80 | public get Percentage(): number {
81 | const progress = this._activeBar.size.width / this._backgroundBar.size.width;
82 | return Math.round(progress * 100) / 100;
83 | }
84 |
85 | public set Percentage(value: number) {
86 | value = value || 0;
87 | value = value < 0 ? 0 : value > 1 ? 1 : value;
88 | this._activeBar.size.width = this._backgroundBar.size.width * value;
89 | }
90 |
91 | public updateParentItem(): void {
92 | const last = this._lastPercentage;
93 | const current = this.Percentage;
94 | if (last !== current) {
95 | this._lastPercentage = current;
96 | this.ParentMenu.panelActivated.emit(this.parentItem, this, current);
97 | this.parentItem.panelActivated.emit(this, current);
98 | }
99 | }
100 |
101 | public setVerticalPosition(y: number): void {
102 | super.setVerticalPosition(y);
103 | this._activeBar.pos.Y = y + 50;
104 | this._backgroundBar.pos.Y = y + 50;
105 | y += 15;
106 | this._minText.pos.Y = y;
107 | this._title.pos.Y = y;
108 | this._maxText.pos.Y = y;
109 | }
110 |
111 | public draw(): void {
112 | if (this.enabled) {
113 | super.draw();
114 |
115 | const x = this.parentItem.offset.X + this.ParentMenu.WidthOffset / 2;
116 | this._activeBar.pos.X = x + 9;
117 | this._backgroundBar.pos.X = x + 9;
118 | this._minText.pos.X = x + 25;
119 | this._title.pos.X = x + 215.5;
120 | this._maxText.pos.X = x + 398;
121 |
122 | this._backgroundBar.draw(undefined, Menu.screenResolution);
123 | this._activeBar.draw(undefined, Menu.screenResolution);
124 |
125 | this._minText.draw(undefined, Menu.screenResolution);
126 | this._title.draw(undefined, Menu.screenResolution);
127 | this._maxText.draw(undefined, Menu.screenResolution);
128 |
129 | this._processControls();
130 | }
131 | }
132 |
133 | private _processControls(): void {
134 | if (
135 | !this._pressed &&
136 | Game.isDisabledControlJustPressed(0, Control.Attack) &&
137 | this.ParentMenu.isMouseInBounds(
138 | new Point(this._backgroundBar.pos.X, this._backgroundBar.pos.Y - 4),
139 | new Size(this._backgroundBar.size.width, this._backgroundBar.size.height + 8),
140 | )
141 | ) {
142 | this._pressed = true;
143 | (async () => {
144 | while (Game.isDisabledControlPressed(0, Control.Attack)) {
145 | await new Promise(resolve => setTimeout(resolve, 0));
146 | this._activeBar.size.width = this._getProgress();
147 | }
148 | this.updateParentItem();
149 | this._pressed = false;
150 | })();
151 | const interval = setInterval(async () => {
152 | if (Game.isDisabledControlPressed(0, Control.Attack)) {
153 | this.updateParentItem();
154 | } else {
155 | clearInterval(interval);
156 | }
157 | }, 75);
158 | }
159 | }
160 |
161 | private _getProgress(): number {
162 | const drawOffset = this.ParentMenu.DrawOffset;
163 | const progress =
164 | (GetControlNormal(0, 239) - drawOffset.X) * Menu.screenWidth - this._activeBar.pos.X;
165 | return progress < 0 ? 0 : progress > 413 ? 413 : progress;
166 | }
167 | }
168 |
--------------------------------------------------------------------------------
/src/ui/menu/items/panels/UIMenuStatisticsPanel.ts:
--------------------------------------------------------------------------------
1 | import { Color, Point, Size } from '../../../../utils';
2 | import { AbstractUIMenuPanel, UIMenuStatisticsPanelItem } from './';
3 | import { Menu, Rectangle } from '../../../';
4 |
5 | export class UIMenuStatisticsPanel extends AbstractUIMenuPanel {
6 | protected readonly background: Rectangle;
7 |
8 | private _divider = true;
9 | private _items: UIMenuStatisticsPanelItem[] = [];
10 |
11 | constructor(item?: UIMenuStatisticsPanelItem[] | UIMenuStatisticsPanelItem, divider = true) {
12 | super();
13 | this.background = new Rectangle(new Point(), new Size(431, 47), new Color(170, 0, 0, 0));
14 | if (item) {
15 | this.addItem(item);
16 | }
17 | this.Divider = divider;
18 | }
19 |
20 | public get Divider(): boolean {
21 | return this._divider;
22 | }
23 |
24 | public set Divider(value: boolean) {
25 | this._divider = value || false;
26 | }
27 |
28 | public get Items(): UIMenuStatisticsPanelItem[] {
29 | return this._items;
30 | }
31 |
32 | public set Items(value: UIMenuStatisticsPanelItem[]) {
33 | this._items = value;
34 | }
35 |
36 | public addItem(item: UIMenuStatisticsPanelItem | UIMenuStatisticsPanelItem[]): void {
37 | const items = Array.isArray(item) ? item : [item];
38 | this._items.push(...items);
39 | }
40 |
41 | public removeItem(itemOrIndex: UIMenuStatisticsPanelItem | number): void {
42 | if (typeof itemOrIndex === 'number') {
43 | this._items = this._items.filter((i, index) => index !== itemOrIndex);
44 | } else {
45 | this._items = this._items.filter(i => i.id !== itemOrIndex.id);
46 | }
47 | }
48 |
49 | public setVerticalPosition(y: number): void {
50 | super.setVerticalPosition(y);
51 | this._items.forEach(async (item, index) => {
52 | const itemCountOffset = 40 * (index + 1);
53 | const yOffset = y + itemCountOffset - 22;
54 | item.backgroundBar.pos.Y = yOffset;
55 | item.activeBar.pos.Y = yOffset;
56 | item.text.pos.Y = yOffset - 12;
57 | if (this._divider) {
58 | item.divider.forEach(async divider => {
59 | divider.pos.Y = yOffset;
60 | });
61 | }
62 | });
63 | }
64 |
65 | public draw(): void {
66 | if (this.enabled) {
67 | super.draw();
68 |
69 | const x = this.parentItem.offset.X + this.ParentMenu.WidthOffset / 2;
70 | this._items.forEach(async (item, index) => {
71 | const itemCountOffset = 40 * (index + 1);
72 | item.backgroundBar.pos.X = x + 200;
73 | item.activeBar.pos.X = x + 200;
74 | item.text.pos.X = x + 13;
75 |
76 | item.backgroundBar.draw(undefined, Menu.screenResolution);
77 | item.activeBar.draw(undefined, Menu.screenResolution);
78 | item.text.draw(undefined, Menu.screenResolution);
79 | if (this._divider) {
80 | item.divider.forEach(async (divider, index) => {
81 | const dividerWidthOffset = (index + 1) * 40;
82 | divider.pos.X = x + dividerWidthOffset + 200;
83 | this.background.size.height = itemCountOffset + 47 - 39;
84 |
85 | divider.draw(undefined, Menu.screenResolution);
86 | });
87 | }
88 | });
89 | }
90 | }
91 | }
92 |
--------------------------------------------------------------------------------
/src/ui/menu/items/panels/UIMenuStatisticsPanelItem.ts:
--------------------------------------------------------------------------------
1 | import { Color, Point, Size, uuidv4 } from '../../../../utils';
2 | import { Rectangle, Text } from '../../../';
3 | import { Alignment, Font } from '../../../../enums';
4 |
5 | export class UIMenuStatisticsPanelItem {
6 | public readonly id: string = uuidv4();
7 |
8 | public readonly text: Text;
9 | public readonly activeBar: Rectangle;
10 | public readonly backgroundBar: Rectangle;
11 | public readonly divider: Rectangle[] = [];
12 |
13 | constructor(name: string, percentage = 0) {
14 | this.text = new Text('', new Point(), 0.35, Color.white, Font.ChaletLondon, Alignment.Left);
15 | this.backgroundBar = new Rectangle(
16 | new Point(),
17 | new Size(200, 10),
18 | Color.fromArgb(100, 87, 87, 87),
19 | );
20 | this.activeBar = new Rectangle(new Point(), new Size(0, 10), Color.white);
21 | for (let i = 1; i <= 4; i++) {
22 | this.divider.push(new Rectangle(new Point(), new Size(2, 10), Color.black));
23 | }
24 | this.Name = name;
25 | this.Percentage = percentage;
26 | }
27 |
28 | public get Name(): string {
29 | return this.text.caption;
30 | }
31 |
32 | public set Name(value: string) {
33 | this.text.caption = value ? value.trim() : '';
34 | }
35 |
36 | public get Percentage(): number {
37 | return this.activeBar.size.width / 200;
38 | }
39 |
40 | public set Percentage(value: number) {
41 | value = value || 0;
42 | value = Math.round(value * 100) / 100;
43 | value = value < 0 ? 0 : value > 1 ? 1 : value;
44 | this.activeBar.size.width = value * 200;
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/src/ui/menu/items/panels/index.ts:
--------------------------------------------------------------------------------
1 | export { AbstractUIMenuPanel } from './AbstractUIMenuPanel';
2 | export { UIMenuGridPanel } from './UIMenuGridPanel';
3 | export { UIMenuColorPanel } from './UIMenuColorPanel';
4 | export { UIMenuPercentagePanel } from './UIMenuPercentagePanel';
5 | export { UIMenuStatisticsPanel } from './UIMenuStatisticsPanel';
6 | export { UIMenuStatisticsPanelItem } from './UIMenuStatisticsPanelItem';
7 |
--------------------------------------------------------------------------------
/src/ui/menu/modules/ListItem.ts:
--------------------------------------------------------------------------------
1 | import { uuidv4 } from '../../../utils';
2 |
3 | export class ListItem {
4 | public readonly id: string = uuidv4();
5 |
6 | public name: string;
7 | public value: unknown;
8 |
9 | constructor(name: string, value: unknown = null) {
10 | this.name = name;
11 | this.value = value;
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/src/ui/menu/modules/index.ts:
--------------------------------------------------------------------------------
1 | export { ListItem } from './ListItem';
2 |
--------------------------------------------------------------------------------
/src/utils/Color.ts:
--------------------------------------------------------------------------------
1 | export class Color {
2 | public static empty = new Color(0, 0, 0, 0);
3 | public static transparent = new Color(0, 0, 0, 0);
4 | public static black = new Color(255, 0, 0, 0);
5 | public static white = new Color(255, 255, 255, 255);
6 | public static whiteSmoke = new Color(255, 245, 245, 245);
7 |
8 | public static fromArgb(a: number, r: number, g: number, b: number): Color {
9 | return new Color(a, r, g, b);
10 | }
11 |
12 | public static fromRgb(r: number, g: number, b: number): Color {
13 | return new Color(255, r, g, b);
14 | }
15 |
16 | public a: number;
17 | public r: number;
18 | public g: number;
19 | public b: number;
20 |
21 | constructor(a = 255, r: number, g: number, b: number) {
22 | this.a = a;
23 | this.r = r;
24 | this.g = g;
25 | this.b = b;
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/utils/LiteEvent.ts:
--------------------------------------------------------------------------------
1 | export interface LiteEvent {
2 | on(handler: { (...args: unknown[]) }): void;
3 | off(handler: { (...args: unknown[]) }): void;
4 | }
5 |
6 | export class LiteEvent implements LiteEvent {
7 | private handlers: { (...args: unknown[]) }[] = [];
8 |
9 | public on(handler: { (...args: unknown[]) }): void {
10 | this.handlers.push(handler);
11 | }
12 |
13 | public off(handler: { (...args: unknown[]) }): void {
14 | this.handlers = this.handlers.filter(h => h !== handler);
15 | }
16 |
17 | public emit(...args: unknown[]): void {
18 | this.handlers.slice(0).forEach(h => {
19 | h(...args);
20 | });
21 | }
22 |
23 | public expose(): LiteEvent {
24 | return this;
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/utils/Math.ts:
--------------------------------------------------------------------------------
1 | export function clamp(num: number, min: number, max: number): number {
2 | return num <= min ? min : num >= max ? max : num;
3 | }
4 |
5 | export function getRandomInt(min: number, max: number): number {
6 | min = Math.ceil(min);
7 | max = Math.floor(max);
8 | return Math.floor(Math.random() * (max - min)) + min;
9 | }
10 |
--------------------------------------------------------------------------------
/src/utils/Point.ts:
--------------------------------------------------------------------------------
1 | export class Point {
2 | public static parse(arg: [number, number] | { X: number; Y: number } | string): Point {
3 | let point = new Point();
4 | if (arg) {
5 | if (typeof arg === 'object') {
6 | if (Array.isArray(arg)) {
7 | if (arg.length === 2) {
8 | point = new Point(arg[0], arg[1]);
9 | }
10 | } else if (arg.X && arg.Y) {
11 | point = new Point(arg.X, arg.Y);
12 | }
13 | } else {
14 | if (arg.indexOf(',') !== -1) {
15 | const arr = arg.split(',');
16 | point = new Point(parseFloat(arr[0]), parseFloat(arr[1]));
17 | }
18 | }
19 | }
20 | return point;
21 | }
22 |
23 | public X: number;
24 | public Y: number;
25 |
26 | constructor(x = 0, y = 0) {
27 | this.X = x;
28 | this.Y = y;
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/src/utils/PointF.ts:
--------------------------------------------------------------------------------
1 | export interface PointF {
2 | x: number;
3 | y: number;
4 | z: number;
5 | }
6 |
7 | export class PointF implements PointF {
8 | public static empty(): PointF {
9 | return new PointF(0, 0, 0);
10 | }
11 | constructor(public x: number, public y: number, public z: number) {}
12 | }
13 |
--------------------------------------------------------------------------------
/src/utils/Quaternion.ts:
--------------------------------------------------------------------------------
1 | import { Vector3 } from './Vector3';
2 |
3 | export class Quaternion {
4 | public x: number;
5 | public y: number;
6 | public z: number;
7 | public w: number;
8 |
9 | constructor(value: number);
10 | constructor(vector: Vector3, w: number);
11 | constructor(x: number, y: number, z: number, w: number);
12 | constructor(valueXOrVector: number | Vector3, yOrW?: number, z?: number, w?: number) {
13 | if (valueXOrVector instanceof Vector3) {
14 | this.x = valueXOrVector.x;
15 | this.y = valueXOrVector.y;
16 | this.z = valueXOrVector.z;
17 | this.w = yOrW;
18 | } else if (yOrW === undefined) {
19 | this.x = valueXOrVector;
20 | this.y = valueXOrVector;
21 | this.z = valueXOrVector;
22 | this.w = valueXOrVector;
23 | } else {
24 | this.x = valueXOrVector;
25 | this.y = yOrW;
26 | this.z = z;
27 | this.w = w;
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/src/utils/Size.ts:
--------------------------------------------------------------------------------
1 | export class Size {
2 | public width: number;
3 | public height: number;
4 | constructor(w = 0, h = 0) {
5 | this.width = w;
6 | this.height = h;
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/src/utils/String.ts:
--------------------------------------------------------------------------------
1 | import { Font, Screen, Text } from '..';
2 | import { clamp } from './Math';
3 |
4 | export function stringToArray(input: string): string[] {
5 | let stringsNeeded = 1;
6 | if (input.length > 99) {
7 | stringsNeeded = Math.ceil(input.length / 99);
8 | }
9 |
10 | const outputString: string[] = new Array(stringsNeeded);
11 | for (let i = 0; i < stringsNeeded; i++) {
12 | outputString[i] = input.substring(
13 | i * 99,
14 | i * 99 + clamp(input.substring(i * 99).length, 0, 99),
15 | );
16 | }
17 | return outputString;
18 | }
19 |
20 | export function measureStringWidthNoConvert(
21 | input: string,
22 | font = Font.ChaletLondon,
23 | scale = 0,
24 | ): number {
25 | SetTextEntryForWidth('STRING');
26 | Text.addLongString(input);
27 | SetTextFont(font);
28 | SetTextScale(1, scale);
29 | return GetTextScreenWidth(false);
30 | }
31 |
32 | export function measureString(
33 | str: string,
34 | font?: Font,
35 | scale?: number,
36 | screenWidth = Screen.ScaledWidth,
37 | ): number {
38 | return this.measureStringWidthNoConvert(str, font, scale) * screenWidth;
39 | }
40 |
--------------------------------------------------------------------------------
/src/utils/UUIDV4.ts:
--------------------------------------------------------------------------------
1 | export function uuidv4(): string {
2 | let uuid = '';
3 | for (let ii = 0; ii < 32; ii += 1) {
4 | switch (ii) {
5 | case 8:
6 | case 20:
7 | uuid += '-';
8 | uuid += ((Math.random() * 16) | 0).toString(16);
9 | break;
10 | case 12:
11 | uuid += '-';
12 | uuid += '4';
13 | break;
14 | case 16:
15 | uuid += '-';
16 | uuid += ((Math.random() * 4) | 8).toString(16);
17 | break;
18 | default:
19 | uuid += ((Math.random() * 16) | 0).toString(16);
20 | }
21 | }
22 | return uuid;
23 | }
24 |
--------------------------------------------------------------------------------
/src/utils/Vector3.ts:
--------------------------------------------------------------------------------
1 | // Source: https://raw.githubusercontent.com/you21979/typescript-vector/master/vector3.ts
2 | export interface Vec3 {
3 | x: number;
4 | y: number;
5 | z: number;
6 | }
7 |
8 | export class Vector3 implements Vec3 {
9 | public static create(v1: number | Vec3): Vector3 {
10 | if (typeof v1 === 'number') {
11 | return new Vector3(v1, v1, v1);
12 | }
13 | return new Vector3(v1.x, v1.y, v1.z);
14 | }
15 |
16 | public static clone(v1: Vec3): Vector3 {
17 | return Vector3.create(v1);
18 | }
19 |
20 | public static add(v1: Vec3, v2: number | Vec3): Vector3 {
21 | if (typeof v2 === 'number') {
22 | return new Vector3(v1.x + v2, v1.y + v2, v1.z + v2);
23 | }
24 | return new Vector3(v1.x + v2.x, v1.y + v2.y, v1.z + v2.z);
25 | }
26 |
27 | public static subtract(v1: Vec3, v2: Vec3): Vector3 {
28 | return new Vector3(v1.x - v2.x, v1.y - v2.y, v1.z - v2.z);
29 | }
30 |
31 | public static multiply(v1: Vec3, v2: Vec3 | number): Vector3 {
32 | if (typeof v2 === 'number') {
33 | return new Vector3(v1.x * v2, v1.y * v2, v1.z * v2);
34 | }
35 | return new Vector3(v1.x * v2.x, v1.y * v2.y, v1.z * v2.z);
36 | }
37 |
38 | public static divide(v1: Vec3, v2: Vec3 | number): Vector3 {
39 | if (typeof v2 === 'number') {
40 | return new Vector3(v1.x / v2, v1.y / v2, v1.z / v2);
41 | }
42 | return new Vector3(v1.x / v2.x, v1.y / v2.y, v1.z / v2.z);
43 | }
44 |
45 | public static dotProduct(v1: Vec3, v2: Vec3): number {
46 | return v1.x * v2.x + v1.y * v2.y + v1.z * v2.z;
47 | }
48 |
49 | public static crossProduct(v1: Vec3, v2: Vec3): Vector3 {
50 | const x = v1.y * v2.z - v1.z * v2.y;
51 | const y = v1.z * v2.x - v1.z * v2.z;
52 | const z = v1.x * v2.y - v1.z * v2.x;
53 | return new Vector3(x, y, z);
54 | }
55 |
56 | public static normalize(v: Vector3): Vector3 {
57 | return Vector3.divide(v, v.Length);
58 | }
59 |
60 | constructor(public x: number, public y: number, public z: number) {}
61 |
62 | public clone(): Vector3 {
63 | return new Vector3(this.x, this.y, this.z);
64 | }
65 |
66 | /**
67 | * The product of the Euclidean magnitudes of this and another Vector3.
68 | *
69 | * @param v Vector3 to find Euclidean magnitude between.
70 | * @returns Euclidean magnitude with another vector.
71 | */
72 | public distanceSquared(v: Vec3): number {
73 | const w: Vector3 = this.subtract(v);
74 | return Vector3.dotProduct(w, w);
75 | }
76 |
77 | /**
78 | * The distance between two Vectors.
79 | *
80 | * @param v Vector3 to find distance between.
81 | * @returns Distance between this and another vector.
82 | */
83 | public distance(v: Vec3): number {
84 | return Math.sqrt(this.distanceSquared(v));
85 | }
86 |
87 | public get normalize(): Vector3 {
88 | return Vector3.normalize(this);
89 | }
90 |
91 | public crossProduct(v: Vec3): Vector3 {
92 | return Vector3.crossProduct(this, v);
93 | }
94 |
95 | public dotProduct(v: Vec3): number {
96 | return Vector3.dotProduct(this, v);
97 | }
98 |
99 | public add(v: number | Vec3): Vec3 {
100 | return Vector3.add(this, v);
101 | }
102 |
103 | public subtract(v: Vec3): Vector3 {
104 | return Vector3.subtract(this, v);
105 | }
106 |
107 | public multiply(v: number | Vec3): Vector3 {
108 | return Vector3.multiply(this, v);
109 | }
110 |
111 | public divide(v: number | Vec3): Vec3 {
112 | return Vector3.divide(this, v);
113 | }
114 |
115 | public replace(v: Vec3): void {
116 | this.x = v.x;
117 | this.y = v.y;
118 | this.z = v.z;
119 | }
120 |
121 | public get Length(): number {
122 | return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z);
123 | }
124 | }
125 |
--------------------------------------------------------------------------------
/src/utils/index.ts:
--------------------------------------------------------------------------------
1 | export { Vector3 } from './Vector3';
2 | export { stringToArray, measureString, measureStringWidthNoConvert } from './String';
3 | export { LiteEvent } from './LiteEvent';
4 | export { PointF } from './PointF';
5 | export { uuidv4 } from './UUIDV4';
6 | export { Point } from './Point';
7 | export { Color } from './Color';
8 | export { clamp, getRandomInt } from './Math';
9 | export { Size } from './Size';
10 | export { Quaternion } from './Quaternion';
11 |
--------------------------------------------------------------------------------
/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "es6",
4 | "module": "commonjs",
5 | "declaration": true,
6 | "outDir": "./lib",
7 | "types": ["@citizenfx/client"]
8 | },
9 | "include": ["src"],
10 | "exclude": ["node_modules", "**/__tests__/*"]
11 | }
12 |
--------------------------------------------------------------------------------
/typedoc.json:
--------------------------------------------------------------------------------
1 | {
2 | "inputFiles": ["./src"],
3 | "mode": "file",
4 | "out": "docs",
5 | "name": "fivem-js - Documentation",
6 | "theme": "node_modules/typedoc-fivemjs-theme/bin/default",
7 | "readme": "none",
8 | "ignoreCompilerErrors": "true",
9 | "experimentalDecorators": "true",
10 | "emitDecoratorMetadata": "true",
11 | "excludePrivate": true,
12 | "excludeProtected": true,
13 | "target": "es6",
14 | "moduleResolution": "node",
15 | "stripInternal": "true",
16 | "suppressExcessPropertyErrors": "false",
17 | "suppressImplicitAnyIndexErrors": "false",
18 | "module": "commonjs"
19 | }
--------------------------------------------------------------------------------