Jump to content
Sign in to follow this  
Sc0rc3d

Chemlight on Soldier [Multiplayer]

Recommended Posts

Hi Guys,

in my actual "Night-Mission" i wannt to set on every playable Blue-Unit an Chemlight on his Shoulder. So far it works pretty well but

its not working complettly... I Hope you have some good Ideas to let me fix it that i can use it and for sure you too. :D

What i wannt is that the Group Leader has an AddAction to setup on every Unit of his group an Chemlight on her Sholders and

deactivated if he wannt. The way it acctualy works is i give every Unit the Option (per Init line) to Activate/Deactivate it.

It works in Multiplayer so far pretty well.

Init Line of the Unit:

ir = this addAction["<t color='#31B404'>Chemlights ON</t>", "chem_on.sqf",[],3,false,false,"","player == _target"];

chem_on.sqf

 
// Chemlight on Soldiers v0.1 by Sc0rc3d

_target = _this select 0;
_caller = _this select 1;
_id = _this select 2; 
_caller removeAction ir;

lgt_array = [];

   {
       if (side _x == West) then {

              lgt = "Chemlight_red" createVehicle [0,0,0];
              lgt attachTo [player, [0,-0.03,0.07], "LeftShoulder"];

lgt_array = lgt_array + [lgt];
                                 };

   } foreach allunits;

ir2 = _target addAction["<t color='#B40404'>Chemlights OFF</t>", "chem_off.sqf",[],3,false,false,"","player == _target"];

chem_off.sqf

// Chemlight on Soldiers v0.1 by Sc0rc3d
_target = _this select 0;
_caller = _this select 1;
_id = _this select 2; 
_caller removeAction ir2;  

{deletevehicle _x;}foreach lgt_array;

ir = _target addAction["<t color='#31B404'>Chemlights ON</t>", "chem_on.sqf",[],3,false,false,"","player == _target"];

Demo Mission: http://www.mediafire.com/?c3fwha7qqc9adr0

I actually workin on it to get it workin smooth with more functions. :)

so far...

Sc0rc3d

Edited by Sc0rc3d

Share this post


Link to post
Share on other sites

a few things to do at the start of chem_on.sqf - i do this by default to make sure I know what its doing - this stuff is passed to all addaction's

try

 _target = _this select 0; //target - if there is one for the addaction. In this case the player.
_caller = _this select 1;// person calling the addaction - hopefully the player
_id = _this select 2; //the id of the addaction.
_caller removeAction ir;  // you can use _id if you want also instead of ir - but ir works as its a global name

lgt_array = []; 

   { 
       if (side _x == West) then { 

              lgt = "Chemlight_red" createVehicle [0,0,0]; 
              lgt attachTo [_x, [0,-0.03,0.07], "LeftShoulder"]; 

lgt_array = lgt_array + [lgt]; 
                                 }; 

   } foreach units group _caller; 

ir2 = _caller addAction["<t color='#B40404'>Chemlights OFF</t>", "chem_off.sqf"];

nice idea hope this helps - not tested as not at home pc.

---------- Post added at 23:37 ---------- Previous post was at 23:14 ----------

tested and it looks awesome!!! great job. didn't think about doing this and going to have to test in MP with mates soon.

Having an option for color would be a nice touch.

one change I have made is to change the unit init to

ir = this addAction["<t color='#31B404'>Chemlights ON</t>", "chem_on.sqf",[],3,false,false,"","player == _target"];  

this means only the person who is in the team leader spot can turn the lights on and off. it will stop the possibility of another group member facing the leader and using the addaction option. having the second false also stops the option coming up all the time as it can get in the way of other options you may want to perform.

Edited by KevsnoTrev

Share this post


Link to post
Share on other sites

if it work can you please make a template so I can copy and paste it onto a missions please as I find it easy to dpbo stuff and take a look how it done thank in advance

Share this post


Link to post
Share on other sites

This is why I need to learn how to code. have wanting to see this done for long time. Good job man OP.

Would like to see this done on the back of the helmets also ( During A HALO). Like how the VIP strobes worked in A2AO. Have not been able to test yet but do the Cemlights move with the player aka Crouch to prone or are the at a fixed height in space and just follow the player around. One more thing, are there IR cemsticks in game at his time. I think there where in A2 but with ACE 2. Because if they where only visible to your side (Blufor/OPfor) Like the IR lasers should be that would be sweet.

Share this post


Link to post
Share on other sites

Thanks for the replay will try to adept and test it at home... :)

Edited by Sc0rc3d

Share this post


Link to post
Share on other sites

Hi Sc0rc3d,

Have you tested in MP? I am concerned the lgtarray will delete all lights for all players on the same side. All lights are going into this array.

i have tested with publicvariable and all works well in MP, I can put code up if you want to see it...

---------- Post added at 08:40 ---------- Previous post was at 07:47 ----------

I am just doing some work on a check to see if the player is holding a light and if so then it will attach to uniform.

Share this post


Link to post
Share on other sites

@sgt_Savage2003 I think it sould work in sp too.

@KevsnoTrev

Yes we played a few minutes ago a ~2 hour Mission and it works perfect for 9/10 group Members the 10th has problems he can't deactivate the Chemlights. But the Arma Alpha Update Today broke some cba functions... I will testing the scripts a bit more and try to advance the code.

Yes i am concerned too about the "foreach units group" i will change this in the next Version (+color selector) that every Unit can do its one thing. And one more Bug. In case of Respawn the script issnt in the init of the player i need to implement an event Handler too. ;)

so far

Sc0rc3d

Edited by Sc0rc3d

Share this post


Link to post
Share on other sites

I haven't tried moving them like that, but I have something that works in MP, but I am currently trying to get it to work where you only get the addaction if you have the chemlight in your gear, vest or backpack.

i have the check in place for each one and even created a param in the description.ext, but cannot get it to function past turning on. Option to turn off is bugged at this stage.

I have used the basis of what Sc0rc3d pasted here.

I have made this aimed at MP so each player can put a light on if they have one - sort of how ACE does it for arrowhead.

I have changed the array to a publicvariable for each soldiers chem light.

The way this works at this time is that you get a main menu, then in the submenu you get the option to turn on a light of each colour. then you can only turn off that colour, this stops the lights doubling up and getting weird results in MP.

respawn you do not get the menu back so have to put something in for this yourself.

Call from the unit initialition in the editor.

 resetlist =  this addaction ["Attach Chem Light", "chemlights\chem_init.sqf",[],6,false,false, "((player) == _target)"];

chemlights\chem_init.sqf

_target = _this select 0;
_caller = _this select 1;
_id = _this select 2;

_caller removeaction _id;


   RedOn = _caller addAction["<t color='#B40404'>Chemlight Red On</t>", "chemlights\chem_on.sqf",["Chemlight_red"],6,false,false,"","_target == ( player)"];
   BlueOn = _caller addAction["<t color='#68ccf6'>Chemlight Blue On</t>", "chemlights\chem_on.sqf",["Chemlight_blue"],6,false,false,"","_target == ( player)"];
   YellowOn = _caller addAction["<t color='#fcf018'>Chemlight Yellow On</t>", "chemlights\chem_on.sqf",["Chemlight_yellow"],6,false,false,"","_target == ( player)"];
   GreenOn = _caller addAction["<t color='#30fd07'>Chemlight Green On</t>", "chemlights\chem_on.sqf",["Chemlight_green"],6,false,false,"","_target == ( player)"];

chemlights\chem_on.sqf

_target = _this select 0; //target - if there is one for the addaction. In this case the player.
_caller = _this select 1;// person calling the addaction - hopefully the player
_id = _this select 2; //the id of the addaction.
_caller removeAction _id;  

_ltcolor = (_this select 3) select 0;    // color of the chem light to turn on.

           _lgt = _ltcolor createVehicle [0,0,0]; 
           _lgt attachTo [_caller, [0,-0.03,0.07], "LeftShoulder"]; 
           _caller setvariable ["lgtarray", _lgt,true];


//_caller removeaction actioncloselist;

if (_ltcolor =="Chemlight_Red") then {
       RedOff = _caller addAction["<t color='#B40404'>Chemlight Red OFF</t>", "chemlights\chem_off.sqf",[_ltcolor],6,false,false,"", "_target == ( player)"];
       _caller removeaction blueon;_caller removeaction yellowon;_caller removeaction greenon;
       };
if (_ltcolor =="Chemlight_Blue") then {
       actionBlueOff = _caller addAction["<t color='#68ccf6'>Chemlight Blue OFF</t>", "chemlights\chem_off.sqf",[_ltcolor],6,false,false,"","_target == ( player)"];
       _caller removeaction redon;_caller removeaction yellowon;_caller removeaction greenon;
       };        
if (_ltcolor =="Chemlight_Yellow") then {
       actionYellowOff = _caller addAction["<t color='#fcf018'>Chemlight Yellow OFF</t>", "chemlights\chem_off.sqf",[_ltcolor],6,false,false,"", "_target == (player)"];
       _caller removeaction blueon;_caller removeaction redon;_caller removeaction greenon;
       };
if (_ltcolor =="Chemlight_Green") then {
       actionGreenOff = _caller addAction["<t color='#30fd07'>Chemlight Green OFF</t>", "chemlights\chem_off.sqf",[_ltcolor],6,false,false,"", "_target == ( player)"];
       _caller removeaction blueon;_caller removeaction yellowon;_caller removeaction redon;
       };

chemlights\chem_off.sqf

_target = _this select 0;
_caller = _this select 1;
_id = _this select 2;

_ltcolor = (_this select 3) select 0;

_caller removeAction _id;

deletevehicle (_caller getvariable "lgtarray"); _caller setvariable ["lgtarray",nil,true];

resetlist = _caller addaction ["Attach Chem Light", "chemlights\chem_init.sqf",[],5,false,false,"", "_target == ( player)"];

For those using the BTC revive, you need to add the addaction to the script in two places.

BTC_player_killed and BTC_player_respawn - add the line

resetlist =  player addaction ["Attach Chem Light", "chemlights\chem_init.sqf",[],6,false,false, "((player) == _target)"];

at the end of both of these sections, just before the last };

I'll update as soon as I am happy with the MP and is it in gear options......

Share this post


Link to post
Share on other sites

I have a solution - sorry if it takes your thunder - tested on hosted but not dedicated.

- publicvariables to create an addaction menu system.

- Added and evenhandler to give back menu on respawn.

- Parameter to see if players want chemlight in their inventory or just 'magically' create one.

Let me know if there are any bugs.

Download from Google Drive:

Zip file

Or

PBO File

Enjoy playing as much as I did making it.

Please credit if used in a mission - its all I ask.

Sc0r3d gets the real credit for the idea. Please improve on it if you feel the need to.

Share this post


Link to post
Share on other sites

Updated the Mission - same links. Forgot it had a target in there that was from a mod.....

Share this post


Link to post
Share on other sites

This works great.

A small issue if a player try to activate attach chem on another player, you will put and extra chem light on your self.

This will overwrite the first one and you can't turn it off.

And the action menu will be cluttered with attach commands.

Is there an AI init command I can use to force chem light on?

Share this post


Link to post
Share on other sites

thanks Bullet - I didn't test for that.

Will see what I can do to change something to allow for light already being on a player.

I always seem to have issues with addactions that can be seen when facing another player. i thought the player == _target would remove this, but it now makes sense that even when looking at another playable unit it is still true.

I have not tested or done anything for AI, maybe the group leader should have all the control for the lights for AI in the squad and leave the player to turn their own on/off at will!??

Share this post


Link to post
Share on other sites

I have not tested or done anything for AI, maybe the group leader should have all the control for the lights for AI in the squad and leave the player to turn their own on/off at will!??

Something like that would be great. If it would be possible to turn chems on/off just like you do with lasers and flashlights through the command menu.

Share this post


Link to post
Share on other sites

the command menu is something I don't know about - is it even possible to script new options in there, or would it have to be modded?

I have a WIP of AI control through the addaction - I need to test in MP. it goes back to the first method (sort of) that Sc0rc3d did where the group leader has the option to turn off the groups chem lights.

Got a little work to do but will hopefully have something done in the next few days - depending on the kids!!

Share this post


Link to post
Share on other sites

I have updated - should be good in MP. please give feedback if you can still turn on lights by looking at another player.

Changes:

Added a multiplayer check, if in single player when player adds chemlight all AI in same group get a chemlight on their shoulder.

I have tried to do the same for MP, but I keep running into walls.

if anyone can help get an array of units in the current group and then remove all human players from the same array; that would be great.

Updated links.

Zip file is the mission folder not a pbo

Download from Google Drive:

Zip file

Or

PBO File

Enjoy playing as much as I did making it.

Please credit if used in a mission - its all I ask.

Sc0r3d gets the real credit for the idea. Please improve on it if you feel the need to.

Share this post


Link to post
Share on other sites

Mind sharing this file again please? its not available anymore :-/

Thanks

Share this post


Link to post
Share on other sites

Hello i have a problem in the game when I login server where you receive an error message: you can not play / edit this mission it is downloadable content that has been
deleted. rhisusf-c-troops, ares, ryanzombiesfunctons, ryanzombies 

 

Share this post


Link to post
Share on other sites

I tried doing something similar to this a while ago and ran into an issue with units entering vehicles and the chemlights became attached to the vehicle instead. Not sure if you have ran into the same issue.

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  

×