Community-driven type definitions for RAGE Multiplayer
Remember to 🌟 this GitHub if you 💖 it.
🔥 Use github:ragempcommunity/ragemp-types#types-server
to latest build
# With npm
> npm i --save-dev @ragempcommunity/types-server
# With yarn
> yarn add -D @ragempcommunity/types-server
# With pnpm
> pnpm add -D @ragempcommunity/types-server
🔥 Use github:ragempcommunity/ragemp-types#types-client
to latest build
# With npm
> npm i --save-dev @ragempcommunity/types-client
# With yarn
> yarn add -D @ragempcommunity/types-client
# With pnpm
> pnpm add -D @ragempcommunity/types-client
🔥 Use github:ragempcommunity/ragemp-types#types-cef
to latest build
# With npm
> npm i --save-dev @ragempcommunity/types-cef
# With yarn
> yarn add -D @ragempcommunity/types-cef
# With pnpm
> pnpm add -D @ragempcommunity/types-cef
To make these types detectable, you need to add the
types
property below totsconfig.json
on each side of your project.
To avoid conflicts between server and client types, they must be installed and set as follows:
Step #1: install the types in package.json from the project root
> npm i --save-dev @ragempcommunity/types-server
> npm i --save-dev @ragempcommunity/types-client
Step #2: for this step, your project should be structured as follows:
├───my-awesome-ragemp-server
│ └───src
│ # Server - Contains code relating to the database, player spawning, etc.
│ # Client - Contains code to display things to the user and do things to them.
│ ├───client
│ │ ├───@types
│ │ │ └───index.d.ts
│ │ ├───src
│ │ └───tsconfig.json
│ │
│ server
│ │ ├───@types
│ │ │ └───index.d.ts
│ │ ├───src
│ │ └───tsconfig.json
│ └───
├───package.json
└───tsconfig.base.json
Now that we know what our server structure should look like, let's start setting the types properly.
tsconfig.base.json
- this is our base tsconfig, from which we extend the client/server part (to avoid making redundant code)
{
"exclude": ["node_modules", "dist"],
"compileOnSave": true,
"compilerOptions": {
"target": "esnext",
"module": "esnext",
"moduleResolution": "node",
"lib": ["es6", "esnext", "DOM"],
"rootDir": ".",
"outDir": "dist",
"baseUrl": "./"
}
}
client/tsconfig.json
- this is our tsconfig for the client side, extended from the basic tsconfig and containing the types for the client
{
// NOTE: This tsconfig will work assuming your project is structured as described above.
"extends": "../../tsconfig.base.json",
"compilerOptions": {
// [RELATIVE_PATH_TO_NODE_MODULES]/@ragempcommunity/types-client
"types": ["../../node_modules/@ragempcommunity/types-client", "./@types"]
},
"include": ["./**/*.ts"]
}
server/tsconfig.json
- this is our tsconfig for the server side, extended from the basic tsconfig and containing the types for the server
{
// NOTE: This tsconfig will work assuming your project is structured as described above.
"extends": "../../tsconfig.base.json",
"compilerOptions": {
// [RELATIVE_PATH_TO_NODE_MODULES]/@ragempcommunity/types-server
"types": ["../../node_modules/@ragempcommunity/types-server", "./@types"]
},
"include": ["./**/*.ts"]
}
For those who didn't understand, I made a gamemode from which you can better orient yourself:
ragemp-typescript & ragemp-javascript
To contribute to this repository, feel free to create a new fork of the repository and submit a pull request.
- Fork / Clone and select the
main
branch. - Create a new branch in your fork.
- Make your changes.
- Commit your changes and push them.
- Submit a Pull Request here!
- CocaColaBear - Creator of types-ragemp-s & types-ragemp-c
- KsenonAdv - moral support
This project is licensed under the MIT License — see the LICENSE file for details.