Jump to content
Sign in to follow this  
Idomass

private addaction problems

Recommended Posts

Hi i have a mission that i created CSGO style and i have a problem with the defuse script.

the problem is that no one can see the defuse action and activate the script.

the plant bomb is called at the start of the round as:

PBAA = bpsa addAction ["Plant Bomb", {BA = [] execVM "BombplantedA.sqf"} , 0, 0, true, true, "" , "(side _this == opfor) and (_target ==  bpsa) and (_this distance _target < 3)"];

and its private (side _this == opfor) so only opfor can call it.

in BombplantedA.sqf the defuse script called as AddAction:

DBAA = bpsa addAction ["Defuse Bomb", {DBA = [] execVM "defuse_scriptA.sqf"} , 0, 0, true, true, "" , "(side _this == blufor) and (_target == bpsa) and (_this distance _target < 3)"];

And thats is the code at defuse_scriptA.sqf:

hint "Defusing Bomb.."; sleep 7 ;terminate BA; hint "The Bomb has been defused!"; bpsa removeAction actionCTA; [] execvm "ctwin.sqf";

From some reasons the blufor side cant defuse the bomb (He have no action).

I dont know why but i think because the first script "BombplantedA.sqf" that is called in private addaction.

How can i fix it?

Thanks ahead for all the helpers

Share this post


Link to post
Share on other sites

You run a bit of code to tell all players to create a defuse add action. All code when run by an addaction is local to the client that triggered it.

setup an "addPublicVariableEventHandler", and use "publicVariable", to trigger that code block when needed.

You can use the conditions if(server) and if(!server) to filter out if clients store the eventhandler or if the server does. In events where only the server needs to get

the update you can use publicVariableServer. Likewise you can get the client id of a player and use publicVariableClient to send only them the update.

Here is an example that would make a passed object "_sign" have the option for a bis arsenal.

//Loaded on each client using the if(!server) condition in the mission init.

"makeArsenal" addPublicVariableEventHandler
{	
	private ["_sign", "_passedContent"];

			_passedContent = _this select 1; //form [signObject]
			_sign = _passedContent;
			_sign addAction["<t size='1.2' color='#32D138'>BIS Arsenal</t>", "VA.sqf", 0, 5]; 
};

//Code that runs on the server (tweaked to use your object, assuming bpsa is already defined)

globalVariableToSendToTheEventHandler = bpsa;
publicVariable "globalVariableToSendToTheEventHandler";

Same principles for removing the action if needed. One thing to keep in mind if a client is triggering the publicvariable to update others, the code in the eventhandler

wont fire for that single client because of the way publicVariable command works

Share this post


Link to post
Share on other sites

if BPSA is placed in the editor, in the name field just make sure you call it BPSA and then use the same case sensitive name in the code. Otherwise if you create the object on the fly, whatever you use to spawn it, have the output assigned to BPSA. IE// BPSA = createVehicle etc...

Share this post


Link to post
Share on other sites

Oh...

I thought that is some tricky stuff, its already defined

I have mannaged to create to bomb defuse script working using PublicVariable but the problem after a round is finished by bomb defuse\bomb explosion it will retart the bomb script.

this is the init.sqf:

tscore = 0;
ctscore = 0;
rlimit = 0;
rnumber = 0;
bpat = -1;
publicvariable "bpat";
bpbt = -1;
publicvariable "bpbt";
bpatp = -1;
publicvariable "bpatp";
bpbtp = -1;
publicvariable "bpbtp";

this is the script that every round is restarting- roundstart.sqf:

bpat = -1;
publicvariable "bpat";
bpbt = -1;
publicvariable "bpbt";
sleep 1;
actionCTA = bpsa addAction ["Defuse Bomb", {if (bpat <1) exitWith{}; hint "Defusing Bomb..";sleep 7;bpat = -1;publicvariable "bpat";hint "The Bomb has been defused!";bpsa removeAction actionCTA;[] execvm "ctwin.sqf";} , 0, 0, true, true, "" , "(side _this == blufor) and (_target == bpsa) and (_this distance _target < 3)"];
actionCTB =bpsb addAction ["Defuse Bomb", {if (bpbt <1) exitWith{};hint "Defusing Bomb..";sleep 7;bpbt = -1;publicvariable "bpbt";hint "The Bomb has been defused!";bpsb removeAction actionCTB;[] execvm "ctwin.sqf";} , 0, 0, true, true, "" , "(side _this == blufor) and (_target == bpsa) and (_this distance _target < 3)"];
actionTA = bpsa addAction ["Plant Bomb", {bpsa removeAction actionTA;bpsb removeAction actionTB;hint "Planting Bomb.."; sleep 3;bpatp = 2;publicvariable "bpatp";} , 0, 0, true, true, "" , "(side _this == opfor) and (_target == bpsa) and (_this distance _target < 3)"];
actionTB = bpsb addAction ["Plant Bomb", {bpsa removeAction actionTA;bpsb removeAction actionTB;hint "Planting Bomb..";sleep 3;bpbtp = 2;publicvariable "bpbtp";} , 0, 0, true, true, "" , "(side _this == opfor) and (_target == bpsa) and (_this distance _target < 3)"];
[] execvm "bombA.sqf";
[] execvm "bombB.sqf";

rnumber =(rnumber+1);

titletext [format ["Round %1", rnumber], "Plain"];

T1 setPos (getmarkerPos "T1s");
T2 setPos (getmarkerPos "T2s");
T3 setPos (getmarkerPos "T3s");
T4 setPos (getmarkerPos "T4s");
T5 setPos (getmarkerPos "T5s");

CT1 setPos (getmarkerPos "CT1s");
CT2 setPos (getmarkerPos "CT2s");
CT3 setPos (getmarkerPos "CT3s");
CT4 setPos (getmarkerPos "CT4s");
CT5 setPos (getmarkerPos "CT5s");
T1 setDamage 0; 
T2 setDamage 0; 
T3 setDamage 0;
T4 setDamage 0; 
T5 setDamage 0;    
CT1 setDamage 0;  
CT2 setDamage 0;  
CT3 setDamage 0;  
CT4 setDamage 0;  
CT5 setDamage 0;  
T1 setdir 180;
T2 setdir 180;
T3 setdir 180;
T4 setdir 180;
T5 setdir 180;
CT1 setdir 0;
CT2 setdir 0;
CT3 setdir 0;
CT4 setdir 0;
CT5 setdir 0;
T1 allowdammage true;
T2 allowdammage true;
T3 allowdammage true;
T4 allowdammage true;
T5 allowdammage true;
CT1 allowdammage true;
CT2 allowdammage true;
CT3 allowdammage true;
CT4 allowdammage true;
CT5 allowdammage true;
deletevehicle d;
ctw = 0;
tw = 0;
trg1 settriggerstatements ["!this","null = [] execvm 'ctwin.sqf';",""];
trg settriggerstatements ["!this","null = [] execvm 'twin.sqf';",""];
rtimel = 180;
while {rtimel > 0} do {
rtimel = (rtimel -1);
titletext [format ["Round time left is %1 seconds",rtimel],"plain down"];
sleep 1;
if (bpat >1) exitWith{};
if (bpbt >1) exitWith{};
if (ctw >1) exitWith{};
if (tw >1) exitWith{};
};
if (bpat >1) exitWith{};
if (bpbt >1) exitWith{};
if (ctw >1) exitWith{};
if (tw >1) exitWith{};
[] execvm "ctwin.sqf";

lets say that the bomb is planted on A, so this is bomba.sqf:

waituntil {bpatp >1}; 
hint "The Bomb has been planted..";trg1 settriggerstatements ["false","null = [] execvm 'ctwin.sqf';",""];bpat = 46;publicvariable "bpat";while {bpat >1} do {bpat = (bpat-1);titletext [format ["%1 seconds to detonation",bpat],"plain down"];sleep 1};if (bpat <1) exitWith{};sleep 0.5;explosion1 = "R_60mm_HE" createVehicle (getMarkerPos "baep");bpsa disableCollisionWith explosion1;[] execvm "twin.sqf";
if (true) exitwith {};

the problem in here probably i dint know why but it makes the next round start like the bomb has been planted. (TWin.sqf calls back the roundstart.sqf)

Edited by eldar

Share this post


Link to post
Share on other sites

///THIS IS JUST AN EXAMPLE

//This lets you have an addaction to interact with a sign. I use publicVariable to send the needed info to the clients. The addaction then has the client send the update to remove the addaction for all other players

"makeAddAction" addPublicVariableEventHandler
{	
	private ["_assetChosen", "_csatFlag", "_passedContent"];

			_passedContent = _this select 1;
			_assetChosen = _passedContent select 0;
			_csatFlag = _passedContent select 1;
			addActionID = _csatFlag addAction[format["<t size='1.5' color='#ffff00'>Capture the %1</t>", _assetChosen],	{
																											cutText ["Capturing... Standby","PLAIN",1];
																											playerHitFlag = true;
																											removeAddAction = [_this select 0];
																											publicVariableServer "playerHitFlag";
																											publicVariable "removeAddAction";
																											(_this select 0) removeAction (_this select 2);
																											}, 0, 6];
			//systemChat format["Capture addAction CREATED"];

};

"removeAddAction" addPublicVariableEventHandler
{	
	private ["_csatFlag", "_passedContent"];

			_passedContent = _this select 1;
			_csatFlag = _passedContent select 0;
			_csatFlag removeAction addActionID;
			//systemChat "Capture addAction REMOVED";

};

All your addactions need to be added and removed via addpubliceventhandler and a signal from publicVariable. You probably arent having the appropriate machines remove the addaction when its need. Thus people still get the option to difuse

Edited by zakiechan

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  

×