Jump to content
🛡️FORUMS ARE IN READ-ONLY MODE Read more... ×
Sign in to follow this  
lucilk

addaction problem

Recommended Posts

can someone explain to me how the addaction works cuz i cant figure it out

i want to have an action for every player on a server so i have put this in init.sqf:

if !(isnull player) then {
null = [] execvm "briefing.sqf";
if (playerSide == west) then { action1 = player addaction ["Support Menu", "lkscripts\menu\open.sqf", [], 1, false, false, "", ""]};
};

ok... now i want them to have the action after they die so i have put this in briefing.sqf:

if ( isNil{player getVariable "mk_killedEHadded"} ) then 
{
player addEventHandler ["killed", 
{ 
	[] spawn {
		waitUntil { alive player }; // waitUntil player has respawned
		execVM "briefing.sqf"; 
		execVM "lkscripts\menu\dead_player.sqf"; 
	};	
}];
player setVariable ["mk_killedEHadded", true];
};

dead_player.sqf gives back the action trough this:

waituntil {alive player};
sleep 1;
action1 = player addaction ["Support Menu", "lkscripts\menu\open.sqf", [], 1, false, false, "", ""];

ok it seems its working but... i cant test it, if i put 4 playable units and go in mp i have the action all is good but if i switch to another unit he doesnt have the action, and if i go close to the first unit the action pops out i acces it and then i have 2 of them, wtf?

how can i just make the action available in mp for all players, but not to show up twice when it goes close to another one?

=======================================================

ooo and i got something alse to

CONDITION PROBLEM

i have a condition in a script like this:

armordone = true;

infdone = true;

helidone = true;

lavhqdone = true;

mvhqdone = true;

paradone = true;

somdone = true;

thdone = true;

th1 = true;

th2 = true;

uavl=true;

ok and i have another script that checks if those condition are true:

if armordone then {action1 = player addaction ["Request Armor Division", "lkscripts\armor.sqf", [], 1, false, true, "", ""]} else {sleep 1; hint "Armor Division is not available"};
sleep 0.02;
if infdone then {action2 = player addaction ["Request Infantry support", "lkscripts\inf.sqf", [], 1, false, true, "", ""]} else {sleep 1; hint "Infantry is not available"};
sleep 0.02;
if helidone then {action3 = player addaction ["Request Helicopter CAS", "lkscripts\casheli.sqf", [], 1, false, true, "", ""]} else {sleep 1; hint "Helicopter CAS is not available"};
sleep 0.02;
if lavhqdone then {action4 = player addaction ["Request LAV HQ", "lkscripts\lavhq.sqf", [], 1, false, true, "", ""]} else {sleep 1; hint "LAV HQ is not available"};
sleep 0.02;
if mvhqdone then {action5 = player addaction ["Request MV-22 HQ", "lkscripts\lavhq2.sqf", [], 1, false, true, "", ""]} else {sleep 1; hint "MV 22 HQ is not available"};
sleep 0.02;
if somdone then {action6 = player addaction ["Request SOM Support", "lkscripts\som.sqf", [], 1, false, true, "", ""]} else {sleep 1; hint "SOM is not available"};
sleep 0.02;
if paradone then { action7 = player addaction ["Request Paratroopers", "lkscripts\paratrooper.sqf", [], 1, false, true, "", ""]} else {sleep 1; hint "Paratroopers is not available"};
sleep 0.02;
if thdone then { action8 = player addaction ["Tomahawk Fire Mission", "lkscripts\menu\tomahawk.sqf", [], 1, true, true, "", ""]} else {};
sleep 0.02;

ok, the question is are those conditions executed for all players, beacuse when for example i "Request Armor Division", that script spawns the armor and at the end its armordone = false, so if i open the menu again i should recive this : "Armor Division is not available", it works fine for me but is this for all clients?,

So if armordone = false for me is it going to be for all clients i mean if i request armor can anyone else request it to?

please help me out on this.

Edited by lucilk

Share this post


Link to post
Share on other sites

Stop bumping your thread just because you get no answer in time.

If someone read this and has an answer he surely will reply here, don't you think?

Just an idea: use publicVariable to distribute the changed conditions on all clients.

Share this post


Link to post
Share on other sites

Hi,

first of all, SWITCHING to another unit won't give this unit the action. Reason is simple: When the init.sqf is executed, it gives the PLAYER the action. Only the player. Then switching to another unit this does not have the action since it was never applied to it. And switching to another unit will not rerun the Init.sqf.

The action stays with the initial unit, so getting close enough to it the action will pop up in your action menu. This, however, is only the case on your machine, not on anyone else's. Another client getting close to the unit will not have the action popping up, since the other clients init.sqf refers to another player.

Next thing:

Variables being defined or changed within a script normally have to be broadcasted. You can do this by

publicVariable "armordone";

Defining or changing variables within triggers, scripts which are executed by triggers or initialization code of objects placed in the editor will normally effect every machine.

A small example:

- Adding your player unit the action "Request Armor Division" in your init.sqf, and you use this action ingame, then the script "armor.sqf" is only executed on your machine, and you have to broadcast your variables.

- Having a radio trigger which provides you to request armor support and klicking on it ingame, the "armor.sqf" would be executed on every participating machine (what'd cause some problems in t his case ;-) ).

Hope that helps a bit.

Edited by Bon

Share this post


Link to post
Share on other sites
Sign in to follow this  

×