Jump to content
peacefull Nation

make all ai do karate code help

Recommended Posts

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

 {if(!isPlayer _x && side _x != playerSide) then {
_x playMove "AmovPercMstpSnonWnonDnon_exerciseKata"  }

 }forEach allUnits;

Share this post


Link to post
Share on other sites

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
[] spawn
{
	while{true} do
	{
		{
			if(!isPlayer _x && side _x != playerSide && _x animationState != "AmovPercMstpSnonWnonDnon_exerciseKata") then
			{
				_x playMove "AmovPercMstpSnonWnonDnon_exerciseKata";
			};
		} forEach allUnits;
	sleep 1;
	};
};

 

Edited by Midnighters
Code revision

Share this post


Link to post
Share on other sites
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

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

 

 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                    

  • Like 2

Share this post


Link to post
Share on other sites
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

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

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 .

  • Like 1

Share this post


Link to post
Share on other sites

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

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;
    };
  };
};

 

  • Like 1

Share this post


Link to post
Share on other sites

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.

V9kigrp.jpg

 

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

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

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

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

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

your code works if i copy and paste it in that ncc command and click server exec it works nice.

V9kigrp.jpg

 

 

 

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

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

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

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×