Created by LeonMrBonnie
❤️ Support me by becoming a Patron
⭐ This repository if you found it useful!
This repository provides an alt:V resource to work with the C# Entity Sync in JS.
It provides an easy base class for entities that you can expand for you own entities.
This resource handles the showing/removing of entities for you, you only need to create you own entity types.
I cannot stress this enough. Ensure you have NodeJS 13+ or you will have problems.
- NodeJS 13+
- An Existing or New Gamemode
- General Scripting Knowledge
First download the JS wrapper for the C# entity sync from GitHub.
Then you need to build it using dotnet publish -c Release
and create a new resource with the type csharp
.
You should name this resource entitysync-wrapper
.
After that simply add the name of this resource to your server.cfg
resource section.
altv-os-js-entitysync
And also add the name of this resource to the deps
array of your resource.cfg
from your main gamemode.
Also add the entitysync-wrapper
to the deps
array of your resource.
Then simply clone this repository into your main server resources folder.
cd resources
git clone https://github.com/LeonMrBonnie/altv-os-js-entitysync
Ensure your package.json
includes this property:
"type": "module"
For every new entity type (textlabel, object, ped etc.) you need to create a new Class that extends the base Entity class.
To do that you need to import this resource and extend from the Entity
class. Then you can use the entity data etc.
Make sure that every new Entity class has its own unique type
id. Else it will cause conflicts. For more info take a look at the Entity Sync Documentation
You can find an example in server/textlabel-example.js
and client/textlabel-example.js
! IMPORTANT !
All your files related to the entity sync have to be in the same resource, because you can't export and import a class.
So you have to put all the files from this resource into your own resource.
- Stuyk - For the drawtext3d function used in the example and this readme layout, as well as his other contributions to the alt:V community
- Fabian Terhorst aka. Heron - For creating the C# module as well as creating the C# Entity Sync
- Kudze - For creating the JS wrapper for the C# Entity Sync