Jump to content
Sign in to follow this  
WikedBubble

Get AI unit to Shoot Payer uuid not in my clan array?

Recommended Posts

Hello Everyone,

I am new to Arma2 scripting and editing and was hoping someone might have a little more insight than me. Unfortunately I am not a developer and am having some trouble wrapping my head around the syntax required to get a "Blufor" unit to fire upon a player who is not in a predefined array.

I have read up and successfully created an array filled with player uuid's that I would like to have not fired upon by a blufor unit. I would like to trigger this with an area trigger but if that cannot be done, maybe I can just have the individual unit/units act upon this command. I have found the "dotarget" and "dofire" commands but I really have no idea how to implement them.

Basically I have a base setup that I only want certain players to have access to, when a player not in my array gets to close or in range of the bluefor unit/units I would like them to fire upon said player who's uuid is not in my array.

I do know that this will involve the unit getting the player uuid and comparing it to the predefined array then target and fire upon the player if that uuid is not in my array.

I have searched and searched for something similar with no luck, I realize that asking the community to do all the work is a bit selfish but I really have no Idea what I am doing and figured this would be the best place to start.

Any input, scripts or help is greatly appreciated.

Sincerely ,

WikedBubble :confused:

Share this post


Link to post
Share on other sites

Well basically it's like this....you can use addrating to make everyone shoot at them... but depends on how you want to use it, call it etc..

_uidarray = ["123456","654321","456789"];

if (not (_unit in uidarray)) then {_unit addrating -10000};

Share this post


Link to post
Share on other sites
Well basically it's like this....you can use addrating to make everyone shoot at them... but depends on how you want to use it, call it etc..

_uidarray = ["123456","654321","456789"];

if (not (_unit in uidarray)) then {_unit addrating -10000};

Sweet, I will try this, from the looks of it I can put this in an area trigger? So when a player enters the area his addrating is reduced to enemy if he is not in the array correct?

Share this post


Link to post
Share on other sites

ya that doesn't seem to work, could be my trigger though, i'll keep trying, thanks again

---------- Post added at 21:19 ---------- Previous post was at 19:47 ----------

Suck it and see it mate... I did no testing!

Hey so I tried putting "_uidarray = ["123456","654321","456789"];

if (not (_unit in uidarray)) then {_unit addrating -10000};" in the On Act. of an area trigger replacing "123456" etc with my own uid's and receive "Local variable in global space". I then tried creating an sqs. file with the code and had the trigger call to it from On Act. with [this] exec "scripts\admins.sqs". and it doesn't seem to do anything, like I said I am very new to this and have no Idea what I am doing, is this how you would activate it with a trigger or am I being completely stupid. twirly If you don't mind helping a bit more how would you go about introducing "addrating" into your missions?

Bubble

---------- Post added at 22:01 ---------- Previous post was at 21:19 ----------

So after more reading it looks like .sqf files work better so I did similar to above and put this in the On Act. of my trigger nul = [this] execVM "scripts\admins.sqf" but still no luck. I am reading through the tutorials and things but it is going to take me a while to educate myself. Any input is helpful, thank you in advance.

Share this post


Link to post
Share on other sites

First off MP programming is not at all easy and may not be the best place to start. There's all sorts of issues with "locality". What gets executed on the server...what gets executed on the clients etc. Which computer runs the script... all sort of things to know.

You can't test the MP stuff unless you run a MP game... which makes testing a challenge all by itself.

Before you can do anything Multiplayer... you need to understand this sort of stuff... http://forums.bistudio.com/showthread.php?96812.

For instance... the player is different on all machines and local to the machine he exists on. You must understand how this all fits together.

You will get lots of help in these forums.... but no-one is going to write your scripts for you... so in the long run you will have to learn. Hope you stick around long enough to do that! :)

Share this post


Link to post
Share on other sites

twirly, I am glad you have decided to point me in the right direction and I look forward to being and active member in these forums. After a bit of reading I have realized that you are right, MP is def. not the place to start. Either way at least I have a starting point and I look forward to any other help being provided here. If any one else wants to chime in with their two cents I am willing to listen.

Bubble

Share this post


Link to post
Share on other sites

You'll have to run something like this on the server (dedicated) only. This is basically a purpose built trigger which executes about every one second.

It needs an object and a radius.

I hardly ever mess with editor placed stuff.... so you're stuck with this :)

myscript.sqf:-

if (not isDedicated) exitwith {};

_obj = _this select 0;
_rad = _this select 1;

_UIDarray = ["123456","654321","456789"];

_list = [];

while {true} do {

     _list = (position _obj) nearEntities [["Man"],_rad];

     for "_i" from 0 to (count _list)-1 do {

           _dude = _list select _i;
           _rating = rating _dude;
           _UIDdude = getplayerUID _dude;

           if (not (_UIDdude in _UIDarray) and (_rating > -10000)) then {
                 _dude addrating -10000;
           };

           sleep 0.01;
     };

     sleep 1;
};

Execute it with an object and a radius as parameters.

nul = [someobject,radius] execVM "myscript.sqf";

I haven't tested this but it should work. See how you get on.

Hope you enjoy your time with Arma!

Edited by twirly
Corrections

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  

×