Home   Help Search Login Register  

Author Topic: CreateUnit Probs  (Read 1649 times)

0 Members and 2 Guests are viewing this topic.

Offline Mad Pup

  • One Who Asks A Lot.
  • Members
  • *
  • OFPEC Is Awesome
CreateUnit Probs
« on: 24 Feb 2010, 22:02:55 »
Hello All..... Mad Pup here.... I have a question about the createUnit command. I am using a unit that comes from an addon called MiG Animals... The unit is called "Cow" (In the mission editor anyhow). What would I put in the script for createUnit?

THANKS
~ Mad Pup
"The object of war is not to die for your country, but to make the other poor bastard die for his" - General Patton
[SH]MadPup
[SH]Squad

Offline RKurtzDmitriyev

  • Former Staff
  • ****
Re: CreateUnit Probs
« Reply #1 on: 25 Feb 2010, 00:07:29 »
What part about createunit are you stuck on? Have you succeeded in creating any units? If not, try putting a game logic called someplace, a unit with initialization "alpha = group this", and execute

Code: [Select]
"SoldierEB" createunit [getpos someplace, alpha]
in a script somewhere.

If you need the name of the cow vehicle type, consult the documentation for MiG Animals. Or, place a cow unit, save mission, and look at mission.sqm to see what was placed. The relevant entry should look like this:

Code: [Select]
class Item3
{
position[]={5152.100586,16.334999,3999.496094};
azimut=270.000000;
special="NONE";
id=9;
side="WEST";
vehicle="SoldierWB";
rank="CORPORAL";
skill=1.000000;
};

Except that vehicle="SoldierWB" will say something else.
The OFP Editing Center wishes to remind you that the faithful COMREF will never threaten to stab you and, in fact, cannot speak.
However, in the event that it does speak, you are encouraged to heed its advice. ;)

Offline savedbygrace

  • Intel Depot
  • Administrator
  • *****
  • Be swift to hear...slow to speak...slow to wrath.
Re: CreateUnit Probs
« Reply #2 on: 25 Feb 2010, 03:57:52 »
A fairly quick way of discovering the class name for an object is to insert the below code into it's init field and preview the mission. It will display the classname in the form of a hint.

Code: [Select]
Hint format ["%1", typeof this]

Offline Mad Pup

  • One Who Asks A Lot.
  • Members
  • *
  • OFPEC Is Awesome
Re: CreateUnit Probs
« Reply #3 on: 26 Feb 2010, 23:38:09 »
Okay, I Tried This..
Code: [Select]
"MiG_Cow" createVehicle [getpos HERE, alpha]
and it said "Error Type Array, expected Number

... This means??


~ Mad Pup
"The object of war is not to die for your country, but to make the other poor bastard die for his" - General Patton
[SH]MadPup
[SH]Squad

Offline RKurtzDmitriyev

  • Former Staff
  • ****
Re: CreateUnit Probs
« Reply #4 on: 27 Feb 2010, 00:22:53 »
You've got createvehicle confused with createunit. ;)

FYI, that error message means that there's an array where there's supposed to be a number. The command is trying to operate on something that it wasn't designed to work with. This can happen because you're using the wrong command, inserting the wrong values, mistyped a command, mistyped a value, misplaced parentheses, etc.
« Last Edit: 27 Feb 2010, 00:26:36 by RKurtzDmitriyev »
The OFP Editing Center wishes to remind you that the faithful COMREF will never threaten to stab you and, in fact, cannot speak.
However, in the event that it does speak, you are encouraged to heed its advice. ;)

Offline Mad Pup

  • One Who Asks A Lot.
  • Members
  • *
  • OFPEC Is Awesome
Re: CreateUnit Probs
« Reply #5 on: 27 Feb 2010, 00:41:01 »
Okay..... I tried
Code: [Select]
"MiG_Cow" createUnit [getpos HERE, alpha]and now it doesn't do anything... no errors, and no cow...... (sorry, I'm not that good with Mission Editing lol)
so what code would you use?

~Mad Pup
"The object of war is not to die for your country, but to make the other poor bastard die for his" - General Patton
[SH]MadPup
[SH]Squad

Offline RKurtzDmitriyev

  • Former Staff
  • ****
Re: CreateUnit Probs
« Reply #6 on: 27 Feb 2010, 02:42:22 »
so what code would you use?

First I would replace "MiG_Cow" with "SoldierWB" to test to see if the position and group are valid. If they are it should create a basic West soldier, group alpha, wherever HERE is.

Code: [Select]
"SoldierWB" createUnit [getpos HERE, alpha]
If that works, then "MiG_Cow" does not refer to an existing class name. If the code above doesn't work, then either the position is not valid or the group is not valid. Check to make sure that HERE is the name of a unit or gamelogic, and alpha refers to a real group.

Here, compare whatever you're doing with the mission attached below. Unzip, place folder in user missions, load in mission editor, hit preview, and hit Radio Alpha to spawn a soldier in the group of the man in front of you.

EDIT: Hey Mad Pup, I just realized that there's a good chance that MiG_Cow is considered a vehicle rather than a unit. In that case, you will in fact need createvehicle rather than createunit. But createvehicle has a different syntax than createunit. Try this code:

Code: [Select]
cow1 = "MiG_Cow" createvehicle getpos HERE
« Last Edit: 27 Feb 2010, 21:27:50 by RKurtzDmitriyev »
The OFP Editing Center wishes to remind you that the faithful COMREF will never threaten to stab you and, in fact, cannot speak.
However, in the event that it does speak, you are encouraged to heed its advice. ;)