Jump to content
Sign in to follow this  
the unknown

AI creator script

Recommended Posts

I have been working on a AI creator script for my clans training map. So far I have managed to get all the error messages that show up in game out of the script except for this last one,

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">Error in expression <g">

Error position: <">

Error Missing;

Now I tink the error is some where in the creatunit area cause it happens multiple times.

This is the script,

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">//REGION RUNCODE

////////////////////////////////////////////////////////

//Runcode: var = [Groupleader,Amountofinfantry,Amountofvehicles,Amountofarmour,AmountofAirunits,Geartype,

Unitside] execVM "AIcreator.sqf"

//Geartypes: 1=West, 2=East

//Sides: 1=West, 2=East, 3=Guerilla, 4=Civilian

////////////////////////////////////////////////////////

//ENDREGION

//REGION Data gathering

_Unit = _this select 0;

_InfS = _this select 1;

_VecS = _this select 2;

_ArmS = _this select 3;

_AirS = _this select 4;

_Geartype = _this select 5;

_Unittype = _this select 6;

_Group = group _Unit;

//ENDREGION

//REGION Unit lists

_InfW = ["SoldierWSaboteurPipe2","SoldierWAA","SoldierWAT","SoldierWAR","SoldierWCrew","SoldierWMiner","SoldierWG","SoldierWMG","SoldierWB","SoldierWPilot","OfficerW","SoldierWMedic","SoldierWSaboteurAssault","SoldierWSaboteurMarksman","","SoldierWSaboteurRecon","SoldierWSaboteurPipe","TeamLeaderW","SquadLeaderW","SoldierWSniper"];

_VecW = ["Truck5tOpen","Truck5tMG","HMMWV","HMMWV50","HMMWVMK","Truck5t","HMMWVTOW","M1030","m113ambul","Truck5tRepair","Truck5tRefuel","Truck5tReammo"];

_ArmW = ["M113","Vulcan","M1Abrams","Stryker_TOW","Stryker_ICV_M2","Stryker_ICV_MK19"];

_AirW = ["UH60","Camel","MH6","UH60MG","AV8B","AV8B2","AH6","AH1W","A10"];

_InfE = ["SoldierEAA","SoldierEAT","SoldierECrew","SoldierEMiner","SoldierEMG","SoldierEG","SoldierESniper","SoldierEB","SoldierEPilot","SoldierESaboteurMarksman","OfficerE","SoldierESaboteurBizon","SoldierESaboteurPipe","SoldierEMedic","SquadLeaderE","TeamLeaderE"];

_VecE = ["UAZ","UralReammo","UralRefuel","Ural","UAZMG","UralOpen","UAZ_AGS30","UralRepair","TT650G","bmp2ambul"];

_ArmE = ["T72","BMP2","BRDM2","BRDM2_ATGM","ZSU"];

_AirE = ["KA50","Mi17_MG","Mi17","Su34B","Su34","Camel2"];

_InfG = ["SoldierGAA","SoldierGAT","SoldierGCrew","SoldierGMiner","SoldierGGuard","SoldierGCommando","SquadLeaderG","TeamLeaderG","SoldierGB","SoldierGMG","SoldierGMedic","OfficerG","SoldierGSniper","SoldierGPilot","SoldierGG","SoldierGMarksman"];

_VecG = ["Landrover_Closed","LandroverMG","Landrover"];

_ArmG = ["Vulcan_RACS","M113_RACS","T72_RACS"];

_AirG = ["AH6_RACS","MH6_RACS"];

_InfC = ["Civilian","Civilian10","Civilian11","Civilian12","Civilian20","Civilian14","Civilian15","Civilian19","Civilian2","Civilian13","Civilian21","Civilian9","Civilian8","Civilian7","Civilian6","Civilian5","Civilian18","Civilian17","Civilian16","Civilian3","Civilian4"];

_VecC = ["SkodaGreen","Skoda","UralCivil","Bus_city","SkodaBlue","SkodaRed","datsun1_civil_1_open","hilux1_civil_3_open","hilux1_civil_2_covered","hilux1_civil_1_open","car_hatchback","UralCivil2","TT650C","datsun1_civil_3_open","datsun1_civil_2_covered","car_sedan","tractor"];

_ArmC = [];

_AirC = [];

//ENDREGION

//REGION Unit creation

switch (_Unittype) do {

//REGION West

case 1:

{

while {_I < _InfS} do

{

_I=_I+1;

_IA = count _InfW;

_IN = random _IA;

_IN = round _IN;

_IUnit = _InfW select _IN;

("_IUnit" createUnit [position _Unit, _Group]);

};

while {_V < _VecS} do

{

_V=_V+1;

_VA = count _VecW;

_VN = random _VA;

_VN = round _VN;

_VUnit = _VecW select _VN;

("_VUnit" createUnit [position _Unit, _Group]);

};

while {_R < _ArmS} do

{

_R=_R+1;

_RA = count _ArmW;

_RN = random _RA;

_RN = round _RN;

_RUnit = _ArmW select _RN;

("_RUnit" createUnit [position _Unit, _Group]);

};

while {_A < _AirS} do

{

_A=_A+1;

_AA = count _AirW;

_AN = random _AA;

_AN = round _AN;

_AUnit = _AirW select _AN;

("_AUnit" createUnit [position _Unit, _Group]);

};

};

//ENDREGION

//REGION East

case 2:

{

while {_I < _InfS} do

{

_I=_I+1;

_IA = count _InfE;

_IN = random _IA;

_IN = round _IN;

_IUnit = _InfE select _IN;

("_IUnit" createUnit [position _Unit, _Group]);

};

while {_V < _VecS} do

{

_V=_V+1;

_VA = count _VecE;

_VN = random _VA;

_VN = round _VN;

_VUnit = _VecE select _VN;

("_VUnit" createUnit [position _Unit, _Group]);

};

while {_R < _ArmS} do

{

_R=_R+1;

_RA = count _ArmE;

_RN = random _RA;

_RN = round _RN;

_RUnit = _ArmE select _RN;

("_RUnit" createUnit [position _Unit, _Group]);

};

while {_A < _AirS} do

{

_A=_A+1;

_AA = count _AirE;

_AN = random _AA;

_AN = round _AN;

_AUnit = _AirE select _AN;

("_AUnit" createUnit [position _Unit, _Group]);

};

};

//ENDREGION

//REGION Guerilla

case 3:

{

while {_I < _InfS} do

{

_I=_I+1;

_IA = count _InfG;

_IN = random _IA;

_IN = round _IN;

_IUnit = _InfG select _IN;

("_IUnit" createUnit [position _Unit, _Group]);

};

while {_V < _VecS} do

{

_V=_V+1;

_VA = count _VecG;

_VN = random _VA;

_VN = round _VN;

_VUnit = _VecG select _VN;

("_VUnit" createUnit [position _Unit, _Group]);

};

while {_R < _ArmS} do

{

_R=_R+1;

_RA = count _ArmG;

_RN = random _RA;

_RN = round _RN;

_RUnit = _ArmG select _RN;

("_RUnit" createUnit [position _Unit, _Group]);

};

while {_A < _AirS} do

{

_A=_A+1;

_AA = count _AirG;

_AN = random _AA;

_AN = round _AN;

_AUnit = _AirG select _AN;

("_AUnit" createUnit [position _Unit, _Group]);

};

};

//ENDREGION

//REGION Civilian

case 4:

{

while {_I < _InfS} do

{

_I=_I+1;

_IA = count _InfC;

_IN = random _IA;

_IN = round _IN;

_IUnit = _InfC select _IN;

("_IUnit" createUnit [position _Unit, _Group]);

};

while {_V < _VecS} do

{

_V=_V+1;

_VA = count _VecC;

_VN = random _VA;

_VN = round _VN;

_VUnit = _VecC select _VN;

("_VUnit" createUnit [position _Unit, _Group]);

};

while {_R < _ArmS} do

{

_R=_R+1;

_RA = count _ArmC;

_RN = random _RA;

_RN = round _RN;

_RUnit = _ArmC select _RN;

("_RUnit" createUnit [position _Unit, _Group]);

};

while {_A < _AirS} do

{

_A=_A+1;

_AA = count _AirC;

_AN = random _AA;

_AN = round _AN;

_AUnit = _AirC select _AN;

("_AUnit" createUnit [position _Unit, _Group]);

};

};

//ENDREGION

};

//ENDREGION

//REGION GEAR

switch (_Geartype) do{

case 1:

{

[_Unit,1,10] execVM "gear\Gearsquad.sqf";

};

case 2:

{

[_Unit,2,10] execVM "gear\Gearsquad.sqf";

};

};

//ENDREGION

//REGION Exit

exitWith;

//ENDREGION

Does anyone have a clue what is wrong with this script?

The Unknown

Share this post


Link to post
Share on other sites

god damn,..

i wish this code box function included tabs..

it makes long code hard to read.

does it tell you what line the errors ocures on?

i think this is one problem. all of the,,

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

_IUnit = _InfW select _IN;

("_IUnit" createUnit [position _Unit, _Group]);

try make them something like

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

_IUnit = format["%1",_InfW select _IN];

_IUnit createUnit [position _Unit, _Group];

Share this post


Link to post
Share on other sites
Quote[/b] ]does it tell you what line the errors ocures on?

Nop thats the whole problem I am haveing it doesnt tell me where the problem is.

Ill give your code a try and see if its that.

Edit: didnt do the trick error is still there and it created even more error's someting about a missing } tryed a couple of placements but I couldnt find it, sometimes I start to tink this sqf ting is designed to make us all go mental.

Share this post


Link to post
Share on other sites

Im not sure about this.. but dont you have to define _I,_V,_R,_A before you use them ?

aslo i see exitwith  with no ";"

exitWith {hint "bleh" ;};

i aslo think this is wrong. i havent tested it though,,

but in my eyes it seams like you try to create the unit _IUnit

littarly.. sine you use " " it is seen as a string..

_IUnit = _InfW select _IN;

thats why i wanted you to test with

_IUnit = format["%1",_InfW select _IN];

_IUnit createUnit [position _Unit, _Group];

now _IUnit is a sting with the name "ex" SoliderW

Share this post


Link to post
Share on other sites

nuxil's reply was the solution: you've got syntax errors with redundant quotes on lines: 139, 148, 157

Share this post


Link to post
Share on other sites

Well I got some good news and some bad news, the good news is it creats the units, the bad news is the error is still there.

Here is a new link with the script so far,

http://pastebin.com/d29605fd3

I already tested if it was the gear script by commenting the lines out and that didnt fix it so its defitnally in this script.

Share this post


Link to post
Share on other sites

dosent exitwith need to exit with a code ?

exitwith {};

but i think you can remove exitwith in your script

Share this post


Link to post
Share on other sites

But how do you stop the script then, I am moveing from sqs to sqf resently so I dont know half these tings.

Share this post


Link to post
Share on other sites

im a bit rusty on this,, but AFIK.. then script exit by itself after it has been run,,

exitwith is used with examle

_x=1

while something.. do

{ bla bla bla

if (_x > 1) exithwith { hint "hey.. i can not continue since X was to big";};

Share this post


Link to post
Share on other sites

Halfway along the _InfW line (the first array) there is  ,"",

It's just a blank element...dunno if this is causing any probs. In theory it shouldn't do....but sqf and sqs dont use normal theory...although it could be trying to create an empty unit.

Share this post


Link to post
Share on other sites

Nope not it, I also tryed it with only 1 entry in every array and it still had it.

Share this post


Link to post
Share on other sites

In the down time I managed to find out what caused the error I probally screwed someting up in the mission.sqm.

Everyting seems to be working now.

Thanks to everybody that helped.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×