OFPEC Forum
Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting Multiplayer => Topic started by: grutt on 05 Sep 2004, 22:47:58
-
This has got me stumped... i'm trying to create a mission and i've so many problems with the scripting i've tried created just simple test mission to try and solve the problems. Ok, here it is:
I create a unit and give it a group name. Then i delete the unit. This is so i can dynamically create some units later on.
Then i dynamically create two snipers using createUnit at a game logic position. And use the domove command to move one of them to another game logic position. OK, now this all seems easy enough, and should work surely?
I preview the mission with the player standing at the top of a hill with a pair of binoculars looking down at the snipers... And hoorah they move to the second position.
If however, i play this mission with a friend online, either of us hosting, the snipers don't move.
The player init's the script which is given below:
_way1 = _this select 0
_group = _this select 1
_skill = _this select 2
_way2 = _this select 3
~0.5
"SoldierESniper" CreateUnit [getpos _way1,_group,"s_1=this",_skill,"CAPTAIN"]
~0.1
"SoldierESniper" CreateUnit [getpos _way2,_group,"s_2=this",_skill,"PRIVATE"]
~0.1
s_1 domove (getpos _way2)
exit
-
Try having the script only executed on the server.
Add a gamelogic, name it 'server', then the first thing you do in your script is:
? !(local server): exit
-
Oops sorry yea. I've tried that too. didn't help matters. Been tryin to sort this for days :'(
-
Ah, then I dont know.
Debug to make sure that s_1 is really that unit, that it is considered alive, and that the doMove position is valid. Also try increasing the delay between the create and the doMove.
But I guess you've been thru all this already.
Good luck to you anyway. :)
-
Thanks anyway mate. I shall keep working away...
[Edited :) ]
One thing though. Checking that they are considered alive. How would i go about this?
-
A little more experimenting, and it seems that if i just create two snipers out of sight and setpos for them at them to the first game logic, and then move them to were i want them, then that works in MP. However that kinda defeats the point of it me wanting to spawn and move them... Am i missing something with the createUnit command?
-
Try move, instead of domove
-
I got it working finally. 8)
For those that are interested and want to avoid the same issue, my problem was that i was putting the following into the init field of the units i was using to predefine some group names:
group_1=group(this); deleteVehicle this
Now i don't know but it seems that the problem was caused because this wasn't running server only. So what i did was remove the init lines and give the units a name, say g1, g2 etc. Then i could create a script that i ran at the very start of the mission that would run server only and replace what was in the init field for each unit. Something like this:
?!(local server):exit
group_1=group(g1)
deleteVehicle g1
after a little delay to allow the above to happen. New units could then be spawned into the groups defined, and the move or domove commands worked a charm. Thanx all for the help everyone. Much appreciated :)