Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to setup resources dependencies in alt:V

I have seen that it is possible to have dependencies between multiple resources. So that resource1 uses functionality of resource2. How does the communication between resources work?

When should I separate scripts in different resources? Is it better to stick to one resource for a whole gamemode or to split it up?

Cheers

like image 938
Felix C Avatar asked Jul 24 '20 10:07

Felix C


1 Answers

Serverside

Each resource is isolated from each other. The resources are using the cpp-sdk for communication. The isolation is depending on the script runtime. Some runtimes like c# support sharing memory between resources, while nodejs doesn't support sharing memory between resources running on different threads. You always have to explicitly tell the runtime which functions and data you want to expose to other resources. This means that you have a small runtime overhead when calling a function or accessing the data, because the communication data needs to be serialized to the unmanaged cpp memory and then back again to the memory of the other resource. When the runtime supports sharing the same memory this overhead doesn't happen between resources with the same type. When sticking to a single resource you don't have the runtime overhead but can't swap out resources individually.

Clientside

Its basically the same as for serverside with the exception that currently only a v8 javascript module exists that doesn't support sharing memory between resources. For clientside the overhead of calling other resources most likely doesn't matter as much as for serverside. Especially when you want to reduce the cpu intensive tasks the server main thread has to execute. For clientside multiple resources also reduce the amount of data the client has to download, because when you change something in a resource the client has to redownload the whole resource.

tl;dr

Serverside

When performance matters most stick to a single resource for serverside. When you need to swap out resources from time to time use multiple resources.

Clientside

Use multiple resources when you use resources from other people or want to have a modulized resource. Split your assets (mods, images, ...) in as many resources ,that make sense, as possible to reduce data download when changes are happening.

like image 134
H3x0n Avatar answered Oct 17 '22 20:10

H3x0n