=Odin= 0 Posted December 21, 2007 G'day, for over a week now I have been trying to make a script so I can recruit AI from a flag pole, depending on player score. I can recruit hundreds of em with this script; init; Quote[/b] ]hiresoldier = Pole addaction ["Hire Soldiers", "hire3.sqs"]; .sqs; Quote[/b] ]#start"SoldierGB" createUnit [getmarkerpos "hire", group player] "SoldierGMG" createUnit [getmarkerpos "hire", group player] exit 'Works great' But I want to limit the squad size to six and only be able to get certain troops depending on your MPscore ( a bit like Evo) yes I have searched the forum, cpbo'ed evo, downloaded ICE Project from Dr eyeball (great stuff Doc btw ) and tried to figure it out. But realized I am crap at translating sqf/sqs. anyways had a go at it, and came up with this which don’t work at all apart from the dudes appearing example; Quote[/b] ]#start_group = player; _groupCount = count units _group; ;get score #rank _rank = score player; ;Count AI players in group _AICount = 0; ;limit group size _AICount = _AICount + 1, count units _group, goto (_groupCount >= 6, exitWith { hint "You are already at your ideal squad size." }); ;?!(isPlayer _x) goto (_AICount = _AICount + 1, count units _group); ;?(_groupCount >= 6) exitWith { hint "You are already at your ideal squad size." }; ;?(_AICount >= 3) exitWith { hint "You have reached your group''s AI limit." }; ;recruit ;_AICount = _AICount + 1, count units _group ; ;_groupCount = 6, exitWith [ hint "You are already at your ideal squad size." ]; ;_AICount = 3, exitWith [ hint "You have reached your group''s AI limit." ]; rank1 = _rank, "1"; count units _group, "SoldierGB" createUnit [getmarkerpos "hire", group player]; rank2 = _rank, "2"; "SoldierGMG" createUnit [getmarkerpos "hire", group player]; I also tried something like this that I found from the Variables section on the wiki; Quote[/b] ]_rank = score player;if (_rank < 1) then {goto "Private"} if (_rank < 2) then {goto "Corporal"} ... some other statements #Private  exec "hire2.sqs"  hint "Private!"  echo "There is snow!"  variable = text "Recruit Rifleman." #Corporal  hint "Corporal!"  echo "There is no snow!"  variable = text "Recruit Rifleman and Machine Gunner." Think I may be entering Dialog territory here to get this to work, can any one please steer me the right way? Help! Cheers, Odin. Share this post Link to post Share on other sites
jezpops 0 Posted December 22, 2007 Goto what? You need a condition loop instead of this: goto (_groupCount >= 6, exitWith { hint "You are already at your ideal squad size." }); something like this: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">if(_groupCount >=6) exitWith {hint "You are already at your ideal squad size." }; or (if you really want to use goto and need to use the limit function a few times) : <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">goto "limit" then <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">#limit if(_groupCount >=6) exitWith {hint "You are already at your ideal squad size." }; and the rest is commented out. You should use sqf format for your scripts instead of sqs, its the 'in' thing you know  Share this post Link to post Share on other sites
=Odin= 0 Posted December 22, 2007 Thanxs JP, It sorta works but keeps recruiting after it shows me the Message, aswell as an error that says Quote[/b] ]'if)_AICount > = 3|#|,) exitwith {hint "You have reached your ....'Error Missing ) Anyway I will try and rewrite it all in sqf as you suggested, bout time I dragged myself out of the 90's Cheers Share this post Link to post Share on other sites
jezpops 0 Posted December 23, 2007 'if)_AICount > = 3|#|,) exitwith {hint "You have reached your ....' Error Missing ) You have the first bracket the wrong way round : <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">'if)_AICount.. should be : <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">'if(_AICount... You could try putting the spawning unit inside the loop : <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">#limit if(_groupCount  ! >= 6) then { _s1= "SoldierGB" createUnit [getmarkerpos "hire", group player]; } else{ exitWith {hint "You are already at your ideal squad size." }; }; Share this post Link to post Share on other sites
=Odin= 0 Posted December 26, 2007 Thx again JP tried that it works but I still get an error about expected bool any way I found one that works the way I want only bad thing is I cant figure uot to add multiple Dialoge Guess I will start a new thread for that one but here it is Quote[/b] ]Basic Dialogue example Create a trigger Add the following code to description.ext Most of this you don't have to worry about - the section you are interested in is the RecruitAT class definition. Within it are 3 controls - MyHelloText is not used but MyActiveText and MyActiveText2 are. you can change basic settings in the control by altering variables. eg. x,y,h,and w - these control the positioning of the dialog and its dimensions. The action variable is the important one however as it determines what happens when you click the buttion. In MyActiveText it points to recruit.sqf and takes soldierWAT as an arguement. In MyActiveText2 it closes the dialog Code: // Control types #define CT_STATIC 0 #define CT_BUTTON 1 #define CT_EDIT 2 #define CT_SLIDER 3 #define CT_COMBO 4 #define CT_LISTBOX 5 #define CT_TOOLBOX 6 #define CT_CHECKBOXES 7 #define CT_PROGRESS 8 #define CT_HTML 9 #define CT_STATIC_SKEW 10 #define CT_ACTIVETEXT 11 #define CT_TREE 12 #define CT_STRUCTURED_TEXT 13 #define CT_CONTEXT_MENU 14 #define CT_CONTROLS_GROUP 15 #define CT_XKEYDESC 40 #define CT_XBUTTON 41 #define CT_XLISTBOX 42 #define CT_XSLIDER 43 #define CT_XCOMBO 44 #define CT_ANIMATED_TEXTURE 45 #define CT_OBJECT 80 #define CT_OBJECT_ZOOM 81 #define CT_OBJECT_CONTAINER 82 #define CT_OBJECT_CONT_ANIM 83 #define CT_LINEBREAK 98 #define CT_USER 99 #define CT_MAP 100 #define CT_MAP_MAIN 101 // Static styles #define ST_POS 0x0F #define ST_HPOS 0x03 #define ST_VPOS 0x0C #define ST_LEFT 0x00 #define ST_RIGHT 0x01 #define ST_CENTER 0x02 #define ST_DOWN 0x04 #define ST_UP 0x08 #define ST_VCENTER 0x0c #define ST_TYPE 0xF0 #define ST_SINGLE 0 #define ST_MULTI 16 #define ST_TITLE_BAR 32 #define ST_PICTURE 48 #define ST_FRAME 64 #define ST_BACKGROUND 80 #define ST_GROUP_BOX 96 #define ST_GROUP_BOX2 112 #define ST_HUD_BACKGROUND 128 #define ST_TILE_PICTURE 144 #define ST_WITH_RECT 160 #define ST_LINE 176 #define FontM "Zeppelin32" class RecruitAT { idd = -1; // set to -1, because we don't require a unique ID movingEnable = true; // no movement while the dialog is shown controlsBackground[] = { }; // no background controls needed objects[] = { }; // no objects needed controls[] = { MyActiveText,MyActiveText2 }; // our Hello World text as seen below: class MyHelloText { idc = -1; // set to -1, unneeded type = CT_STATIC; // constant style = ST_LEFT; // constant text = "Hello world"; font = FontM; sizeEx = 0.023; colorBackground[] = { 1, 1, 1, 0.3 }; colorText[] = { 0, 0, 0, 1 }; x = 0.8; y = 0.1; w = 0.2; h = 0.05; }; class MyActiveText { idc = -1; type = CT_ACTIVETEXT; style = ST_LEFT; x = 0.75; y = 0.5; w = 0.2; h = 0.035; font = FontM; sizeEx = 0.024; color[] = { 1, 1, 1, 1 }; colorActive[] = { 1, 0.2, 0.2, 1 }; soundEnter[] = { "", 0, 1 }; // no sound soundPush[] = { "", 0, 1 }; soundClick[] = { "", 0, 1 }; soundEscape[] = { "", 0, 1 }; action = "nul = [""SoldierWAT""] execVM ""recruit.sqf"""; text = "Recruit Soldier"; default = true; }; class MyActiveText2 { idc = -1; type = CT_ACTIVETEXT; style = ST_LEFT; x = 0.75; y = 0.55; w = 0.2; h = 0.035; font = FontM; sizeEx = 0.024; color[] = { 1, 1, 1, 1 }; colorActive[] = { 1, 0.2, 0.2, 1 }; soundEnter[] = { "", 0, 1 }; // no sound soundPush[] = { "", 0, 1 }; soundClick[] = { "", 0, 1 }; soundEscape[] = { "", 0, 1 }; action = "closeDialog 0"; text = "Exit"; default = true; }; }; Create 2 script files, one to create the menu dialog(recruitAT.sqf) and another to actually create the unit (recruit.sqf) RecruitAT.sqf Code: titleText["Recruit AT soldier", "PLAIN DOWN"]; _ok = createDialog "RecruitAT"; waitUntil { !dialog }; hint "Dialog closed."; This code is fairly straightforward = we create the dialog we defined in description.ext and wait until the dialog is closed. This is what pops the menu up when you enter the trigger area. When you click on the text for recruit soldier it executes the action you defined in the action variable. For completeness here is the code to create an AI unit and have him join your group. Recruit.sqf Code: _grp = group player; _recruit = _this select 0; hint _recruit; _numunits = count units _grp; if (_numunits < 4) then { _unit = _grp createUnit [_recruit, position player, [], 10, "FORM"] ; [_unit] join _grp ; _unit move position player ; titleText["squad member recruited", "PLAIN DOWN"]; } Originaly posted by rockettgirl Share this post Link to post Share on other sites