From f3e4ae08f823d55d5a7e6e7d5500ddec1a6e43fa Mon Sep 17 00:00:00 2001 From: xLuxy <67131061+xLuxy@users.noreply.github.com> Date: Wed, 28 Feb 2024 11:41:29 +0100 Subject: [PATCH 01/10] ci(shared): Bump version --- shared/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shared/package.json b/shared/package.json index 235bfc6a..2b490019 100644 --- a/shared/package.json +++ b/shared/package.json @@ -1,6 +1,6 @@ { "name": "@altv/types-shared", - "version": "16.0.1", + "version": "16.0.2", "description": "This package contains types definitions for alt:V JS module shared types.", "types": "index.d.ts", "files": [ From 8599d0b7a4e4a23f38eb7b7dc61013f678c1545e Mon Sep 17 00:00:00 2001 From: xshady <54737754+xxshady@users.noreply.github.com> Date: Thu, 14 Mar 2024 14:10:34 +0300 Subject: [PATCH 02/10] fix(server): virtual entity description (#306) --- server/index.d.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/server/index.d.ts b/server/index.d.ts index cdefa1fe..a88b3d19 100644 --- a/server/index.d.ts +++ b/server/index.d.ts @@ -727,6 +727,7 @@ declare module "alt-server" { public pos: shared.Vector3; } + /** https://docs.altv.mp/articles/virtualentity.html */ export class VirtualEntityGroup extends BaseObject { /** Creates a new Virtual Entity Group */ public constructor(maxEntitiesInStream: number); @@ -734,7 +735,10 @@ declare module "alt-server" { /** Returns all Virtual Entity Group instances */ public static readonly all: readonly VirtualEntityGroup[]; - /** Maximum streaming range inside the Virtual Entity Group */ + /** + * Max number of entities per player stream. + * More info: https://docs.altv.mp/articles/virtualentity.html#what-is-max-number-of-entities-per-player-stream + */ public readonly maxEntitiesInStream: number; } From 5860297bc844300657b7d0b052260023a61615d0 Mon Sep 17 00:00:00 2001 From: xshady <54737754+xxshady@users.noreply.github.com> Date: Thu, 14 Mar 2024 14:13:06 +0300 Subject: [PATCH 03/10] chore: update imports in examples (#303) --- docs/articles/create-your-first-resource.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/articles/create-your-first-resource.md b/docs/articles/create-your-first-resource.md index cd8b3d0f..fc3791d6 100644 --- a/docs/articles/create-your-first-resource.md +++ b/docs/articles/create-your-first-resource.md @@ -55,7 +55,7 @@ deps = [ You can access exported functions & more by adding the following in your code: ```js -import * as chat from 'chat'; +import * as chat from 'alt:chat'; ``` **main** is the main server file. @@ -68,13 +68,13 @@ import * as chat from 'chat'; Creating Server-side Code - server.js We're going to add **chat** as a dependency to our resource. -Then we're going to import 'alt' and 'chat'. +Then we're going to import 'alt-server' and 'alt:chat'. ```js // alt:V built-in module that provides server-side API. import * as alt from 'alt-server'; // Your chat resource module. -import * as chat from 'chat'; +import * as chat from 'alt:chat'; console.log('==> Your Resource Has Loaded! Horray!'); From 994a80c81cf487cb508cc291e232e45de9c4aa28 Mon Sep 17 00:00:00 2001 From: xshady <54737754+xxshady@users.noreply.github.com> Date: Thu, 14 Mar 2024 14:13:37 +0300 Subject: [PATCH 04/10] chore: remove outdated event beforePlayerConnect (#304) --- docs/articles/events/before-player-connect.md | 29 ------------------- docs/articles/toc.yml | 3 -- 2 files changed, 32 deletions(-) delete mode 100644 docs/articles/events/before-player-connect.md diff --git a/docs/articles/events/before-player-connect.md b/docs/articles/events/before-player-connect.md deleted file mode 100644 index 6ffece49..00000000 --- a/docs/articles/events/before-player-connect.md +++ /dev/null @@ -1,29 +0,0 @@ -# beforePlayerConnect - -## A General Overview - - You can find information about the types here. (click to redirect) - -This event is where servers can kick users before the actual connection. For example, if the player is banned. - -## Example - -```js -import alt from "alt-server"; - -alt.on('beforePlayerConnect', (connectionInfo) => { - alt.log(connectionInfo.branch); // Prints out the current branch. - alt.log(connectionInfo.authToken); // Prints out the authToken. - alt.log(connectionInfo.build); // Prints out the current build number. - alt.log(connectionInfo.cdnUrl); // Prints out the URL of the CDN. - alt.log(connectionInfo.hwidExHash); // Prints out the ExHash of the client's HWID. - alt.log(connectionInfo.hwidHash); // Prints out the Hash of the client's HWID. - alt.log(connectionInfo.isDebug); // Prints out whether the client is in debug mode. - alt.log(connectionInfo.passwordHash); // Prints out a hash of the password that was used to connect to the server. - alt.log(connectionInfo.socialID); // Prints out the social ID of the client. - - if(connectionInfo.passwordHash !== alt.hashServerPassword('myPassword')) { - return false; - } -}); -``` diff --git a/docs/articles/toc.yml b/docs/articles/toc.yml index adfa7716..a3392c46 100644 --- a/docs/articles/toc.yml +++ b/docs/articles/toc.yml @@ -11,9 +11,6 @@ href: import-assertions.md - name: Events href: events/index.md - items: - - name: beforePlayerConnect - href: events/before-player-connect.md - name: Player href: player/index.md items: From 1a3baf2ca7489cc0aad215a231a2a86e14079168 Mon Sep 17 00:00:00 2001 From: xshady <54737754+xxshady@users.noreply.github.com> Date: Thu, 14 Mar 2024 14:14:23 +0300 Subject: [PATCH 05/10] chore: add package.json to first resource article (#302) --- docs/articles/create-your-first-resource.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/docs/articles/create-your-first-resource.md b/docs/articles/create-your-first-resource.md index fc3791d6..882d9527 100644 --- a/docs/articles/create-your-first-resource.md +++ b/docs/articles/create-your-first-resource.md @@ -20,6 +20,23 @@ server/ ├── server.toml ``` +Before creating an example resource we need to create package.json in the root with the following content so we can use ES6 modules on serverside. +```json +{ + "type": "module" +} +``` + +So in the end our server folder structure should look like this: +``` +server/ +... +├── altv-server.exe +├── libnode.dll +├── server.toml +├── package.json // <--------- here +``` + Let's create an example resource. ``` From bf4425c772d157eee2fd7a1dcf34ff8688ec006d Mon Sep 17 00:00:00 2001 From: xshady <54737754+xxshady@users.noreply.github.com> Date: Fri, 15 Mar 2024 01:43:05 +0300 Subject: [PATCH 06/10] feat: add server debugging article (#309) --- docs/articles/debugging-server-code.md | 34 ++++++++++++++++++++++++++ docs/articles/toc.yml | 3 ++- 2 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 docs/articles/debugging-server-code.md diff --git a/docs/articles/debugging-server-code.md b/docs/articles/debugging-server-code.md new file mode 100644 index 00000000..32468b3e --- /dev/null +++ b/docs/articles/debugging-server-code.md @@ -0,0 +1,34 @@ +# Debugging server code + +alt:V allows you to debug your server-side code just like you would do in [NodeJS](https://nodejs.org/en/learn/getting-started/debugging). + +## How? + +1. Enable inspector in `resource.toml`. + +```toml +type = 'js' +main = 'main.js' + +[inspector] +# You can also specify host and port if needed +# (127.0.0.1:9229 by default) +# host = '127.0.0.1' +# port = '9999' +``` + +2. Add NodeJS interval with 0 delay. + +```js +setInterval(() => {}, 0) +``` + +3. Now you should be able to connect to inspector via Chrome DevTools for example: + + 1. Open any webpage in Chrome + 2. Press f12 to open console + 3. Click on NodeJS icon + +Video tutorial: + + diff --git a/docs/articles/toc.yml b/docs/articles/toc.yml index a3392c46..5befd658 100644 --- a/docs/articles/toc.yml +++ b/docs/articles/toc.yml @@ -48,4 +48,5 @@ href: vehicle/train-api.md - name: Workers href: workers.md - +- name: Debugging server code + href: debugging-server-code.md From c86040610904bf004e91f66de01ac02f74feeed7 Mon Sep 17 00:00:00 2001 From: xshady <54737754+xxshady@users.noreply.github.com> Date: Fri, 15 Mar 2024 01:43:39 +0300 Subject: [PATCH 07/10] chore: add more descriptions for virtual entity API (#307) --- client/index.d.ts | 13 +++++++++++-- server/index.d.ts | 11 ++++++++--- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/client/index.d.ts b/client/index.d.ts index 6731ccc8..82294fde 100644 --- a/client/index.d.ts +++ b/client/index.d.ts @@ -594,17 +594,26 @@ declare module "alt-client" { public setMeta(key: K, value: shared.InterfaceValueByKey): void; } + /** [Documentation](https://docs.altv.mp/articles/virtualentity.html) */ export class VirtualEntityGroup extends BaseObject { - /** Creates a new Virtual Entity Group */ + /** + * Creates a new Virtual Entity Group + * + * @param maxEntitiesInStream Max number of entities per player stream. [More info](https://docs.altv.mp/articles/virtualentity.html#what-is-max-number-of-entities-per-player-stream). + */ public constructor(maxEntitiesInStream: number); /** Returns all Virtual Entity Group instances */ public static readonly all: readonly VirtualEntityGroup[]; - /** Maximum streaming range of the Virtual Entity Group */ + /** + * Max number of entities per player stream. + * [More info](https://docs.altv.mp/articles/virtualentity.html#what-is-max-number-of-entities-per-player-stream). + */ public readonly maxEntitiesInStream: number; } + /** [Documentation](https://docs.altv.mp/articles/virtualentity.html) */ export class VirtualEntity extends WorldObject { /** Creates a new Virtual Entity */ public constructor(group: VirtualEntityGroup, position: shared.Vector3, streamingDistance: number, data?: Record); diff --git a/server/index.d.ts b/server/index.d.ts index a88b3d19..c600de2b 100644 --- a/server/index.d.ts +++ b/server/index.d.ts @@ -727,9 +727,13 @@ declare module "alt-server" { public pos: shared.Vector3; } - /** https://docs.altv.mp/articles/virtualentity.html */ + /** [Documentation](https://docs.altv.mp/articles/virtualentity.html) */ export class VirtualEntityGroup extends BaseObject { - /** Creates a new Virtual Entity Group */ + /** + * Creates a new Virtual Entity Group + * + * @param maxEntitiesInStream Max number of entities per player stream. [More info](https://docs.altv.mp/articles/virtualentity.html#what-is-max-number-of-entities-per-player-stream). + */ public constructor(maxEntitiesInStream: number); /** Returns all Virtual Entity Group instances */ @@ -737,11 +741,12 @@ declare module "alt-server" { /** * Max number of entities per player stream. - * More info: https://docs.altv.mp/articles/virtualentity.html#what-is-max-number-of-entities-per-player-stream + * [More info](https://docs.altv.mp/articles/virtualentity.html#what-is-max-number-of-entities-per-player-stream). */ public readonly maxEntitiesInStream: number; } + /** [Documentation](https://docs.altv.mp/articles/virtualentity.html) */ export class VirtualEntity extends WorldObject { /** Creates a new Virtual Entity */ public constructor(group: VirtualEntityGroup, position: shared.Vector3, streamingDistance: number, data?: Record); From 3675e2e02a0f31cad3a0760cab3c750d07f00292 Mon Sep 17 00:00:00 2001 From: xshady <54737754+xxshady@users.noreply.github.com> Date: Fri, 15 Mar 2024 01:44:00 +0300 Subject: [PATCH 08/10] chore: edit text labels to avoid confusion with 15.0 text labels (#305) --- .../snippets/{textlabels.md => natives-textlabels.md} | 4 ++-- docs/articles/toc.yml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) rename docs/articles/snippets/{textlabels.md => natives-textlabels.md} (88%) diff --git a/docs/articles/snippets/textlabels.md b/docs/articles/snippets/natives-textlabels.md similarity index 88% rename from docs/articles/snippets/textlabels.md rename to docs/articles/snippets/natives-textlabels.md index d4f8e244..98b4ea23 100644 --- a/docs/articles/snippets/textlabels.md +++ b/docs/articles/snippets/natives-textlabels.md @@ -1,6 +1,6 @@ -# Drawing Text 3D & 2D +# Drawing Text 3D & 2D (via game natives) -Used to draw text on your screen or in a 3D space. This only works on **client-side**. +Used to draw text on your screen or in a 3D space. This only works on **client-side**. This implementation uses natives of the game, for an alternative take a look at official [Text Label API](https://docs.altv.mp/articles/textlabel.html) added in [15.0](https://docs.altv.mp/articles/changelogs/15_0.html). **Client Side** diff --git a/docs/articles/toc.yml b/docs/articles/toc.yml index 5befd658..689f158f 100644 --- a/docs/articles/toc.yml +++ b/docs/articles/toc.yml @@ -38,7 +38,7 @@ - name: Shuffle href: snippets/shuffle.md - name: Text Labels - href: snippets/textlabels.md + href: snippets/natives-textlabels.md - name: Voice href: snippets/voice.md - name: Vehicle From e75c9ed31373cf520a134d42ec7e10a5797a6bc3 Mon Sep 17 00:00:00 2001 From: xshady <54737754+xxshady@users.noreply.github.com> Date: Sun, 24 Mar 2024 02:28:35 +0300 Subject: [PATCH 09/10] feat(client): add alt.Object.streamedIn (#312) --- client/index.d.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/client/index.d.ts b/client/index.d.ts index 82294fde..3567083a 100644 --- a/client/index.d.ts +++ b/client/index.d.ts @@ -3893,6 +3893,8 @@ declare module "alt-client" { public static readonly count: number; + public static readonly streamedIn: readonly Object[]; + public readonly alpha: number; public readonly textureVariation: number; From 94fc6e6b0a19940f335fb952e8d26fd78811e2d4 Mon Sep 17 00:00:00 2001 From: xLuxy <67131061+xLuxy@users.noreply.github.com> Date: Wed, 3 Apr 2024 15:06:27 +0200 Subject: [PATCH 10/10] chore(client): Bump version --- client/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/package.json b/client/package.json index 0090e730..f1fb9721 100644 --- a/client/package.json +++ b/client/package.json @@ -1,6 +1,6 @@ { "name": "@altv/types-client", - "version": "16.0.12", + "version": "16.0.13", "description": "This package contains types definitions for alt:V client-side module.", "types": "index.d.ts", "files": [