Also, I have never been so clear on the differences between createVehicle and camCreate, some have said createVehicle would be more MP friendly, and some have said it's not...
So I've more or less just figured that no-one actually knows for sure, and went on with createVehicle...
Actually, the difference between
createVehicle and
camCreate is quite well-known. It boils down to
- The result of camCreate is local to the machine where it is issued. Ex: creating something that goes boom, for effect.
- The result of createVehicle will eventually be broadcast to all machines. Ex: creating a Jeep on the server.
As for what's best for a particular situation, well, that depends on the problem at hand. If you need to spawn something that isn't done too often (say, vehicles from a CTI type game factory),
createVehicle issued on one node only is yer daddy. For other situations, the use of camCreate can
greatly improve the performance in MP. Let's examine that further by a few examples:
Say you have an explosion script that will hurl debris around when a vehicle is destroyed. Best practice is to create said random debris on each client using
camCreate. Why? Because using lots of
createVehicle calls on one machine only will cause a lot of unneeded network traffic, causing desync. And we don't like desync at all. Good rule of thumb: if something is temporary and mostly for show/effect -> bell should ring: "aha,
camCreate time". If you use the
drop command, there's a good chance that
camCreate should/could be nearby.
In other situations, it's best to centralise control of the newly created object to one node only. Creating new vehicles and or units (using
createUnit) is where this applies.
Real-world examplesThere are a few very illustrative examples of what happens if you don't use the differences between
camCreate and
createVehicle wisely.
A cautionary note: the addons themselves are otherwise excellent and I love them to bits.
Case 1: multiple createVehicle calls on
one machine in MP
Try the Hudson/Pennywise F18 airplane. Gather a few friends for a MP session and let one person fly around in a cluster bomb-equipped F18. The effect is more noticeable the more players you have. Now have the pilot drop one or more cluster bombs and see what happens to your framerate and the desync.... The desync storm that thing creates can take out the internet for miles around :-X.
So what did they do? They use lots of
createVehicle calls on one machine to create the many cluster bomb bomlets. Result: lots of network traffic and unhappy MP players.
Case 2: multiple
createVehicle calls on
all machines in MP
Now try one of Footmunches excellent planes, say the F4 Phantom. This baby has napalm bombs on it. Here's where it gets really nasty the more players you have. Again, have one guy fly the Phantom and ripple off all the napalm canisters. If you haven't experienced
negative framerates yet, you're in for a treat ;D
Reason: the napalm effects script will do multiple
createVehicle calls on
each and every machine in the MP session. Unsurprisingly, this leads to the server and clients choking on traffic and overhead.
In both cases, by reworking the addons/scripts to use
camCreate and "dummy shells" where needed
greatly improved MP playability without changing the way the addons work and look.
Examples of good MP codingATM, I can think of only one example: the War Games League addpack (WGL), currently in version 4.12. Feel free to have a peek at how they did their MP coding for the effects department. In short, this is MP coding done right! Low impact, low desync, proper use of both
camCreate and
createVehicle.
So, how does this apply to MCAR and MP?Well, I hope this will help you guys experiment with and use the differences between
camCreate and
createVehicle to your advantage.
Cheers!