Skip to content

Commit 7b933f5

Browse files
Merge branch 'master' into dev
2 parents a932a70 + ba04083 commit 7b933f5

File tree

1 file changed

+34
-34
lines changed

1 file changed

+34
-34
lines changed

README.md

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -393,63 +393,63 @@ AltColShape.OnEntityEnterColShape = (entity, shape) => {
393393

394394
### Experimental entity streaming
395395

396-
https://github.com/FabianTerhorst/coreclr-module/releases/download/1.7.6-beta6/networking-entity.zip
397-
398-
Include the js file in your index.html
399-
```html
400-
<script type="module" src="networking-entity.js"></script>
401-
```
402-
Add the networking-entity.js and entity.proto file to your client config and save the entity.proto in top level of client files
403-
Add the https://www.nuget.org/packages/AltV.Net.NetworkingEntity/ to your project where you want to run the server
396+
https://github.com/FabianTerhorst/coreclr-module/releases/download/cdntest1.12.0-beta/networking-entity.zip
397+
Extract the files from the zip and put them into resources/networking-entity.
398+
Add the https://www.nuget.org/packages/AltV.Net.NetworkingEntity/ dependency to your server.
399+
When running on server don't forget to open the websocket port 46429 or change it to a own port.
400+
You need to call ``AltNetworking.Configure`` even when you don't want to modify the default port.
404401
```csharp
405-
AltNetworking.Init();
406-
AltNetworking.CreateEntity(new Position {X = 0, Y = 0, Z = 73}, 1, 50, new Dictionary<string, object>());
402+
AltNetworking.Configure(options =>
403+
{
404+
options.Port = 46429;
405+
});
406+
var data = new Dictionary<string, object>(); // This is the entity data, the streamer on clientside will receive it with entity.data
407+
data["model"] = "a_c_deer";
408+
AltNetworking.CreateEntity(new Position {X = 0, Y = 0, Z = 73}, 1, 50, data);
409+
```
410+
Add the networking-entity as a dependency to your client resource.
411+
```
412+
deps: [
413+
networking-entity
414+
]
407415
```
408-
Add the client.js to your client and maybe rename the file
409-
Use it like this
416+
Import the networking-entity resource in your client script and setup it.
410417
```js
411-
import { create, onStreamIn, onStreamOut, onDataChange } from "client/streaming/client.js";
412-
import game from "natives";
413-
import hudWebView from "client/hud-webview.js";
418+
import networkingEntity from "networking-entity";
419+
networkingEntity.create();
420+
```
421+
Now you can write a own streamer to receive the entities and convert them into game objects ect.
422+
Tip: You can also call the `networkingEntity.create();` in the constructor of the streamer.
423+
```js
424+
//File: my-streamer.js
425+
import networkingEntity from "networking-entity";
414426

415427
class EntityStreamer {
416428
constructor() {
417-
create(hudWebView);
418-
this.peds = new Map();
419429
this.onStreamIn = this.onStreamIn.bind(this);
420430
this.onStreamOut = this.onStreamOut.bind(this);
421431
this.onDataChange = this.onDataChange.bind(this);
422-
onStreamIn(this.onStreamIn);
423-
onStreamOut(this.onStreamOut);
424-
onDataChange(this.onDataChange);
432+
networkingEntity.onStreamIn(this.onStreamIn);
433+
networkingEntity.onStreamOut(this.onStreamOut);
434+
networkingEntity.onDataChange(this.onDataChange);
425435
}
426436

427437
onStreamIn(entity) {
428-
const ped = game.createPed(2, 1885233650, entity.position.x, entity.position.y, entity.position.z, 61, false, true);
429-
this.peds.set(entity.id, ped);
430438

431439
}
432440

433441
onStreamOut(entity) {
434-
if (this.peds.has(entity.id)) {
435-
game.deleteEntity(this.peds.get(entity.id));
436-
}
442+
437443
}
438444

439445
onDataChange(entity, data) {
440-
//TODO: when model changes ect.
446+
441447
}
442-
443448
}
444449

445450
export default new EntityStreamer();
446451
```
447-
Import the streamer in your main client file
452+
Now you just need to import the streamer from your client code.
448453
```js
449-
import "client/entity-streamer.js";
454+
import 'client/my-streamer.js';
450455
```
451-
When running on server don't forget to open the websocket port 46429 or change it to a own port with
452-
```csharp
453-
AltNetworking.Init(new NetworkingModule(myPort))
454-
```
455-

0 commit comments

Comments
 (0)