Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
xLuxy committed May 28, 2024
2 parents c31ed89 + 7d08b18 commit b873f89
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 10 deletions.
25 changes: 20 additions & 5 deletions client/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2602,20 +2602,30 @@ declare module "alt-client" {
export function emitRpc<K extends string>(rpcName: Exclude<K, keyof shared.ICustomClientServerRpc>, ...args: any[]): Promise<any>;

/**
* Subscribes to a client event with the specified listener.
* Subscribes to a server -> client RPC with the specified listener.
* @param rpcName Name of the RPC
* @param listener Listener that should be added.
* @param listener Listener to be assigned to this RPC name (there can only be one listener for each RPC name).
*
* * @example
* ```js
* alt.onRpc("testRpc", (...args) => {
* alt.log(`server called testRpc`, args);
*
* @remarks The return value of the listener function determines the response clients will receive. When returning multiple values, use an array. Returning an Error object will cause the promise on the server to throw an exception which has to be caught.
* // throw new Error("I am an error! Notice me!");
* return [1, 2, [10, 13, 19], false, "hey there"];
* });
* ```
*
* @remarks The return value of the listener function determines the response server will receive. When returning multiple values, use an array. Returning an Error object will cause the promise on the server to throw an exception which has to be caught.
*
*/
export function onRpc<K extends keyof shared.ICustomServerClientRpc>(rpcName: K, listener: (...args: Parameters<shared.ICustomServerClientRpc[K]>) => Promise<ReturnType<shared.ICustomClientServerRpc[K]>> | ReturnType<shared.ICustomClientServerRpc[K]>): void;
export function onRpc<K extends keyof shared.ICustomServerClientRpc>(rpcName: K, listener: (...args: Parameters<shared.ICustomServerClientRpc[K]>) => Promise<ReturnType<shared.ICustomServerClientRpc[K]>> | ReturnType<shared.ICustomServerClientRpc[K]>): void;
export function onRpc<K extends string>(rpcName: Exclude<K, keyof shared.ICustomServerClientRpc>, listener: (...args: any[]) => Promise<any> | any): void;

/**
*
* @param rpcName Name of the RPC
* @param listener Listener that should be added.
* @param listener Listener that should be removed (if not passed current listener will be removed).
*
*/
export function offRpc<K extends keyof shared.ICustomServerClientRpc>(rpcName: K, listener?: (...args: Parameters<shared.ICustomServerClientRpc[K]>) => Promise<ReturnType<shared.ICustomServerClientRpc[K]>> | ReturnType<shared.ICustomServerClientRpc[K]>): void;
Expand Down Expand Up @@ -3927,6 +3937,11 @@ declare module "alt-client" {
*/
public static getByScriptID(scriptID: number): Ped | null;

/**
* Gets the ped with the given remote id
*/
public static getByRemoteID(id: number): Ped | null;

public static readonly all: readonly Ped[];

public static readonly streamedIn: readonly Ped[];
Expand Down
2 changes: 1 addition & 1 deletion docs/articles/events/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ alt.on('playerConnect', player => {
The client may only emit data to the server-side with `emitServer` or `emitServerRaw`.
`emitServerRaw` is used for big data and is faster than `emitServer` and `emitServerRaw` only works, if the server is using javascript.

The server-side `onServer` event handlers will automatically receive the player that sent the event as the first argument.
The server-side `onClient` event handlers will automatically receive the player that sent the event as the first argument.

# [Client-side](#tab/tab2-0)
```js
Expand Down
1 change: 1 addition & 0 deletions docs/articles/setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ This article will explain how to setup an alt:V server with the JS module.
- Basic knowledge of command prompts
- VC Redist Latest Version installed
- Windows 10+ or Linux (For running the server)
- On Linux you need the package libatomic1 `apt-get install libatomic1`

## Summary

Expand Down
7 changes: 4 additions & 3 deletions server/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3000,9 +3000,9 @@ declare module "alt-server" {
export function emitAllClientsUnreliable<K extends string>(eventName: Exclude<K, keyof shared.ICustomServerClientEvent>, ...args: any[]): void;

/**
* Subscribes to a client event with the specified listener.
* Subscribes to a client -> server RPC with the specified listener.
* @param rpcName Name of the RPC
* @param listener Listener that should be added.
* @param listener Listener to be assigned to this RPC name (there can only be one listener for each RPC name).
*
* @example
* ```js
Expand All @@ -3013,6 +3013,7 @@ declare module "alt-server" {
* return [1, 2, [10, 13, 19], false, "hey there"];
* });
* ```
*
* @remarks The return value of the listener function determines the response clients will receive. When returning multiple values, use an array. Returning an Error object will cause the promise on the client to throw an exception which has to be caught.
*
*/
Expand All @@ -3022,7 +3023,7 @@ declare module "alt-server" {
/**
*
* @param rpcName Name of the RPC
* @param listener Listener that should be added.
* @param listener Listener that should be removed (if not passed current listener will be removed).
*
*/
export function offRpc<K extends keyof shared.ICustomClientServerRpc>(rpcName: string, listener: (player: Player, ...args: Parameters<shared.ICustomClientServerRpc[K]>) => Promise<ReturnType<shared.ICustomClientServerRpc[K]>> | ReturnType<shared.ICustomClientServerRpc[K]>): void;
Expand Down
2 changes: 1 addition & 1 deletion server/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@altv/types-server",
"version": "16.0.7",
"version": "16.0.8",
"description": "This package contains types definitions for alt:V server-side module.",
"types": "index.d.ts",
"files": [
Expand Down

0 comments on commit b873f89

Please sign in to comment.