Skip to content

Commit 4d9b30f

Browse files
Add player communication
1 parent 7b35d13 commit 4d9b30f

File tree

3 files changed

+39
-1
lines changed

3 files changed

+39
-1
lines changed

api/AltV.Net.NetworkingEntity/EntityStreamer.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using AltV.Net.NetworkingEntity.Elements.Entities;
22
using Entity;
3-
using Google.Protobuf;
43

54
namespace AltV.Net.NetworkingEntity
65
{
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Player communication
2+
3+
On serverside two ways exists to send data to clients.
4+
5+
The first way is to use ```Alt.EmitAllClients(eventName, args)``` to send data to all connected clients.
6+
7+
The second way sends data to a specific player directly via ```player.Emit(eventName, args)```.
8+
9+
args expects a ```object[]```.
10+
11+
Supported arguments types inside the array are ```object```, ```bool```, ```int```, ```long```, ```uint```, ```ulong```, ```float```, ```double```, ```string```, ```IPlayer``` (or any types extending IPlayer), ```IVehicle``` (or any types extending IVehicle), ```Dictionary<string, (any type listed here)```, ```Alt.Function```, any type listed here as array e.g. int[].
12+
Also any dictionary in dictionary, array in array, ect. endless depth types are supported, because they are resolved recursively.
13+
14+
## Clientside
15+
16+
To catch the event inside clientside javascript.
17+
18+
```js
19+
import * as alt from "alt";
20+
21+
alt.onServer(eventName, (args) => {
22+
23+
});
24+
// or
25+
alt.onServer(eventName, (arg1, arg2) => {
26+
27+
});
28+
// ect.
29+
```
30+
31+
To send events to server from clientside javascript.
32+
33+
```js
34+
import * as alt from "alt";
35+
36+
alt.emitServer(eventName, args);
37+
```

docs/articles/toc.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
href: build-in-events.md
1515
- name: Custom events
1616
href: custom-events.md
17+
- name: Player communication
18+
href: player-communication.md
1719
- name: Communication between resources
1820
href: resource-communication.md
1921
- name: Entity factories

0 commit comments

Comments
 (0)