Advertisement

Author Topic: Random Unit spawntent  (Read 753 times)

0 Members and 1 Guest are viewing this topic.

Offline ual002

  • Members
  • *
Random Unit spawntent
« on: 25 Aug 2010, 04:44:34 »
Ok so ive got a tent with addaction and it points to a script... this is the script....

Code: [Select]
_nearestgrp = [spawntent, allgroups] call CBA_fnc_getNearest



 _sold = random 3
tr0 = "Ins_Soldier_Medic"
tr1 = "Ins_Soldier_1"
tr2 = "Ins_Soldier_2"
tr3 = "Ins_Soldier_AT"


_unit =  _nearestgrp createUnit ["tr_sold", getPos spawntent, [], 0, "none"];

removeallweapons _unit; _unit addweapon "ACE_M16A4_Iron";

addswitchableunit _unit;

Tried to use the random command and assign variables to the numbers and im getting no results.  Anybody see what im doing wrong?

Offline DrStrangelove

  • Members
  • *
  • Mr.Creative
Re: Random Unit spawntent
« Reply #1 on: 02 Sep 2010, 13:38:39 »
Right out of my head:

I'd replace

Code: [Select]
_sold = random 3
tr0 = "Ins_Soldier_Medic"
tr1 = "Ins_Soldier_1"
tr2 = "Ins_Soldier_2"
tr3 = "Ins_Soldier_AT"

_unit =  _nearestgrp createUnit ["tr_sold", getPos spawntent, [], 0, "none"];


with:

Code: [Select]
all_tr = ["Ins_Soldier_Medic","Ins_Soldier_1","Ins_Soldier_2","Ins_Soldier_AT"];
_sold = all_tr select (random floor (count all_tr));
_unit = _nearestgrp createUnit [_sold, getPos spawntent, [], 0, "none"];

(not sure about random floor <number>, i think it worked that way if i remember correctly)

Offline zonker3210

  • Members
  • *
Re: Random Unit spawntent
« Reply #2 on: 03 Sep 2010, 04:21:13 »
Another thing...based on your code sample, it looks like you're switching back and forth between SQS and SQF syntax (i.e., semicolons at the end of statements, etc.)

Offline ual002

  • Members
  • *
Re: Random Unit spawntent
« Reply #3 on: 05 Sep 2010, 17:43:37 »
Great thanks, this worked.  I love the OFP/ARMA community!!

Quote
all_tr = ["Ins_Soldier_Medic","Ins_Soldier_1","Ins_Soldier_2","Ins_Soldier_AT"];
_sold = all_tr select (random floor (count all_tr));
_unit = _nearestgrp createUnit [_sold, getPos spawntent, [], 0, "none"];


sqs semicolon, sqf no semicolon?
« Last Edit: 05 Sep 2010, 17:47:27 by ual002 »

Offline zonker3210

  • Members
  • *
Re: Random Unit spawntent
« Reply #4 on: 06 Sep 2010, 06:20:38 »
SQF scripts use semicolons at the end of statements and code blocks.

http://community.bistudio.com/wiki/SQF_syntax


Offline ual002

  • Members
  • *
Re: Random Unit spawntent
« Reply #5 on: 08 Sep 2010, 15:45:45 »
why have i never run into that.