Page 1 of 1

How to make MP-compatible mod?

Posted: Sat Sep 30, 2017 10:38 am
by Eliont
Hello and good time of day.

How to ensure that (existing, my own) mod work well in multiplayer?
Many scripting, many new entities.

Is there some recomedndations somewhere?

Thanks in advance.

Re: How to make MP-compatible mod?

Posted: Sat Sep 30, 2017 6:35 pm
by Rseding91
Just a few things:
  • Store all of your mutable variables in the "global" table. If you don't know what mutable means - just store all of your variables in the "global" table.
  • Only run code in reaction to a event
  • Make sure you don't mutate things in the on_load event. If you don't know what that means just avoid the on_load event.
Past that, it should 'just work'.

Re: How to make MP-compatible mod?

Posted: Mon Oct 02, 2017 8:20 am
by bobingabout
use game.players[#]. instead of game.player.

Re: How to make MP-compatible mod?

Posted: Mon Oct 02, 2017 8:30 am
by Bilka
bobingabout wrote:use game.players[#]. instead of game.player.
game.player also doesn't work in singleplayer... it's only available from the console, nowhere else

Re: How to make MP-compatible mod?

Posted: Tue Oct 03, 2017 8:59 am
by bobingabout
Bilka wrote:
bobingabout wrote:use game.players[#]. instead of game.player.
game.player also doesn't work in singleplayer... it's only available from the console, nowhere else
you'd be surprised how many mods fail to work because they've used game.player in their scripting.

Re: How to make MP-compatible mod?

Posted: Tue Oct 03, 2017 9:11 am
by ratchetfreak
bobingabout wrote:use game.players[#]. instead of game.player.
but don't ever hardcode game.players[1], instead either loop over all players or use the player involved in whatever event that triggered the code