Jump to content

One resource or few in gamemode.


One resource or few in gamemode.?  

17 members have voted

  1. 1. One resource or few in gamemode.?

    • Many resources
      10
    • One resource with many scripts
      7


Recommended Posts

  • Moderators

Both choices have benefits, but it has nothing to do with optimization. You won't notice those extra execution time for exports. As long as you use more exports in stead of custom events, everything is al right.

This is a choice for the developer, based on his knowledge and logic thinking.

Some resources can be placed together and others can better not.

Link to comment

A rather experienced scripter told me that he batched all of his gamemode scripts into a single resource and it ran more efficiently and was apparently many times faster than with multiple resources. You have a few more advantages with single resource too, as you can properly manage classes and objects without hassle. Also makes compiling easier, as you can ultimately compile your whole gamemode into two or three files: client and server, and additionally shared.

You need to make sure you start building the gamemode properly. Building it wrong at first will come around and stab you in the back easily. Properly name your methods and functions. Use events whenever needed, but minimize the amount of events. Stack things together. Make use of Lua's coroutines and use tables efficiently.

Updating the gamemode will become more difficult on a live server, if you want to perform live updates. Other than that you're good (live updates are never good anyway).

Link to comment
  • MTA Team
Updating the gamemode will become more difficult on a live server, if you want to perform live updates. Other than that you're good (live updates are never good anyway).

For live updates: Scheduled server restarts should happen every week (or every day) and only a stable script package should be on the "production" system. You should also control the memory/cpu usage if you keep the server running to check if there are any leaks in your script, which occur when the server runs under load (with players).

About the part with the performance: I once made a local math.clamp and an exported function math_clamp (from an util resource) and tested the amount of times they were executed in a second. The local function had about 3200 calls and the exported function had something around 900 - 1000 if I recall correctly. You can say it's 3 times faster. As conclusion, you are likely to run into performance issues if you have many resources, which use exported functions.

Try to make a main resource with the "critical" code and various other resources without exported functions, which purely work with events and no more, to avoid using the exported functions.

Link to comment

What about the development process though? You'll have to restart the whole game-mode to implement any change, however small it is. Another disadvantage is extensibility and collaboration. It won't be a walk in the park to allow others to contribute and test their work.

The major advantage for me is OOP, classes and objects are much easier to work with.

Link to comment
What about the development process though? You'll have to restart the whole game-mode to implement any change, however small it is. Another disadvantage is extensibility and collaboration. It won't be a walk in the park to allow others to contribute and test their work.

The major advantage for me is OOP, classes and objects are much easier to work with.

Indeed. These are the things for a single resource.

Really depends what you are doing and how are you doing it from a technical point of view.

You could have everything set into their own resources, but then you would have your own compiler which compiles all resources into a single package with just those three core files that run the server script. It could work, but there could be conflicts, and that's never good.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...