@@ -348,3 +348,64 @@ namespace AltV.Net.Example
348348 [ IVehicle] ( https://github.com/FabianTerhorst/coreclr-module/blob/master/api/AltV.Net/Elements/Entities/IVehicle.cs )
349349 [ IBlip] ( https://github.com/FabianTerhorst/coreclr-module/blob/master/api/AltV.Net/Elements/Entities/IBlip.cs )
350350 [ ICheckpoint] ( https://github.com/FabianTerhorst/coreclr-module/blob/master/api/AltV.Net/Elements/Entities/ICheckpoint.cs )
351+
352+ ### Experimental entity streaming
353+
354+ Include the js file in your index.html
355+ ``` html
356+ <script type =" module" src =" networking-entity.js" ></script >
357+ ```
358+ Add the networking-entity.js and entity.proto file to your client config and save the entity.proto in top level of client files
359+ Add the https://www.nuget.org/packages/AltV.Net.NetworkingEntity/ to your project where you want to run the server
360+ ``` csharp
361+ AltNetworking .Init ();
362+ AltNetworking .CreateEntity (new Position {X = 0 , Y = 0 , Z = 73 }, 1 , 50 , new Dictionary <string , object >());
363+ ```
364+ Add the client.js to your client and maybe rename the file
365+ Use it like this
366+ ``` js
367+ import { create , onStreamIn , onStreamOut , onDataChange } from " client/streaming/client.js" ;
368+ import game from " natives" ;
369+ import hudWebView from " client/hud-webview.js" ;
370+
371+ class EntityStreamer {
372+ constructor () {
373+ create (hudWebView .webview );
374+ this .peds = new Map ();
375+ this .onStreamIn = this .onStreamIn .bind (this );
376+ this .onStreamOut = this .onStreamOut .bind (this );
377+ this .onDataChange = this .onDataChange .bind (this );
378+ onStreamIn (this .onStreamIn );
379+ onStreamOut (this .onStreamOut );
380+ onDataChange (this .onDataChange );
381+ }
382+
383+ onStreamIn (entity ) {
384+ const ped = game .createPed (2 , 1885233650 , entity .position .x , entity .position .y , entity .position .z , 61 , false , true );
385+ this .peds .set (entity .id , ped);
386+
387+ }
388+
389+ onStreamOut (entity ) {
390+ if (this .peds .has (entity .id )) {
391+ game .deleteEntity (this .peds .get (entity .id ));
392+ }
393+ }
394+
395+ onDataChange (entity , data ) {
396+ // TODO: when model changes ect.
397+ }
398+
399+ }
400+
401+ export default new EntityStreamer ();
402+ ```
403+ Import the streamer in your main client file
404+ ``` js
405+ import " client/entity-streamer.js" ;
406+ ```
407+ When running on server don't forget to open the websocket port 46429 or change it to a own port with
408+ ``` csharp
409+ AltNetworking .Init (new NetworkingModule (myPort ))
410+ ```
411+
0 commit comments