Home   Help Search Login Register  

Author Topic: createUnit not working as planned  (Read 522 times)

0 Members and 1 Guest are viewing this topic.

Offline KTottE

  • Former Staff
  • ****
createUnit not working as planned
« on: 24 Jul 2003, 19:43:22 »
Well, I can create units without problem, but the units I create don't respond to any following scripting commands. Something that is sort of a drag when you're trying to create enemy patrols on the fly, no?

Code: [Select]
_grpLeader = "FDF_russianSpetzOfficer" createUnit [_location,GrGrp1,"",0.8,""]

That's what I'm doing from a script. But orders such as:

_grpLeader Move getPos _logic
_grpLeader doMove getPos _logic
_grpLeader doTarget _targetE

etc. don't work at all.
The silly sod just stands there looking stupid. Does anyone have a clue what could be wrong?
"Life is not a journey to the grave with the intention of arriving safely in a pretty and well preserved body, but rather to skid in broadside, thoroughly used up, totally worn out, and loudly proclaiming 'WOW What a Ride!'"

Offline .pablo.

  • Former Staff
  • ****
  • When in doubt, empty the magazine.
Re:createUnit not working as planned
« Reply #1 on: 24 Jul 2003, 20:18:58 »
im having similar problems, i think its because you need to define the person's name in his init (like "sold1 = this").  

the problem im having is that i want to use one createunit line for several guys, but i can't put a local variable in the init string (so i need one createunit for each man)

Offline LCD

  • Former Staff
  • ****
    • Everon Cartel
Re:createUnit not working as planned
« Reply #2 on: 24 Jul 2003, 23:36:19 »
pablo got it right here ;)

creatunit nameing goes like dat

"FDF_russianSpetzOfficer" createUnit [_location,GrGrp1,"grpLeader = this",0.8,""]

cant use no private varies  :-\

LCD OUT
« Last Edit: 24 Jul 2003, 23:37:26 by LCD »
"guess being the community has downsides .." - cheetah
Help Perfecting Da Next Best Thing - O-Team Beta

Unnamed

  • Guest
Re:createUnit not working as planned
« Reply #3 on: 25 Jul 2003, 00:10:37 »
KTottE,

I may have misunderstood what your trying to do. But I have created Units at runtime without any problems. I can send you an example if you want?

The problem lies with defining the group you want a unit to join.

You cant create groups during a game. But you can define them during initialization, then use them as and when you see fit.

Offline KTottE

  • Former Staff
  • ****
Re:createUnit not working as planned
« Reply #4 on: 25 Jul 2003, 00:23:08 »
I've got it sorted now :)
"Life is not a journey to the grave with the intention of arriving safely in a pretty and well preserved body, but rather to skid in broadside, thoroughly used up, totally worn out, and loudly proclaiming 'WOW What a Ride!'"

Unnamed

  • Guest
Re:createUnit not working as planned
« Reply #5 on: 25 Jul 2003, 02:29:04 »
Woohoo :)

I wish mine could be solved as quickly  :'(

Offline toadlife

  • OFPEC Old Skool
  • Former Staff
  • ****
  • Official OFP Editing Center Toad
    • toadlife.net
Re:createUnit not working as planned
« Reply #6 on: 25 Jul 2003, 03:03:52 »
There is a function in the function library that creates a unit and returns the units ID. :) It's called "createunit2"

http://www.ofpec.com/editors/funcref.php?letter=C#CreateUnit2
« Last Edit: 25 Jul 2003, 03:05:03 by toadlife »
"Whenever you want information on the 'net, don't ask a question; just post a wrong answer." -- Cancer Omega.

Unnamed

  • Guest
Re:createUnit not working as planned
« Reply #7 on: 25 Jul 2003, 03:29:03 »
I slapped mine straight into a global array, so I missed the problem:

Code: [Select]
_SquadType createunit [_SquadPos,(GroupList select _GroupCounter),"UnitList set ["+format["%1",MaxUnits]+",this]", 1,_SquadRank];

Offline .pablo.

  • Former Staff
  • ****
  • When in doubt, empty the magazine.
Re:createUnit not working as planned
« Reply #8 on: 25 Jul 2003, 06:11:54 »
why does KTottE get a bunch of responses and my thread gets none...?

i'm still having problems, help me!!! (especially LCD, he seems to know his scripting)

http://www.ofpec.com/yabbse/index.php?board=8;action=display;threadid=11659