peacefull Nation 6 Posted October 20, 2017 currently this code makes my solder do karate. player playMove "AmovPercMstpSnonWnonDnon_exerciseKata"; if(!isPlayer _x && side _x != playerSide) then { allUnits playMove "AmovPercMstpSnonWnonDnon_exerciseKata"; } }forEach allUnits; this is not making ai do karate please help Share this post Link to post Share on other sites
froggyluv 2130 Posted October 20, 2017 {if(!isPlayer _x && side _x != playerSide) then { _x playMove "AmovPercMstpSnonWnonDnon_exerciseKata" } }forEach allUnits; Share this post Link to post Share on other sites
peacefull Nation 6 Posted October 20, 2017 i should have posted this but thanks. this code {if(!isPlayer _x && side _x != playerSide) then { _x playMove "AmovPercMstpSnonWnonDnon_exerciseKata" } }forEach allUnits; only does it once not looping boss. once its finished i want it to start again Share this post Link to post Share on other sites
Midnighters 152 Posted October 20, 2017 (edited) [] spawn { while{true} do { { if(!isPlayer _x && side _x != playerSide && _x animationState != "AmovPercMstpSnonWnonDnon_exerciseKata") then { _x playMove "AmovPercMstpSnonWnonDnon_exerciseKata"; }; } forEach allUnits; sleep 1; }; }; Edited October 20, 2017 by Midnighters Code revision Share this post Link to post Share on other sites
peacefull Nation 6 Posted October 20, 2017 not working sir Share this post Link to post Share on other sites
Midnighters 152 Posted October 20, 2017 4 minutes ago, peacefull Nation said: not working sir what's the error? What's not working? Share this post Link to post Share on other sites
Midnighters 152 Posted October 20, 2017 posted a revised version, check that one out. Share this post Link to post Share on other sites
peacefull Nation 6 Posted October 20, 2017 am running thse code of nss console and not directly into files yet so that i veryify the code works before i start to add them in sqf files. [] spawn { while{true} do { { if(!isPlayer _x && side _x != playerSide && _x animationState != "AmovPercMstpSnonWnonDnon_exerciseKata") then { _x playMove "AmovPercMstpSnonWnonDnon_exerciseKata"; }; } forEach allUnits; sleep 1; }; }; this code dont work , no error , no effect is taken soldiers are not doing karate. if i execute this code it work but animation is only 1 time and i have to click , i want it to loop , so i tried your code but its not doing anything. if(!isPlayer _x && side _x != playerSide && _x animationState != "AmovPercMstpSnonWnonDnon_exerciseKata") then { _x playMove "AmovPercMstpSnonWnonDnon_exerciseKata"; }; } forEach allUnits; Share this post Link to post Share on other sites
froggyluv 2130 Posted October 20, 2017 I put it in as a function in the Debug and it goes on repeatedly Karate_loop = {{if(!isPlayer _x && side _x != playerSide) then { _x playMove "AmovPercMstpSnonWnonDnon_exerciseKata" }}forEach allUnits;}; {_x call Karate_loop} foreach allunits 2 Share this post Link to post Share on other sites
peacefull Nation 6 Posted October 20, 2017 Karate_loop = {{if(!isPlayer _x && side _x != playerSide) then { _x playMove "AmovPercMstpSnonWnonDnon_exerciseKata" }}forEach allUnits;}; {_x call Karate_loop} foreach allunits working , nice thanks alot , i thank all who taken the time to reply working now thanks so much Share this post Link to post Share on other sites
pierremgi 4751 Posted October 20, 2017 It's weird to cope with a loop in a loop to make things work. Don't do that! There was just a typo in Midnighters' code, far better! 0 = [] spawn { while{true} do { { if(!isPlayer _x && side _x != playerSide && animationState _x != "AmovPercMstpSnonWnonDnon_exerciseKata") then { _x playMove "AmovPercMstpSnonWnonDnon_exerciseKata" }; } forEach allUnits; sleep 1; }; }; Share this post Link to post Share on other sites
peacefull Nation 6 Posted October 21, 2017 if i host then this code works Karate_loop = {{if(!isPlayer _x && side _x != playerSide) then { _x playMove "AmovPercMstpSnonWnonDnon_exerciseKata" }}forEach allUnits;}; {_x call Karate_loop} foreach allunits if my friend host then this code dont work how come ,please help this code is to make all ai do karate only . 1 Share this post Link to post Share on other sites
peacefull Nation 6 Posted October 21, 2017 ok update. if i run this same code in server exec ,global or local then it works. this code above u se i have that in my karate.sqf that code only. is it not working because am missing maybe "{} ? Share this post Link to post Share on other sites
pierremgi 4751 Posted October 21, 2017 As i replied in your previous code (please don't multiply them), your double forEach loop is a bad code. It seems you are interested in scripting. So, start with good usage. You can place the code I gave you in a initServer.sqf, or init.sqf with an extra condition if (isServer) then { code }; You need also to be sure the mission has started. (the playMove command doesn't work if not). So, I suggest something, in init.sqf: [] spawn { if (isServer) then { waitUntil {time > 2}; while{true} do { { if(!isPlayer _x && side _x != west && animationState _x != "AmovPercMstpSnonWnonDnon_exerciseKata") then { _x playMove "AmovPercMstpSnonWnonDnon_exerciseKata" }; } forEach allUnits; sleep 1; }; }; }; 1 Share this post Link to post Share on other sites
peacefull Nation 6 Posted October 21, 2017 if i paste this code Karate_loop = {{if(!isPlayer _x && side _x != playerSide) then { _x playMove "AmovPercMstpSnonWnonDnon_exerciseKata" }}forEach allUnits;}; {_x call Karate_loop} foreach allunits in this box in image then it works. this in game nss admin console was made by some one else and am testing it to se if code works and if it does then i start adding it to my filename.sqf here is what i done as you told me. in my fn_aikarate.sqf i have [] spawn { if (isServer && time > 2) then { while{true} do { { if(!isPlayer _x && side _x != playerSide && animationState _x != "AmovPercMstpSnonWnonDnon_exerciseKata") then { _x playMove "AmovPercMstpSnonWnonDnon_exerciseKata" }; } forEach allUnits; sleep 1; }; }; }; ["karate"] spawn BIS_fnc_guiMessage; so when i click the button from menu in my own menu app this code gets executed cause the message box shows up , how ever the karate code is not taking any affect on enemy ai ? Share this post Link to post Share on other sites
pierremgi 4751 Posted October 21, 2017 Oups! sorry. The code can't work if I put time as an initial condition. Must wait until instead. Corrected above! Not sure how your console work. The BI native is fine. Share this post Link to post Share on other sites
peacefull Nation 6 Posted October 21, 2017 what do you mean by Must wait until instead. Corrected above!? do you edit your code ? in post 3 should i try it Share this post Link to post Share on other sites
peacefull Nation 6 Posted October 21, 2017 am trying to make it work on arma3.server if i use the code in game/host then it works. why dont it work when i try it on arma3server.exe please help. kindly look at this similar code i have on button click it works on arm3.server.exe { if(!isPlayer _x && side _x != playerSide) then { _x setPos screenToWorld[.5,.5]; } }forEach allUnits; this code brings all enemy ai to my location works nice. and now back at the main code ( karate ) am using the same if statement but not working. [] spawn { if (isServer && time > 2) then { while{true} do { { if(!isPlayer _x && side _x != playerSide && animationState _x != "AmovPercMstpSnonWnonDnon_exerciseKata") then { _x playMove "AmovPercMstpSnonWnonDnon_exerciseKata" }; } forEach allUnits; sleep 1; }; }; }; not working. { if(!isPlayer _x && side _x != playerSide && animationState _x != "AmovPercMstpSnonWnonDnon_exerciseKata") then { _x playMove "AmovPercMstpSnonWnonDnon_exerciseKata" }; } forEach allUnits; sleep 1; not working ai not doing karate.. Share this post Link to post Share on other sites
peacefull Nation 6 Posted October 21, 2017 ok update here is a code witch i am able to use when button is clicked , it brings all enemies to my location. fn_getallenemy.sqf { if(!isPlayer _x && side _x != playerSide) then { _x setPos screenToWorld[.5,.5]; } }forEach allUnits; and now here is the karate code again witch i am currently using but not working.fn_aikarate.sqf {if(!isPlayer _x && side _x != playerSide) then { _x playMove "AmovPercMstpSnonWnonDnon_exerciseKata" } }forEach allUnits; [_x] spawn BIS_fnc_guiMessage; i added the [_x] spawn BIS_fnc_guiMessage; just to se if my code executes and works and yes the button when its clicked the mesage box shows how ever the _x shows as blank this is why this karate is not working because the _x is returning no value on this message box is blank. how can i fix this. Share this post Link to post Share on other sites
pierremgi 4751 Posted October 21, 2017 I corrected my code. I never see the waitUntil in yours! If your server is dedicated, there is no player on this PC, so playerSide doesn't mean something on a server only code. Use east or resistance or even west instead. (Not sure why you don't select a group of units) [] spawn { if (isServer) then { waitUntil {time > 2}; while{true} do { { if(!isPlayer _x && side _x == EAST && animationState _x != "AmovPercMstpSnonWnonDnon_exerciseKata") then { _x playMove "AmovPercMstpSnonWnonDnon_exerciseKata" }; } forEach allUnits; sleep 1; }; }; }; Share this post Link to post Share on other sites
peacefull Nation 6 Posted October 21, 2017 trying it now lets se. using it on dedicated server on pc ,using arma3server.exe Share this post Link to post Share on other sites
peacefull Nation 6 Posted October 21, 2017 your code works if i copy and paste it in that ncc command and click server exec it works nice. how ever in my own mod menu it dont work. i am able to use other codes i added my server such as teleport all ai to me. fn_getallenemy.sqf { if(!isPlayer _x && side _x != playerSide) then { _x setPos screenToWorld[.5,.5]; } }forEach allUnits; this code you use se teleports all ai to me works nice. i am using Tonis_Admin_Menu_Main.pbo and modified and added my own code next to other codes that are already their. and now i created a new menu with the file name fn_aikarate.sqf and copied and pasted all your code in their , when i join dedicated server and open the toni's menu and press button nothing happens. i am certainly sure that this fn_aikarate.sqf is being called , as i have added a simple messagebox just to se if it opens when i click the button and it does. how ever the code is not taking any effect on the ai at all. Share this post Link to post Share on other sites
pierremgi 4751 Posted October 21, 2017 No more clue. The Toni's menu, fn_aikarate.sqf and the way you call that in on your side. If you can play on another PC, (as player) just place a radio trigger radio Alpha with the code I gave you (don't omit the handle: 0 = [] spawn {... in on act field) and see what happens. Share this post Link to post Share on other sites
peacefull Nation 6 Posted October 21, 2017 i added another option to my menu http://www.armaholic.com/forums.php?m=posts&q=31212 second post and that is working. am not sure why the ai karate code is not working , am gona try and make another ai karate code with different name and no space in characters. Share this post Link to post Share on other sites
peacefull Nation 6 Posted October 21, 2017 how come if i add this line player playMoveNow "AmovPercMstpSnonWnonDnon_exerciseKata"; it works ? so here is the full code Karate_loop = {{if(!isPlayer _x && side _x != playerSide) then { player playMoveNow "AmovPercMstpSnonWnonDnon_exerciseKata"; }}forEach allUnits;}; {_x call Karate_loop} foreach allUnits this code works but it makes my player do karate , instead i want all ai to do karate , i understand that we add _x instead of player but its not working when i add _x normally we replace the string ( player ) with ( _x ) but i am not understanding what is going on please help Share this post Link to post Share on other sites