Jump to content
Sign in to follow this  
commanderx

How to assign a setvariable with params set

Recommended Posts

Hi,

I have the following problem.

In my mission template I would like to make 3 teamleader able to perform AGM medic tasks with this setVariable ["AGM_IsMedic", true]; That works fine but furthermore I would like to make this dependable from what I choose at the beginning of the mission with a parameter. Also that should work while someone is joining with one of the teamleadslots while mission is in progress. So I have the variable _team_medic = paramsArray select 3 (in the init.sqf) but don´t know how to assign the setvariable command.

Best regards

Kai

Share this post


Link to post
Share on other sites

I hope I understand you correctly here as I've never worked with teams before. But maybe this helps you:

{
   _x setVariable ["AGM_IsMedic", true];
} forEachMemberTeam _team_medic;

Share this post


Link to post
Share on other sites

The 3 teamleader are not in the team _team_medic cause this is not a team. This variable is just 1 or 0. If _team_medic == 1 then all the teamleader (they have the names s2, s3 and s4) should be able to perform medic tasks. If 0 then not.

Share this post


Link to post
Share on other sites

This should do the job:

[color=#FF8040][color=#191970][b]if[/b][/color][color=#8B3E2F][b]([/b][/color][color=#1874CD]_team_medic[/color] [color=#8B3E2F][b]=[/b][/color][color=#8B3E2F][b]=[/b][/color] [color=#FF0000]1[/color][color=#8B3E2F][b])[/b][/color] [color=#191970][b]then[/b][/color]
[color=#8B3E2F][b]{[/b][/color]
   [color=#1874CD]_medics[/color] [color=#8B3E2F][b]=[/b][/color] [color=#8B3E2F][b][[/b][/color][color=#8B3E2F][b]][/b][/color][color=#8B3E2F][b];[/b][/color]
   [color=#8B3E2F][b]{[/b][/color]
       [color=#1874CD]_medics[/color] [color=#191970][b]pushBack[/b][/color] [color=#8B3E2F][b]([/b][/color][color=#191970][b]missionNamespace[/b][/color] [color=#191970][b]getVariable[/b][/color] [color=#000000]_x[/color][color=#8B3E2F][b])[/b][/color][color=#8B3E2F][b];[/b][/color]
   [color=#8B3E2F][b]}[/b][/color] [color=#191970][b]forEach[/b][/color] [color=#8B3E2F][b][[/b][/color][color=#7A7A7A]"s1"[/color][color=#8B3E2F][b],[/b][/color] [color=#7A7A7A]"s2"[/color][color=#8B3E2F][b],[/b][/color] [color=#7A7A7A]"s3"[/color][color=#8B3E2F][b],[/b][/color] [color=#7A7A7A]"s4"[/color][color=#8B3E2F][b]][/b][/color][color=#8B3E2F][b];[/b][/color]

   [color=#191970][b]if[/b][/color][color=#8B3E2F][b]([/b][/color][color=#000000]player[/color] [color=#191970][b]in[/b][/color] [color=#1874CD]_medics[/color][color=#8B3E2F][b])[/b][/color] [color=#191970][b]then[/b][/color]
   [color=#8B3E2F][b]{[/b][/color]
       [color=#000000]player[/color] [color=#191970][b]setVariable[/b][/color] [color=#8B3E2F][b][[/b][/color][color=#7A7A7A]"AGM_IsMedic"[/color][color=#8B3E2F][b],[/b][/color] [color=#000000]true[/color][color=#8B3E2F][b]][/b][/color][color=#8B3E2F][b];[/b][/color]
   [color=#8B3E2F][b]}[/b][/color][color=#8B3E2F][b];[/b][/color]
[color=#8B3E2F][b]}[/b][/color][color=#8B3E2F][b];[/b][/color][/color]

Kudos to Killzone_Kid for his SQF to BBCode Converter.

By the way, you can also use boolean types (true, false) for your variable _team_medic. Then you don't have to do

if(_team_medic == 1) then {...}

but instead, you can do

if(_team_medic) then {...}

Edited by Heeeere's Johnny!

Share this post


Link to post
Share on other sites

Will something like this work?

["medic", "onPlayerConnected", { player setVariable ["AGM_IsMedic", true];}] call BIS_fnc_addStackedEventHandler;

Share this post


Link to post
Share on other sites

It won't work as you want it, because if you execute that in the init.sqf, this EH will fire on every connected client whenever a new client connects. So not only will EVERY connected player get this variable set, they will only get it set when another player connects after them.

You should put the code block I posted above into the init.sqf, because it will check on the player's connection if he connected as one of the medics. This is independent from other connected players and will have no effect on them.

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  

×