Jump to content
Sign in to follow this  
A-SUICIDAL

Deploy-Stow Vehicle Camo problem

Recommended Posts

I wrote a script for deploying/stowing a camo cover for a vehicle. Option to deploy appears when near the vehicle, after deploying the camo cover and option to stow appears. It works fine offline. If I deploy it, I can then switch player and stow it. But when I deploy it online, other players cannot stow it, instead they still see the option to deploy it, and when they do, there are then 2 camo covers overlapping. So I need help. It's a good script for any mission creator, if I only I can get it to work correctly online.

init.sqf:

camoStowed = true;
camoDeployed = false;

vehicle init:

this addAction ["Deploy Camo Cover","camo_deploy.sqf",nil,1,true,true,"","alive _target and camoStowed and player distance _target<7"];  

this addAction ["Stow Camo Cover","camo_stow.sqf",nil,1,true,true,"","alive _target and camoDeployed and player distance _target<15"];

camo_deploy.sqf:

_veh = _this select 0;
_man = _this select 1;

if ( vehicle _man != _man ) then {
hint "You must dissembark before you can perform this action.";
} else {

vehCamo = objNull;

_man playMove "AinvPknlMstpSlayWrflDnon_medic";
sleep 5;

vehCamo = "Land_CamoNetB_EAST_EP1" createVehicle [0,0,0];

vehCamo setDir ((direction _veh) +0);
vehCamo setPos (_veh modelToWorld [0,0,((position _veh) select 2)-2.4]);

camoDeployed = true;
publicVariable "camoDeployed";

camoStowed = false;
publicVariable "camoStowed";

vehCamo setVehicleInit "this setVehicleVarName 'vehCamo'";
processInitCommands;

if (true) exitWith {}; 

};

camo_stow.sqf;

_veh = _this select 0;
_man = _this select 1;

if ( vehicle _man != _man ) then {
hint "You must dissembark before you can perform this action.";
} else {

vehCamo setDamage 1;

_man playMove "AinvPknlMstpSlayWrflDnon_medic";
sleep 5;

deleteVehicle vehCamo;

camoDeployed = false;
publicVariable "camoDeployed";

camoStowed = true;
publicVariable "camoStowed";

if (true) exitWith {};

};

Honestly, I am not really sure what the hell I am scripting, like with variables and stuff. I managed to get it to work offline, so Yay sui!!!, but I'm still very much a newb at this stuff. I tried using "if (isServer) then {" but I'm not sure I implemented it correctly, so I took it out when I still couldn't get it to work online, but I figured it needs to be in there someplace. Anyway, I'm sure I am going about this completely wrong, so if anybody could please help me with this, it would be greatly appreciated. I'm sure others might want to use it as well. Here's my Takistan demo mission if you want to try it, but it won't work online.

vehCamo.Takistan.zip

Edited by A-SUICIDAL

Share this post


Link to post
Share on other sites

Hi there,

i fixed it for you... (haven't tested obviously) but it should work in mp like that. I also reduced it to just one file and you can now use it for more than just one vehicle.

Vehicle init line:

this setVariable ["CamoDeployed", false, true];
this addAction ["Deploy", "camo.sqf", ["Deploy"], 51, false, true, "", "!(_target getVariable 'CamoDeployed')"];
this addAction ["Stow", "camo.sqf", ["Stow"], 50, false, true, "", "(_target getVariable 'CamoDeployed')"];

camo.sqf:

// No dedicated
if (isDedicated) exitWith {};

_veh = _this select 0;
_man = _this select 1;

// What to execute
_option = (_this select 3) select 0;

// Exec only at caller
if (_man != player) exitWith {};

// Deploy
if (_option == "Deploy") exitWith {

// Exit if in vehicle
if (vehicle _man != player) then {
	hint "You must dissembark before you can perform this action.";
} else {

	_man playMove "AinvPknlMstpSlayWrflDnon_medic";
	sleep 5;

	vehCamo = "Land_CamoNetB_EAST_EP1" createVehicle [0,0,0];

	vehCamo setDir ((direction _veh) +0);
	vehCamo setPos (_veh modelToWorld [0,0,((position _veh) select 2)-2.4]);

	// Set variable for vehicle
	_veh setVariable ["CamoDeployed", true, true];
};
};

// Stow
if (_option == "Stow") exitWith {

// Exit if in vehicle
if (vehicle _man != player) then {
	hint "You must dissembark before you can perform this action.";
} else {
	vehCamo setDamage 1;

	_man playMove "AinvPknlMstpSlayWrflDnon_medic";
	sleep 5;

	deleteVehicle vehCamo;

	// Set variable for vehicle
	_veh setVariable ["CamoDeployed", false, true];
};
};

I also added some comments, as you can see.

getVariable and setVariable are a good way to broadcast such things over the network.

:thumb_down:

Edit:

BTW

The "you have to disembark..." is not really needed, as you can set as a condition that the action is only visible as long as you are not in the vehicle...

Like this:

this addAction ["Deploy", "camo.sqf", ["Deploy"], 51, false, true, "", "!(_target getVariable 'CamoDeployed') && !(_this in _target)"];
this addAction ["Stow", "camo.sqf", ["Stow"], 50, false, true, "", "(_target getVariable 'CamoDeployed') && !(_this in _target)"];

And, yeah, its a cool feature. :thumbsup:

Edited by sxp2high

Share this post


Link to post
Share on other sites

Really awesome man. I feel like it's my birthday. The comments, the colors, and it tested perfectly. And I learned a few things that I can definitely put to use in other scripts. I asked for a little help and wow. Just wow.

Thanks man. Really. Thank you so much.

Share this post


Link to post
Share on other sites
Thanks man. Really. Thank you so much.

You're welcome. :)

Now back to BTK Cargo 2.0! :)

Ha. Yes, sir!

Putted that aside for a while. But will try to finish it soon. :)

Edit:

One more thing... for proper multi-vehicle support, please change the stow part to this:

// Stow
if (_option == "Stow") exitWith {

   // Exit if in vehicle
   if (vehicle _man != player) then {
       hint "You must dissembark before you can perform this action.";
   } else {

	_Net = nearestObject [_veh, "Land_CamoNetB_EAST_EP1"];
	if (_Net distance _veh > 5) exitWith {};

       _Net setDamage 1;

       _man playMove "AinvPknlMstpSlayWrflDnon_medic";
       sleep 5;

       deleteVehicle _Net;

       // Set variable for vehicle
       _veh setVariable ["CamoDeployed", false, true];
   };
};

Should be working better if you deployed more than one net.

Edited by sxp2high

Share this post


Link to post
Share on other sites

I added what you said and it took away the ability to stow the camo if I drive more >5 meters away.

So, since in the small coop mission I am working on right now only has 1 transport vehicle/truck that I want to add a deploy camo option to - I decided to add a trigger... specific for the vehicle, in this case my vehicle is a called "truck1".

condition:

(!alive vehCamo) OR (!alive truck1) OR (truck1 distance vehCamo >12)

activation:

null = [] execVM "delete_camo.sqf";

and in the delete_camo.sqf:

vehCamo setDamage 1;
sleep 3;
deleteVehicle vehCamo;
truck1 setVehicleInit "this setVariable ['CamoDeployed', false, true];";
processInitCommands;

If camo is damaged/collapsed - it deletes the camo and give the vehicle the option to deploy again.

If vehicle is destroyed - it deletes the camo and give the vehicle option to deploy again - which doesn't matter since the vehicle deletes and respawns anyway - and then adds back the camo action.

But basically what the triggers main purpose is... if you drive away from the tent and get more that 12 meters away from it, it collapses the tent and then deletes it and gives the vehicle back the option to deploy it again. Kind of like - as if there is a string tied from the net to the truck and driving away yanks the tent to the ground, lol. I know, it seems weird, but it it seems even more weird to me for the vehicle to have an option to stow a camo net that is miles away from the vehicle - and then after stowing it - having to go back into another animation just to get it deployed again. I am assuming that if I wanted to use more than 1 vehicle that has camo abilities and want to use this string yank approach - that I would then need to create camo.sqf files specific to each vehicle that I want to have a camo option. Like camo1.sqf for truck1 and camo2.sqf for truck2. Unless there is a way to implement my trigger system into the script and have it work for all vehicle using just 1 camo.sqf file. I don't mind creating multiple camo script files for each vehicle that I want to have a camo abilities.

Share this post


Link to post
Share on other sites

I always think about the future when i create such stuff. So i make it as flexible as possible, no dependecy to unique vehicle names and such, so i can easily add it to future missions.

There you go with "string" :D Just a few lines more.

// No dedicated
if (isDedicated) exitWith {};

_veh = _this select 0;
_man = _this select 1;

// What to execute
_option = (_this select 3) select 0;

// Exec only at caller
if (_man != player) exitWith {};

// Deploy
if (_option == "Deploy") exitWith {

   // Exit if in vehicle
   if (vehicle _man != player) then {
       hint "You must dissembark before you can perform this action.";
   } else {

       _man playMove "AinvPknlMstpSlayWrflDnon_medic";
       sleep 5;

       _Net = "Land_CamoNetB_EAST_EP1" createVehicle [0,0,0];

       _Net setDir ((direction _veh) +0);
       _Net setPos (_veh modelToWorld [0,0,((position _veh) select 2)-2.4]);

       // Set variable for vehicle
       _veh setVariable ["CamoDeployed", true, true];

	// String ;)
	sleep 1;
	waitUntil {!(_veh getVariable "CamoDeployed") || (_veh distance _Net > 12) || !(alive _veh) || !(alive _Net)};

	// If stowed, no clean up needed, exit
	if (!(_veh getVariable "CamoDeployed")) exitWith {};

	_veh setVariable ["CamoDeployed", false, true];

	_Net setDamage 1;
	sleep 3;
	deleteVehicle _Net;
   };
};

// Stow
if (_option == "Stow") exitWith {

   // Exit if in vehicle
   if (vehicle _man != player) then {
       hint "You must dissembark before you can perform this action.";
   } else {

	// Remove nearest tent
       _Net = nearestObject [_veh, "Land_CamoNetB_EAST_EP1"];

       _Net setDamage 1;

       _man playMove "AinvPknlMstpSlayWrflDnon_medic";
       sleep 5;

       deleteVehicle _Net;

       // Set variable for vehicle
       _veh setVariable ["CamoDeployed", false, true];
   };
};

Share this post


Link to post
Share on other sites

Works great. I deleted my "string" trigger, heh.

If applied to chopper, it should probably only be available if engine is off. So I through in an "engine off" check...

chopper_camo.sqf:

// No dedicated
if (isDedicated) exitWith {};

_veh = _this select 0;
_man = _this select 1;

// What to execute
_option = (_this select 3) select 0;

// Exec only at caller
if (_man != player) exitWith {};

// Deploy
if (_option == "Deploy") exitWith {

   // Exit if in vehicle
   if (vehicle _man != player) then {
       hint "You must dissembark before you can perform this action.";
   } else {
   if (isEngineOn _veh) then {
       hint "You must turn engine off before you can perform this action.";
   } else {

       _man playMove "AinvPknlMstpSlayWrflDnon_medic";
       sleep 5;

       _Net = "Land_CamoNetB_EAST_EP1" createVehicle [0,0,0];

       _Net setDir ((direction _veh) +0);
       _Net setPos (_veh modelToWorld [0,0,((position _veh) select 2)-2.4]);

       // Set variable for vehicle
       _veh setVariable ["CamoDeployed", true, true];

       // String ;)
       sleep 1;
       waitUntil {!(_veh getVariable "CamoDeployed") || (_veh distance _Net > 12) || !(alive _veh) || !(alive _Net)};

       // If stowed, no clean up needed, exit
       if (!(_veh getVariable "CamoDeployed")) exitWith {};

       _veh setVariable ["CamoDeployed", false, true];

       _Net setDamage 1;
       sleep 3;
       deleteVehicle _Net;
   };
};
};

// Stow
if (_option == "Stow") exitWith {

   // Exit if in vehicle
   if (vehicle _man != player) then {
       hint "You must dissembark before you can perform this action.";
   } else {

       // Remove nearest tent
       _Net = nearestObject [_veh, "Land_CamoNetB_EAST_EP1"];

       _Net setDamage 1;

       _man playMove "AinvPknlMstpSlayWrflDnon_medic";
       sleep 5;

       deleteVehicle _Net;

       // Set variable for vehicle
       _veh setVariable ["CamoDeployed", false, true];
   };
}; 

But it wouldn't make sense if a player were to take off and fly away while the camo is still covering the chopper, so maybe lock the chopper until the camo is either stowed or destroyed? Maybe I'm getting in over my head here. But I was thinking if engine on, maybe kill the engine and hint that player must stow the camo before being allowed to turn engine on.

Share this post


Link to post
Share on other sites

I was thinking lock too, but some players might think it's permanently locked and not know that they need to stow before they can get in. So I figured.. let them in, but kill their engine and give them a hint that they need to stow before starting their engine. Is it possible to stop an engine that they try to start? In domi I think they remove the fuel until the mhq camo is stowed, but I thought the kill engine with a hint might make more sense if possible.

Share this post


Link to post
Share on other sites

Yeah but at some point you would think common sense would kick in. Do I turn the helicopter on while it is under a cargo net or do I stow it away first?

Or like you said take the fuel away until it is stowed away.

Share this post


Link to post
Share on other sites

Hmm, I tried, I couldn't get the engineOff action to work. Locking the vehicle when deploying with a simple "Vehicle locked while camo is deployed" hint should work fine. But what about players that are still in cargo? Eject them? lol. Or what about an MHQ type of vehicle that players can teleport into the cargo of from base, well, they shouldn't be able to switch to driver seat anyway, so that should'nt be a problem.

---------- Post added at 10:35 PM ---------- Previous post was at 10:31 PM ----------

Yeah, forget the hint, your right, the common sense should kick in, or pff for them, right. If they don't have enough common sense, then maybe they need to stop smoking so much pot, lol.

---------- Post added at 10:53 PM ---------- Previous post was at 10:35 PM ----------

I told AI to get in as pilot, then I deployed the camo, then I switched to the AI and I could not get out, but I could fly away - and once I was more than 12 meters away it collapsed and deleted the camo. So how do I eject the players inside when deploying the camo?

---------- Post added at 11:30 PM ---------- Previous post was at 10:53 PM ----------

I'm starting to understand why they take the fuel away in domi.

---------- Post added at 11:50 PM ---------- Previous post was at 11:30 PM ----------

So this is what I added to it so I could use it for both the air and land vehicles:

vehicle init:

this setVariable ["CamoDeployed", false, true];
this addAction ["Deploy Camo Cover", "mhq\camo_chopper.sqf", ["Deploy"], 51, false, true, "", "!(_target getVariable 'CamoDeployed')"];
this addAction ["Stow Camo Cover", "mhq\camo_chopper.sqf", ["Stow"], 50, false, true, "", "(_target getVariable 'CamoDeployed')"];

camo.sqf:

// No dedicated
if (isDedicated) exitWith {};

_veh = _this select 0;
_man = _this select 1;

// What to execute
_option = (_this select 3) select 0;

// Exec only at caller
//if (_man != player) exitWith {};

// Deploy
if (_option == "Deploy") exitWith {

   // Exit if in vehicle
   if (vehicle _man != player) then {
       hint "You must dissembark before you can perform this action.";
   } else {
   if (isEngineOn _veh) then {
       hint "You must turn engine off before you can perform this action.";
   } else {
   	_veh setFuel 0;
       _man playMove "AinvPknlMstpSlayWrflDnon_medic";
       sleep 5;

       _Net = "Land_CamoNetB_EAST_EP1" createVehicle [0,0,0];

       _Net setDir ((direction _veh) +0);
       _Net setPos (_veh modelToWorld [0,0,((position _veh) select 2)-2.4]);

       // Set variable for vehicle
       _veh setVariable ["CamoDeployed", true, true];

       // String ;)
       sleep 1;
       waitUntil {!(_veh getVariable "CamoDeployed") || !(alive _veh) || !(alive _Net)};

       // If stowed, no clean up needed, exit
       if (!(_veh getVariable "CamoDeployed")) exitWith {};

       _veh setVariable ["CamoDeployed", false, true];

   	_veh setFuel 1;
       _Net setDamage 1;
       sleep 3;
       deleteVehicle _Net;
       if (!(_veh getVariable "CamoDeployed")) exitWith {};

       _veh setVariable ["CamoDeployed", false, true];

       _Net setDamage 1;
       sleep 3;
       deleteVehicle _Net;
   };
};
};


// Stow
if (_option == "Stow") exitWith {

   // Exit if in vehicle
   if (vehicle _man != player) then {
       hint "You must dissembark before you can perform this action.";
   } else {
   	_veh setFuel 1;
       // Remove nearest tent
       _Net = nearestObject [_veh, "Land_CamoNetB_EAST_EP1"];

       _Net setDamage 1;

       _man playMove "AinvPknlMstpSlayWrflDnon_medic";
       sleep 5;

       deleteVehicle _Net;

       // Set variable for vehicle
       _veh setVariable ["CamoDeployed", false, true];
   };
};

---------- Post added at 12:16 AM ---------- Previous post was Yesterday at 11:50 PM ----------

oops, forgot to add back fuel if camo is destroyed. edit - updated script

Share this post


Link to post
Share on other sites

I deploy the camo, then a player JIPs and gets the deploy action instead of stow. Anyway to fix that?

Share this post


Link to post
Share on other sites

I guess it can't be fixed. Shame. I have a Stryker M2 as an MHQ. Players can teleport into the cargo of it from base at any time. It can deploy a camo net cover as discussed in this thread - and it can deploy a mash tent and weapons crate. The only problem is when everything is deployed - a players then JIPs and the "Stow" options turn back to "Deploy". Since deploying the camo net removes the fuel from the vehicle, I then have to choose deploy again, then stow just to get the fuel back into the vehicle.

Is there any possible way to make it so when I deploy the camo net - that players that then join will see it as deployed and also see the action to stow it?

I host from my pc non-dedicated mostly.

I also have a rally point that the leader can deploy every ten minutes, and players that join late in the mission and choose to teleport to the rally point(getMarkerPos) - wind up in the far south-west corner of the map, so I had to put a teleport flag there just so they wouldn't get stranded. Again, same problem as above. players JIP and they are not updated as to the current marker position of the rally point and they are not updated with the MHQ's current deployed objects. Everything else is working, the markers, tasks, triggers etc. It's just my MHQ and rally point.

Share this post


Link to post
Share on other sites

I was sure getVariable would work for JIP´s, anywho.. other possible ways might be:

Edit: unless the vehicle init, will mess it up giving it its original setVar on JIP.

try setting the variable in a script only if variable is not there instead.

regarding JIP, instead of using getVariable in the conditions of the actions, try using a global variable instead and publicVariable it, pubVar is transferred to JIP´s automatically.

place in init of the mhq:

A_S_Mhq1_deployed = false;
publicVariable "A_S_Mhq1_deployed";
this addAction ["Deploy Camo Cover", "mhq\camo_chopper.sqf", ["Deploy"], 51, false, true, "", "!A_S_Mhq1_deployed"];
this addAction ["Stow Camo Cover", "mhq\camo_chopper.sqf", ["Stow"], 50, false, true, "", "A_S_Mhq1_deployed"];

not really sure if publicVariable is really needed in the init of the vehicle above.

then in the addaction scripts add this instead of setVariable:

if (A_S_Mhq1_deployed) then {A_S_Mhq1_deployed = false} else {A_S_Mhq1_deployed = true};
publicVariable "A_S_Mhq1_deployed";

for the JIP markers part, one way of doing it possibly:

again use a global variable with pubvar.

dont place marker in editor, we spawn it instead via init,sqf

place in init.sqf: marker is named "A_S_rally1"

if (isNil ("A_S_rally1")) then {
_marker = createMarker["A_S_rally1",[0,0,0]];
_marker setMarkerShape "ICON";
_marker setMarkerType "DOT";
A_S_rally1 = [_marker,[0,0,0],"ICON","DOT"];
publicVariable "A_S_rally1";
} else {
_marker = createMarker[(A_S_rally1 select 0),(A_S_rally1 select 1)];
_marker setMarkerShape (A_S_rally1 select 2);
_marker setMarkerType (A_S_rally1 select 3);
};

in the rally point script whenever the marker is moved add this after the move:

A_S_rally1 set [1, (getMarkerPos _marker)];
publicVariable "A_S_rally1";

Im am sure there is another way, like using MP framework or something, this above is just untested, speculations by me..

Edited by Demonized
removed error line

Share this post


Link to post
Share on other sites

Took a little while, but I finally got the camo changes made the way you suggested, but I haven't been able to test with anybody yet.

I made the rally point changes too, but I'm not sure if I did that correctly. My rally point marker was called rallyM. The actual rally point is a small desert bunker(named nest) and weapon crate and it can also deploy a camo cover if needed :) When the team leader deploys the rally point, the script first deletes the old rally point objects and the rally point marker and then creates a new rally point and marker. My preferred choice would be to not have the rally point in the mission at all at mission start and if any players attempt to teleport to it - they would receive a hint message telling them that the rally point has not yet been deployed - but I couldn't figure out how to do that. I tried... if (!alive nest) then {hint.... - but that didn't work and players got teleported into the far southwest corner of the map :( help with that would be great.

I feel stupid asking this, but is A_S_ just part of the name or does it have some kind of purpose? Like... can I simply change A_S_rally1 to be called rallyM and the script would work the same? It doesn't matter to me what it's called, I was just curious about the A_S_

Also, looking at your script, I didn't notice where the marker actually gets created.

My marker gets created like this...

rallyMarker = createMarker ["rallyM", position teleportTo_object];
"rallyM" setMarkerShape "ICON";
"rallyM" setMarkerType "mil_dot";
"rallyM" setMarkerSize [1.0, 1.0];
"rallyM" setMarkerColor "ColorGreen";
"rallyM" setMarkerText "Rally Point";
"rallyM" setMarkerDir ((direction teleportTo_object) +90);
rallyDeployed = true; publicVariable "rallyDeployed";

teleportTo_object is a small ammo crate that gets created 2 meters under the ground in the center of the gun nest. The rallyM marker is set in the direction of the ammo crate +90 degrees so players teleport facing the the correct direction. I added your script to my init.sqf, but I wasn't sure how to implement...

A_S_rally1 set [1, (getMarkerPos _marker)];
publicVariable "A_S_rally1";

... into my deployRally.sqf

Share this post


Link to post
Share on other sites

Don't initialize variables in init.sqf on all clients. Instead, initialize and publicVariable them only on the server, then on clients add a waitUntil condition that waits for the variables to be defined. That way JIP clients won't initialize them to an incorrect value and nobody will try to use the variables before they have been given a value.

Share this post


Link to post
Share on other sites

I created a 2 player sample mission that uses my exact rally point script. Basically I deleted everything from my real mission and left just the rally point stuff behind so you can see exactly how I have it setup. It's actually a pretty cool rally point. There is a base teleport flag to test teleporting to the rally point and I enabled AI in the description.ext. I made the changes regarding the camo net cover, but I did not add the changes for the rally point marker. I also do not have a hint message for players that try to teleport to the rally point before it has be deployed - which I can't seem to get to work.

rallyPoint.Takistan.zip

What you said makes sense galzohar, I just don't know how to do it :(

Like the waitUntil part, I don't know where to add that. Once I learn how to do that, I can apply it to many other scripts where I run into the same problem.

Share this post


Link to post
Share on other sites

Add the waitUntil part just before the part that uses the variables.

waitUntil {!isNil "varName1"};
[code]
or
[code]
waitUntil {_blah = _unit getVariable "varName"; !isNil "_blah"};
[code]
Depending on which method you used.

To initialize the variables in init.sqf:
[code]
if (isServer) then
{
var1=false;
publicVariable "var1";
var2=true;
publicVariable "var2";
};

Or

if (isServer) then
{
_unit setVariable [varName1, true, true];
_unit setVariable [varName2, false, true];
};

Again depending on which method you chose to use. Notice the 3rd parameter of the setVariable command basically tells it to publicVariable it after setting it.

Basically you need to make sure the variables are set for all clients but only the server initializes their value and then broadcasts that value to all clients (JIP-included, they will automatically get the last value that was publicVariabled before they connected for all variables that were ever publicVariabled).

Edited by galzohar

Share this post


Link to post
Share on other sites

I really don't think I did this correctly at all.

init.sqf:

I added this to the bottom of my init.sqf file. I'm not sure if it needs to be near the top.

if (isServer) then
{
camoDeployed=false;
publicVariable "camoDeployed";
camoDeployed=true;
publicVariable "camoDeployed";
rallyDeployed=false;
publicVariable "rallyDeployed";
rallyDeployed=true;
publicVariable "rallyDeployed";
};

rallyTimer=0;

s1_deploy_rally.sqf:

/*

DEPLOY RALLY POINT (PLAYER/US TEAM LEADER - S1)

A-SUICIDAL, AUG 2011

************************************************************************************************************************************

*/

_manS1 = _this select 0;

_actS1 = _this select 2;

if (alive s1 and rallyTimer>0) then {

hint "10 minutes has not yet passed.";

sleep 6;

hint "";

} else {

rallyTimer=1;

_manS1 switchMove "AinvPknlMstpSlayWrflDnon_medic";

sleep 3;

_manS1 switchMove "amovpknlmstpsraswrfldnon_gear";

deleteVehicle nest;

deleteVehicle crate;

deleteVehicle teleportTo_object;

deleteVehicle rallyFlag;

deleteVehicle rallySphere;

deleteMarker "rallyM";

rallyDeployed = false; publicVariable "rallyDeployed";

waitUntil {!isNil "rallyDeployed"};

nest = "Land_fortified_nest_small_EP1" createVehicle [0,0,0];

nest setDir ((direction _manS1) -180);

nest setPos (_manS1 modelToWorld [0.5,1.4,((position _manS1) select 2)]);

crate = "USBasicAmmunitionBox_EP1" createVehicle [0,0,0];

crate setDir ((direction _manS1) -90);

crate setPos (_manS1 modelToWorld [1.18,1.85,((position _manS1) select 2)-0.12]);

teleportTo_object = "USBasicAmmunitionBox_EP1" createVehicle [0,0,0];

teleportTo_object setDir ((direction _manS1) -90);

teleportTo_object setPos (_manS1 modelToWorld [-0.2,+0.6,((position _manS1) select 2)-2]);

rallyFlag = "FlagPole_EP1" createVehicle [0,0,0];

rallyflag setFlagTexture "pictures\yellowFlag.paa";

rallyFlag setDir ((direction _manS1) -90);

rallyFlag setPos (_manS1 modelToWorld [-3,-3,((position _manS1) select 2)]);

rallySphere = "Sign_sphere25cm_EP1" createVehicle [0,0,0];

rallySphere setPos (_manS1 modelToWorld [-3,-3,((position _manS1) select 2)]);

nest setpos [(getpos nest) select 0, (getpos nest) select 1, -0.1];

crate setpos [(getpos crate) select 0, (getpos crate) select 1, -0.1];

teleportTo_object setpos [(getpos teleportTo_object) select 0, (getpos teleportTo_object) select 1, -2];

rallyFlag setpos [(getpos rallyFlag) select 0, (getpos rallyFlag) select 1, -0.1];

rallySphere setpos [(getPos rallySphere) select 0, (getPos rallySphere) select 1, +0.04];

nest setVehicleInit "this allowDamage false; camoDeployed = false; publicVariable 'camoDeployed'; this addAction ['Deploy Camo Cover', 'rally\camo.sqf', ['Deploy'], 51, false, true, '', '!(camoDeployed)']; this addAction ['Stow Camo Cover', 'rally\camo.sqf', ['Stow'], 50, false, true, '', '(camoDeployed)'];waitUntil {!isNil 'camoDeployed'};";

crate setVehicleInit "this allowDamage false; null = this execVM 'scripts\ammo.sqf'; this allowDamage false; null = this execVM 'scripts\ammo.sqf'; crate addAction ['Save Loadout','scripts\saveloadout.sqf',nil,+10,true,true,'','player distance crate<5.5']";

teleportTo_object setVehicleInit "this allowDamage false";

rallyFlag setVehicleInit "this allowDamage false; this addaction ['Teleport to Base', 'teleport\teleport_base.sqf'];";

rallySphere setVehicleInit "this allowDamage false";

processInitCommands;

rallyMarker = createMarker ["rallym", position teleportTo_object];

"rallym" setMarkerShape "ICON";

"rallym" setMarkerType "mil_dot";

"rallym" setMarkerSize [1.0, 1.0];

"rallym" setMarkerColor "ColorGreen";

"rallym" setMarkerText "Rally Point";

"rallym" setMarkerDir ((direction teleportTo_object) +90);

rallyDeployed = true; publicVariable "rallyDeployed";

waitUntil {!isNil "rallyDeployed"};

waitUntil{!(isNil "BIS_MPF_InitDone")};

[s1,nil,rGLOBALCHAT,"Rally Point deployed and marked on map."] call RE;

sleep 6;

hint "You cannot deploy a new Rally Point until 10 minutes has passed.";

sleep 6;

hint "";

sleep 588;

rallyTimer=0;

waitUntil {alive s1};

hint composeText [parsetext format["<t size=1' align='center' color='#00FF00'>Rally Point deploy available.%1</t&gt]];

};

Edited by A-SUICIDAL

Share this post


Link to post
Share on other sites

This isn't working either

teleport_rally.sqf:

_telguy = _this select 1;


if (!( rallyDeployed )) then {
   hint "The Rally Point is currently not deployed.";
} else {
_telguy setPos [(getMarkerPos "rallyM" select 0)+0,(getMarkerPos "rallyM" select 1)+0,(getMarkerPos "rallyM" select 2)+0];
_telguy setDir markerDir "rallyM";
playSound "teleport";
};

Edited by A-SUICIDAL

Share this post


Link to post
Share on other sites

Look at your first red line. It sets the variable back to false... Delete that line!

Basically if you want to be 100% sure, add to the start of any stow-related code:

waitUntil {!isNil "camoDeployed"};
waitUntil {!isNil "rallyDeployed"};

Of course, this is only truly needed if the variables might not be defined when the script starts. If the script is called via action and those variables are in the action's condition then you know they are already defined when the script starts and thus those waitUntils would be redundant.

Also, your server initializes the variables to false and then to true... Instead just initialize to false only since I assume the rally is not deployed before someone deploys it?

// anywhere in init.sqf
if (isServer) then
{
camoDeployed=false;
publicVariable "camoDeployed";
rallyDeployed=false;
publicVariable "rallyDeployed";
};

Whatever worked for you in single player and/or multiplayer with no JIP, take that code and make sure every time you set one of those 2 variables you also publicVariable it. So if original code set camoDeployed=true; it should also immediately after do publicVaraible "camoDeployed"

Share this post


Link to post
Share on other sites

Ok, thank you. It's starting to make more sense now.

I have a few vehicles that have the ability to deploy camo. Should they each have their own variable name? For instance, if jeep1, jeep2 and jeep3 can all deploy camo, should they share the same variable "camoDeployed" or should they instead have unique names, like... "j1camoDeployed", "j2camoDeployed" and "j3camoDeployed"?

and lastly, my teleport to rally point flagpole action currently looks like this...

_telguy = _this select 1;

if (isNull nest) then {
hint "The Rally Point has not yet been deployed by the Leader.";
} else {

_telguy setPos [(getMarkerPos "rallyM" select 0)+0,(getMarkerPos "rallyM" select 1)+0,(getMarkerPos "rallyM" select 2)+0];
_telguy setDir markerDir "rallyM";
playSound "teleport";
};

"nest" is the name of the small bunker/gun nest that gets deployed. When I tested the script, it doesn't do anything. It's supposed to give me a hint if the Rally Point hasn't yet been deployed. I tried changing the "if" part to:

if (!(getVariable "ralleyDeployed)) then {
hint "The Rally Point has not yet been deployed by the Leader.";

...but it still wouldn't work. What am I doing wrong?

Share this post


Link to post
Share on other sites

For multiple vehicles obviously you need multiple variables. They can be stored "inside" each vehicle with setVariable (recommended), in which case they can have the same name, or alternatively simply have global variables of different names not attached to any vehicle.

isNull nest will only return true if nest equals a non-existing object (aka objNull). If it is simply undefined your entire if condition will do absolutely nothing without any error message (neither the if nor the else blocks will get executed).

isNull is good for objects that got deleted. isNil is for variables that have not yet been defined at all. If both options are possible you must check both (first check isNil, then if it's defined check if it's null with isNull, then if it's both not nil and not null it is defined and can be used).

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  

×