Jump to content
Sign in to follow this  
mordeaniischaos

Addaction to specific unit TYPES in MP?

Recommended Posts

I am creating a small script to allow team leaders to set respawn points for their squads. I have that mostly worked out except I rely on the TL's inits to give them the action, and if they die it's gone. I'm wondering if there's a way to script it so that every x period of time it adds the action to all units of a particular classname, so that it can be easily applied to other missions in the future without needing to do any extra work, as this will likely be used in a mission starting template for my community.

Even better would be if I could have a script that would set it on mission start for all units of that classname, and then when players respawn it checks the class and then only adds the action if the class matches. I assume there's a way to do that using onPlayerRespawn.sqf

---------- Post added at 17:07 ---------- Previous post was at 16:22 ----------

Here's the onPlayerRespawn.sqf I've tried using:

_unit = _this select 0;
if (typeof _unit == "B_Soldier_SL_F") then {_unit addaction ["Set Respawn Location", "movingrespawn.sqf", "",  0, false, true, "", "_this == _target"]};
_unit hint  "Tomatoes and Stuff";

but it's not doing anything because (possibly for other reasons as well) I can't get loadouts to load in the respawn system. I pasted a generic one from the wiki just to see if it would work but it isn't showing in the list.

Edited by MordeaniisChaos

Share this post


Link to post
Share on other sites

hi MordeaniisChaos , both hint & addAction effect is only local, you need to use BIS_fnc_MP in order to show the action option your your players. In your case, i think you may still need publicVariable and addPublicVariableEventHandler to trigger the player to execute hint command

Share this post


Link to post
Share on other sites

I think the Respawn and MPrespawn eventhandlers is what you're looking for. No need for a loop.

https://community.bistudio.com/wiki/Arma_3:_Event_Handlers#MPRespawn

this addMPEventHandler ["MPrespawn"{ _unit = _this select 0; if (typeof _unit == "B_Soldier_SL_F") then {_unit addaction ["Set Respawn Location", "movingrespawn.sqf", "",  0, false, true, "", "_this == _target"]}; _unit hint "Tomatoes and Stuff"; }

I'm not sure if the EH stays after respawn, but I'm pretty sure it does. You might also want to include a locality check so it only gets added to units by the server or the units themselves.

Edited by L3TUC3

Share this post


Link to post
Share on other sites
hi MordeaniisChaos , both hint & addAction effect is only local, you need to use BIS_fnc_MP in order to show the action option your your players. In your case, i think you may still need publicVariable and addPublicVariableEventHandler to trigger the player to execute hint command

I dunno about hint, but addaction worked fine for other players when they were in the correct slot. I'll post my solution in a bit, but I have it all working now.

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  

×