akvadakar 21 Posted August 29, 2015 Hey guys, I spawn soldiers (server side) and then order them to move (server side too!) but they are not moving! (they can shoot etc.) They spawn & move normally in LAN server. This is how I spawn soldiers: ; UNIT.SQS ; usel (number) - unit type selected in dialog by player - this script is local to player only usel= (_this select 0) publicvariable "usel" closedialog 1000 TitleCut["CLICK ON THE MAP TO CREATE UNIT", "PLAIN DOWN", 1] onMapSingleClick {[_pos] exec "unit1.sqs";True} exit ; UNIT1.SQS - again local to player only onMapSingleClick "" _p= _this select 0 ; helpu - position where player clicked helpu= "HeliHEmpty" createvehicle _p publicvariable "helpu" ~0.1 creating= true publicvariable "creating" ~0.2 server globalchat format ["%1 created", (infarray select usel)] TitleCut["CLICK ON THE MAP TO CREATE ANOTHER UNIT", "PLAIN DOWN", 1] onMapSingleClick {[_pos] exec "unit1.sqs";True} exit ; CHECKU.SQS - this script runs on all clients + server (launched from init.sqs) #s ? creating : goto "ss" ~0.1 goto "s" #ss ? local server : (infarray select usel) createunit [getpos helpu, group wdum, "[this] exec {unitx.sqs}", lvl, "COLONEL"] ~0.1 creating= false publicvariable "creating" ? local server : deletevehicle helpu ~0.1 goto "s" ; UNITX.SQS - for each spawned soldier - all clients + server _u= _this select 0 [_u] join grpnull exit This is how I am trying to make them move: ; MOVE.SQS - script is local to player ; msel - number for trigger radius - ; I created 4 triggers in editor with 10, 50, 200, 500 meters radius ; Triggers: 1 sec, Repeatedly, Countdown, Present West (AIs are West) msel= (_this select 0) publicvariable "msel" closedialog 1000 TitleCut["CLICK ON THE MAP TO SELECT UNITS", "PLAIN DOWN", 1] onMapSingleClick {[_pos] exec "move1.sqs";True} exit ; MOVE1.SQS - local to player onMapSingleClick "" ; these are names of the 4 triggers w10, w50 etc. _a= [w10, w50, w200, w500] _p= (_this select 0) _trig= _a select msel _trig setpos _p helpm1= "HeliHEmpty" createvehicle _p publicvariable "helpm1" ~1.1 server globalchat format ["%1 units chosen", count list _trig] TitleCut["CLICK ON THE MAP TO MOVE UNITS", "PLAIN DOWN", 1] onMapSingleClick {[_pos] exec "move2.sqs";True} exit ; CHECKM.SQS - runs on all clients + server - launched from init.sqs #s ? moving : [] exec "move3.sqs"; goto "ss" ~0.1 goto "s" #ss ~0.2 moving= false publicvariable "moving" ~0.2 goto "s" ; MOVE3.SQS - runs on all clients + server _a= [w10, w50, w200, w500] _t= _a select msel _t setpos getpos helpm1 #s ~1.2 "_x domove getpos helpm" foreach list _t ~0.2 ; I checked the "po" variable (number) in dedicated server by Alpha radio and it showed proper number of AIs in the trigger everytime. ? local server : deletevehicle helpm; deletevehicle helpm1; po= count list _t; publicvariable "po" exit Any ideas? Share this post Link to post Share on other sites
zulu1 145 Posted August 29, 2015 Hey Akvadakar, I think it's maily because newly spawned units/groups are not named. This is what I found that works for my spawning fun and games. _leader = NewSquad select 0[group _leader] exec "movesquad.sqs"[group _leader,sp4] exec "infPatrol.sqs" Works like a charm. Share this post Link to post Share on other sites
akvadakar 21 Posted August 29, 2015 I used OnMapSingleClick to select AIs on the map - player can select & move AIs as he wants so giving names to AIs will not help AFAIK. Share this post Link to post Share on other sites
kenoxite 156 Posted August 30, 2015 It'd be better if you debug all the variables in move3.sqs. That will give you more hints about what's being correctly passed and what not, and then work from there to trace the bug back. Anyway, move3.sqs has other problems. You should run it only on the server. AI units (those not in the group of a player) are handled by the server, and only the server should be dealing with them. Also, doMove (and any other "move" order) is local/global, meaning that the unit must be local and the command is automatically run on all clients. Although I would support Zulu1 suggestion regarding the creation of groups instead of single units, unless you want them to be single for some reason. Remember that in OFP the unit count limit for each side is 63. Share this post Link to post Share on other sites
akvadakar 21 Posted August 30, 2015 I changed the move3.sqs to find any bug but everything worked properly. Dedicated server changed my position (zeus) to the right coordinates, "po" variable shows correct number when I use Alpha radio. I will add the possibility to spawn groups but I must solve the AIs movement firstly. ; MOVE3.SQS ? not local server : exit _a= [w10, w50, w200, w500] _t= _a select msel _t setpos getpos helpm1 zeus setpos getpos helpm1 ~3 zeus setpos getpos _t ~3 zeus setpos getpos helpm #s ~1.2 "_x domove getpos helpm" foreach list _t ~0.2 ; even when I delete the helpm & helpm1 there is no change. ;deletevehicle helpm ;deletevehicle helpm1 po= count list _t publicvariable "po" exit Share this post Link to post Share on other sites
kenoxite 156 Posted August 30, 2015 Ok, I've done some tests myself with a custom version of what you're doing here (in move3.sqs) and all seems to work fine. So, let me recap what you're trying to do: Player chooses the option to select a unit via a dialog move.sqs: The dialog option launches move.sqs with a parameter, that you assign to msel, and you ask him to click on the map to select the units move1.sqs: Then you place the trigger of msel type on the clicked position, and a placeholder (helpm1) to "store" the selecte position, then ask to click for the destination move2.sqs: ??? (you forgot to copy/paste this one, I guess you place the helpm placeholder here) checkm.sqs: Meanwhile you have this script running all the time, which checks if the move global var is true, and if so launches move3.sqs and sets it to false move3.sqs: Runs only on servers. Moves again the type of trigger selected (via msel) to the position of your first placeholder (helpm1), and then orders all units inside it to move to the position of helpm (which I guess is set in move2.sqs). And, while all the global vars are correctly set and passed (msel, helpm1, helpm) the units don't move. You don't need to move the trigger in move1.sqs, as all you need is the helpm1 object. And not knowing how move2.sqs is written I can't tell you if the problem is there (but, if your problem is that units aren't moving, and helpm, which is used to set the destination, is set in move2.sqs... well, that sounds suspicious). Other than that, and unless something very obvious has slipped me by, this really seems a task you must solve yourself. Chop all this system into individual pieces and test them separately, then keep adding until something breaks. And print all the vars all the time, so you know what's going on. That will save you some headaches in cases like this. Share this post Link to post Share on other sites
akvadakar 21 Posted August 30, 2015 Damn it here is the move2.sqs: onMapSingleClick "" _p= (_this select 0) helpm= "HeliHEmpty" createvehicle _p publicvariable "helpm" "wp" setmarkerpos _p ~1 moving= true publicvariable "moving" ~1.3 server globalchat "Units are on the way!" TitleCut["CLICK ON THE MAP TO SELECT ANOTHER UNITS", "PLAIN DOWN", 1] onMapSingleClick {[_pos] exec "move1.sqs";True} exit You get it right, kenoxite. I move the trigger in move1.sqs just to give the player info how many units he chose (server globalchat format ["%1 units chosen", count list _trig]). The changed MOVE3.SQS (my last post) shows that everything is in the right place from the server side perspective as it moves me to all 3 positions (trigger position, helpm & helpm1 position) properly + it shows the proper number of units in the trigger zone. Units are created in server, they are ordered to move in server but they do not move... Share this post Link to post Share on other sites
akvadakar 21 Posted August 30, 2015 Okay after a few depression states I probably managed to make it work. I changed the: _u= _this select 0[_u] join grpnull to _u= _this select 0~0.5? local server : [_u] join grpnull in UNITX.SQS Thanks everybody for your replies :) Share this post Link to post Share on other sites
kenoxite 156 Posted August 31, 2015 Good to see you managed to solve it. TBH I didn't pay much attention to your spawning scripts, I guess I should have :) From now on: make sure everything related to AI units (spawning, issuing orders, etc) is managed by the server only. In general, only run scripts on clients if there's no way around it or it's a task that must be done by clients (like onmapsingleclick). And, when in doubt, check the wiki often, particularly for the information about locallity of each command if you're doing multiplayer. Share this post Link to post Share on other sites