OFPEC Forum
Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting Multiplayer => Topic started by: Pravit on 14 Jul 2005, 01:59:18
-
I'm having a problem creating crewed vehicles in MP. In one of my missions, some tanks are created as reinforcements. I create them like this:
(spawntank.sqs)
_spawnpos = _this select 0
_grp = _this select 1
_tank = "T80" createVehicle _spawnpos
"SoldierECrew" createUnit [_spawnpos, _grp]
"SoldierECrew" createUnit [_spawnpos, _grp]
"SoldierECrew" createUnit [_spawnpos, _grp]
_driver = units _grp select 0
_commander = units _grp select 1
_gunner = units _grp select 2
_driver moveindriver _tank
_commander moveincommander _tank
_gunner moveingunner _tank
When I start a multiplayer game and play by myself, it works fine. But when I have someone else playing with me, I get an error about _gunner = units _grp select 2, saying something about a zero divisor. What really confuses me is that I have some other tanks which are also created and crewed in the same manner, and they work fine regardless of if it's only me playing or if there are other players. I have a seperate group for every tank, so select 0, 1, and 2 should always pick the right people. Any help?
I noticed this error happens sometimes even when it doesn't display an error message. I'm guessing the moveindriver etc. commands don't work as I think they do in multiplayer, or I can't select the driver/pilot/whatever with this method?
Also, I create the "groups" by placing a unit in the editor and then writing something like this in the init field:
tankgroup = group this; deletevehicle this
Thanks!
-
I've had problems in the past with trying to spawn units into a group and make them use the 'move' command. The problem turned out to be the code I was putting in their init field:
grpx = group this; deletevehicle this
Turned out the group would be defined on the server, but not on all of the clients (I guess it got deleted before the group was registered on everybody). I fixed it by making a script called "delete.sqs", which looked like this:
~1
deletevehicle _this
Then I'd put this in the unit's init fields:
grpx = group this; this exec "delete.sqs"
Once I did that, my scripts suddenly worked. I'd suggest trying to do the same thing.
-
had the same prtoblem too when referring to groupnames that were initialised in a units init field
I found the best solution was to initialise the group name in the init.sqs, solved lots of problems
eg
tx_mygroup = group W1
where W1 is a unit name
-
Yeah, setting a delay and then deleting them works! Thanks, guys.
Another question: Can I spawn a vehicle with its engines on? It's not so important for a tank or something, but helicopters take quite a while to power up their rotors and if I spawn them in the air, they may crash in the meantime...
-
use the following line after you have placed a crew in the helo
vehiclename flyinheight 70
-
Neat, thanks!
One other quick question - do hints work in MP? I'm aware it needs to be run locally but it doesn't seem to be working. I was testing a mission with a friend who heard "dings" but didn't see any hints. My init.sqs looks like this:
[] exec "objectives.sqs"
and objectives.sqs just looks something like this:
@basedestroyed
hint "Base destroyed!"