Home   Help Search Login Register  

Author Topic: createunit help  (Read 1486 times)

0 Members and 1 Guest are viewing this topic.

garret64

  • Guest
createunit help
« on: 30 Apr 2004, 05:34:21 »
I want a trigger that wehn activated will run a script that will create a coba (with crew, and in flight preferably) and then have it move to a waypoint.  I have searched through the forums, and ed depot, and have downloaded a few different missions and tuts, but i just cant get it working.

Here is my setup:

i have a 'dummy' guy named cob1 with :   cobraz = group(this); deleteVehicle this    in his init field, and a move waypoint for him.

I also have this script (which i modified from one i found):
#start

#create

cobra1 = cobra createvehicle getpos cob1
~1
"SoldierWPilot" createunit [getpos cob1, cobra1, "p1 = this", 1, "CAPTAIN"]
"SoldierWPilot" createunit [getpos cob1, cobra1, "p2 = this", 1, "LIEUTENANT"]
~1
p1 moveindriver cobra1
p2 moveingunner cobra1

exit

and a trigger that execs the script, but when i go to the trigger nothing happens, i have an activation for it, and i know the trigger is working because i put a text effect in it, and the text comes on screen.

any help would be greatly appreciated.

Isaioux2x

  • Guest
Re:createunit help
« Reply #1 on: 30 Apr 2004, 06:24:45 »
I want a trigger that wehn activated will run a script that will create a coba (with crew, and in flight preferably) and then have it move to a waypoint.  I have searched through the forums, and ed depot, and have downloaded a few different missions and tuts, but i just cant get it working.

Here is my setup:

i have a 'dummy' guy named cob1 with :   cobraz = group(this); deleteVehicle this    in his init field, and a move waypoint for him.

I also have this script (which i modified from one i found):
#start

#create

cobra1 = cobra createvehicle getpos cob1
~1
"SoldierWPilot" createunit [getpos cob1, cobra1, "p1 = this", 1, "CAPTAIN"]
"SoldierWPilot" createunit [getpos cob1, cobra1, "p2 = this", 1, "LIEUTENANT"]
~1
p1 moveindriver cobra1
p2 moveingunner cobra1

exit

and a trigger that execs the script, but when i go to the trigger nothing happens, i have an activation for it, and i know the trigger is working because i put a text effect in it, and the text comes on screen.

any help would be greatly appreciated.

Naming the group cobraz is useless unless you call it in the script. As far as I know, there has to be a group for the created units to goto ;)


So something like

"SoldierWPilot" createunit [getpos cob1, cobraz, "p1 = this", 1, "CAPTAIN"]
p1 moveindriver cobra1
p2 moveingunner cobra1
exit

You get the idea

Edit: If this is all there is to the script. Ditch the labels.
and: cobraz = group this
« Last Edit: 30 Apr 2004, 06:26:51 by Isaioux2x »

garret64

  • Guest
Re:createunit help
« Reply #2 on: 30 Apr 2004, 06:44:07 »
thanks for the feedback, but i just cant get it to work.  I dont know if im missing something, or if something is tyoed incorrectly, this is my first time trying to do this, and im trying to base it off of respawning scripts ive seen.

Any one else have any ideas?
« Last Edit: 30 Apr 2004, 06:44:55 by SFS84 »

Offline Artak

  • The old beanbag shaker
  • Former Staff
  • ****
  • You want to talk about it, yes?
    • OFP Team Finlanders
Re:createunit help
« Reply #3 on: 30 Apr 2004, 07:00:53 »
The only error is that you have is what Isaioux2x says above.
Change
"cobraz = group(this)"
to
"cobraz = group this"
just to make sure and in the script the create lines from
""SoldierWPilot" createunit [getpos cob1, cobra1, "p1 = this", 1, "CAPTAIN"]"
to
""SoldierWPilot" createunit [getpos cob1, cobraz, "p1 = this", 1, "CAPTAIN"]"
« Last Edit: 30 Apr 2004, 07:01:53 by Artak »
Not all is lost.

garret64

  • Guest
Re:createunit help
« Reply #4 on: 30 Apr 2004, 07:07:13 »
ah ha, well i hope it works....

cover me, im going in...

garret64

  • Guest
Re:createunit help
« Reply #5 on: 30 Apr 2004, 07:16:44 »
ok, i changed the 'cobraz = group(this), i didnt catch that from Isaioux2x, i thought he meant to ditch it too.  and ive read through both your posts a few times, and have made every change you suggest
 
and now.....

it still dont work.

Is cobra the right name to use to create a cobra?  from what i know thats the only other thinkg i know of that could be causing it to not worky.

Isaioux2x

  • Guest
Re:createunit help
« Reply #6 on: 30 Apr 2004, 07:26:43 »
ok, i changed the 'cobraz = group(this), i didnt catch that from Isaioux2x, i thought he meant to ditch it too.  and ive read through both your posts a few times, and have made every change you suggest
 
and now.....

it still dont work.

Is cobra the right name to use to create a cobra?  from what i know thats the only other thinkg i know of that could be causing it to not worky.

Yes, I honestly don't see why this isn't working.

I think the problem lays within your trigger. Because it doesn't seem to be erroring out. And if it couldn't find the script it would've displayed a message telling you so. The script looks sound.

If you're 100% the scipt is executing then it's a problem in the init field
« Last Edit: 30 Apr 2004, 07:28:38 by Isaioux2x »

Offline Artak

  • The old beanbag shaker
  • Former Staff
  • ****
  • You want to talk about it, yes?
    • OFP Team Finlanders
Re:createunit help
« Reply #7 on: 30 Apr 2004, 07:41:12 »
Quote
Is cobra the right name to use to create a cobra?
Ah indeed it is. How did I miss that?  ;D


Code: [Select]
cobra1 = cobra createvehicle getpos cob1should be
Code: [Select]
cobra1 = "cobra" createvehicle getpos cob1
Not all is lost.

Isaioux2x

  • Guest
Re:createunit help
« Reply #8 on: 30 Apr 2004, 07:44:19 »
Don't I look like a fool? :)

You have to love it when you're sitting for hours to figure out why something isn't working and then you find out it was just something small. Scripting/Programming in general.

garret64

  • Guest
Re:createunit help
« Reply #9 on: 30 Apr 2004, 07:54:55 »
uh hu, well ill give it a try and if it doesnt work (knock on wood) im giving up for the night.

garret64

  • Guest
Re:createunit help
« Reply #10 on: 30 Apr 2004, 08:06:05 »
so i guess im giving up for the night...

if someone could write/post a working script for this that i can compare with my own, that would help.

mabey tomarrow ill re-write the script and trigger from scratch, who knows mabey it will work then

and thanks for the help given so far, it has been helpfull, even though it isnt working yet, ive still learned a few things, so thanks alot.

Kammak

  • Guest
Re:createunit help
« Reply #11 on: 30 Apr 2004, 10:04:43 »
SFS84, I got your script working with two changes.  I verified both changes are necessary to get it working.

First, the line

cobra1="cobra" createvehicle getpos cob1

has two problems.  "cobra" must be "Cobra", as the name is case-sensitive.  Second, once you delete cob1, getpos cob1 is invalid.  So you must either supply coords for createvehicle (and createunit) or place a gamelogic/other object near where cob1 is, and use that.  So here is the working script:

Code: [Select]
cobra1="Cobra" createvehicle getpos glCob
~1
"SoldierWPilot" createunit [getpos glCob,cobraz,"p1=this",1,"CAPTAIN"]
"SoldierWPilot" createunit [getpos glCob,cobraz,"p2=this",1,"LIEUTENANT"]
~1
p1 moveindriver cobra1
p2 moveingunner cobra1

exit

glCob is a game logic I placed in the editor next to the unit named Cob1.  Cob1's init looks like this:

Code: [Select]
cobraz=group this;deletevehicle this

and I gave him three waypoints, which the helo followed after taking off.  To test this, I used a radio trigger (Alpha), but I assume you have no trouble with the trigger or calling the script on activation, right?

Hope that helps!  :)




garret64

  • Guest
Re:createunit help
« Reply #12 on: 30 Apr 2004, 17:46:07 »
Ok, i made those changes and it worked.  The cobra even got shot down by some shilkas.   :P

Thanks Kammak,  I never even thought about either of those two things, although i knew that names were case sensitive, it just escaped me.

thanks for all the help i got, now that its working im just so happy ;D

thanks again guys