Home   Help Search Login Register  

Author Topic: moving troops in preview working. Not in MP  (Read 1263 times)

0 Members and 1 Guest are viewing this topic.

grutt

  • Guest
moving troops in preview working. Not in MP
« 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:

Code: [Select]
_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
« Last Edit: 05 Sep 2004, 22:48:55 by grutt »

Offline Mud_Spike

  • Contributing Member
  • **
Re:moving troops in preview working. Not in MP
« Reply #1 on: 05 Sep 2004, 22:51:51 »
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


grutt

  • Guest
Re:moving troops in preview working. Not in MP
« Reply #2 on: 05 Sep 2004, 22:59:52 »
Oops sorry yea. I've tried that too. didn't help matters. Been tryin to sort this for days :'(

Offline Mud_Spike

  • Contributing Member
  • **
Re:moving troops in preview working. Not in MP
« Reply #3 on: 05 Sep 2004, 23:06:51 »
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. :)

grutt

  • Guest
Re:moving troops in preview working. Not in MP
« Reply #4 on: 05 Sep 2004, 23:09:51 »
Thanks anyway mate. I shall keep working away...

[Edited :) ]

One thing though. Checking that they are considered alive. How would i go about this?
« Last Edit: 05 Sep 2004, 23:11:11 by grutt »

grutt

  • Guest
Re:moving troops in preview working. Not in MP
« Reply #5 on: 06 Sep 2004, 16:23:30 »
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?
« Last Edit: 06 Sep 2004, 16:24:11 by grutt »

Offline Artak

  • The old beanbag shaker
  • Former Staff
  • ****
  • You want to talk about it, yes?
    • OFP Team Finlanders
Re:moving troops in preview working. Not in MP
« Reply #6 on: 06 Sep 2004, 22:00:56 »
Try move, instead of domove
Not all is lost.

grutt

  • Guest
Re:moving troops in preview working. Not in MP
« Reply #7 on: 06 Sep 2004, 22:50:24 »
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:

Code: [Select]
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:

Code: [Select]
?!(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 :)