Jump to content
Sign in to follow this  
Kerry

Civi dies as he picks up a weapon

Recommended Posts

Hi,

I do not know how to write ArmA script files, sqs or sqf.

banghead.gif

So I was wondering if somebody could help me with this one.

I am trying to find, or make, a script in which as a specific unit(s) picks up a weapon, he will die, or the weapon and ammo will atleast be deleted. The only thing, if anything, they could carry would be ACE medical suplies.

If you are in the mood to play Mommy, then baby me threw this . otherwise, please just explain it! smile_o.gif  

But the playing Mommy is welcome!

Thanks for you're time!

Share this post


Link to post
Share on other sites

So picking up any type of weapon should kill the soldier? Because you also say "or the weapon and ammo will atleast be deleted" - which is a totally different approach.

Bottom line: I guess you just want some people to not be able to pick up any weapon, right?

VictorFarbau

Share this post


Link to post
Share on other sites

crazy_o.gif

Yes. Anything in their inventory, i need them to die.

Share this post


Link to post
Share on other sites

go to your mission folder, and create a empty text file in there. Rename it to "scriptofdeath.sqf" (w/o the quotes).

Copy-paste this code in there

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">private["_items","_allowedItems","_x"];

if(isServer) then {

       if(isnil "Kerry_scriptOfDeath") then {

               Kerry_scriptofDeath = true;

               Kerry_watchedUnits = [(_this select 0)];

               _allowedItems = [];  // here you can add class names of items that are allowed

                                    // example:    _allowedItems = ["30Rnd_556x45_Stanag"];

               while { (count Kerry_watchedUnits) > 0 } do {

                       {

                               if(isNull _x || (!alive _x)) then {

                                       Kerry_watchedUnits = Kerry_watchedUnits - [_x];

                               } else {

                                       _items = ((magazines _x) + (weapons _x)) - _allowedItems;

                                       if(count _items > 0) then {

                                               _x setdamage 1;

                                               Kerry_watchedUnits = Kerry_watchedUnits - [_x];

                                       };

                               };

                       } forEach Kerry_watchedUnits;

                       sleep 5;

               };

               Kerry_scriptofDeath = nil;

       } else {

               Kerry_watchedUnits = Kerry_watchedUnits + [_this select 0];

       };

};

true

In the mission editor, copy-paste this line

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">tmp  = [this] execVM "scriptofdeath.sqf"

into the Initialisation text field of each unit that shall not carry anything.

Share this post


Link to post
Share on other sites

      " if(isnil "Kerry_scriptOfDeath") then {

               Kerry_scriptofDeath = true;

               Kerry_allowedItems = [];  // here you can add class names of items that are allowed"

Thank you, Soooo much!!! notworthy.gif

Question:

I noticed how it says "Kerry" inside of the script.

1. Does my name have to be kerry ingame? (Just a silyl guess)

2. Will this work on a dedicated? or Only home hosted game?

If its home only, then that is fine.

P.S- I owe you   yay.gif

Share this post


Link to post
Share on other sites

1) By giving those global variables the prefix/tag "Kerry_", I'm making sure that I'm using a variable name, which is not already used by some other addon or mod. This simply avoids overlaps, that would cause errors or break some functionality.

2) Both

edit: updated the script above

- removes dead or non-existent units from the array Kerry_watchedUnits now

- fixed a typo

- list of allowed items is a local variable now

Share this post


Link to post
Share on other sites

So in the allowdObjects line, I put in "ACE_Bandage", which works, and i also made another line and put "ACE_Morphine", and they work.

But when you pick them up together, you die.

Is there a way around that?

*EDIT*

Does SQF or SQS recognize ACE class names? Or is it only default ArmA class names?

Share this post


Link to post
Share on other sites

Post what you did with that "other line".

Something like this?

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> _allowedItems = ["ACE_Bandage"];

 _allowedItems = ["ACE_Morphine"];

It should be:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_allowedItems = ["ACE_Bandage","ACE_Morphine"];

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  

×