Jump to content
Sign in to follow this  
J. Schmidt

Few Scripts with Problems

Recommended Posts

I've been working on a mission for awhile and have been unable to get some scripts working. My first script is getting the loading screen of my mission to randomize different pictures. My second script is getting an addAction command to appear on an object, that creates an HQ which hide the original object so it doesn't interfere with the new objects created. I will undoubtedly have more questions to come as I progress on this mission. Any help that is given is always appreciated, thanks!

Description.ext:

// Mission Header
class Header
{
 	gameType = Coop;
 	minPlayers = 1;
 	maxPlayers = 16;
};

onLoadMission = "A JSFC Team Development";
onLoadIntro = "A JSFC Team Development";
OnLoadMissionTime = 1;
OnLoadIntroTime = 1;

respawn= "Base";
respawndelay= 15;

disabledAi=1;
AiKills=1;
respawnDialog=true;

class CfgMusic
{
tracks[]={jsf_track01};

class jsf_track01
{
	name = "jsf_track01";
	sound[] = {\music\jsf_track01.ogg, db+8, 1.0};
};
};

loadScreen = __Rev(["pics\flags\jsf1.paa", "pics\flags\jsf2.paa", "pics\flags\jsf3.paa", "pics\flags\jsf4.paa"] select round random 4);

(I keep getting an error ""Picture __Rev(["pics\flags\jsf1.paa", "pics\flags\jsf2.paa", "pics\flags\jsf3.paa", "pics\flags\jsf4.paa"] select round random 4); not found"")

init_hq.sqf

private ["_caller"];
_caller = _this select 0;
_caller setVariable ["hq_busy", 0, true];

if (isnil ("deploy_hq")) then
{
player addAction ["Deploy HQ", "scr\veh_sys\action_array.sqf", "", 6, false, true];
deploy_hq = 1;
};

_caller addAction ["Undeploy HQ", "scr\veh_sys\undeploy_hq.sqf","", 6, false, true];

action_array.sqf

private ["_list","_action_list","_action_nr","_action","_temp"];
_list = position player nearObjects ["deploy_hq", 5];
_action_list = [];
_action_nr = _this select 2;

player removeAction _action_nr;
{
if (_x getVariable "hq_busy" == 0) then
{
	_action = player addAction ["Deploy HQ", "scr\veh_sys\deploy_hq.sqf", _x, 6, false, true];
	_temp = [_action];
	_action_list = _action_list + _temp;
}
}forEach _list;

sleep 10;

{
player removeAction _x; 
}forEach _action_list;

player addAction ["Undeploy HQ", "scr\veh_sys\action_array.sqf", "", 6, false, true];

deploy_hq.sqf

if (isServer) then
{
private ["_fnc_calc_pos_angle", "_obj", "_position", "_temp_pos", "_direction", "_est_calculator"];
private ["_hq", "_mhq", "_net", "_med", "_sndwll1", "_sndwll2", "_sndwll3", "_sndwll4", "_sndwll5", "_sndwll6", "_sndwll7", "_sndwll8", "_sndwll9", "_sndwll10"];	

_fnc_calc_pos_angle =
{
	private ["_obj","_direction","_position"];
	_obj = _this select 0;
	_direction = _this select 1;
	_position = _this select 2;

	[
		(_position select 0) + ((_obj select 0)*cos _direction) + ((_obj select 1)*sin _direction),
		(_position select 1) - ((_obj select 0)*sin _direction) + ((_obj select 1)*cos _direction)
	]
};

_mhq = _this select 0;
_hq = _this select 1;
_position = getPos _hq;
_direction = getDir _hq;

_mhq setVariable ["hq_busy", 1, true];
_mhq hideObject true;
_est_calculator = _mhq getVariable "HQ_est_calculator";
if (isNil "_est_calculator") then
{
	_mhq setVariable ["HQ_est_calculator", true, true];
};

_temp_pos = [[1, -2], _direction, _position] call _fnc_calc_pos_angle;
_net = format ["Land_CamoNetB_NATO_EP1%1"] createVehicle _temp_pos;
_net setVariable ["HQ_disabled", true, true];
_net setPos _temp_pos;
_net setDir (_direction +180);
sleep 0.2;

_temp_pos = [[0, -4.7], _direction, _position] call _fnc_calc_pos_angle;
_hq = format ["CampEast%1"] createVehicle (position _mhq);
_hq setVariable ["HQ_disabled", true, true];
_hq setPos _temp_pos;
_hq setDir (_direction +150);
sleep 0.2;

_temp_pos = [[5.8, -2], _direction, _position] call _fnc_calc_pos_angle;
_med = format ["MASH%1"] createVehicle _temp_pos;
_med setVariable ["HQ_disabled", true, true];
_med setPos _temp_pos;
_med setDir (_direction -40);
sleep 0.2;

_temp_pos = [[-7, -11.5], _direction, _position] call _fnc_calc_pos_angle;
_sndwll1 = format ["Land_HBarrier5%1"] createVehicle _temp_pos;
_sndwll1 setVariable ["HQ_disabled", true, true];
_sndwll1 setPos _temp_pos;
_sndwll1 setDir (_direction +240);
sleep 0.2;

_temp_pos = [[-4, -12], _direction, _position] call _fnc_calc_pos_angle;
_sndwll2 = format ["Land_HBarrier5%1"] createVehicle _temp_pos;
_sndwll2 setVariable ["HQ_disabled", true, true];
_sndwll2 setPos _temp_pos;
_sndwll2 setDir (_direction +150);
sleep 0.2;

_temp_pos = [[12.2, 0], _direction, _position] call _fnc_calc_pos_angle;
_sndwll3 = format ["Land_HBarrier5%1"] createVehicle _temp_pos;
_sndwll3 setVariable ["HQ_disabled", true, true];
_sndwll3 setPos _temp_pos;
_sndwll3 setDir (_direction +240);
sleep 0.2;

_temp_pos = [[11.5, -3], _direction, _position] call _fnc_calc_pos_angle;
_sndwll4 = format ["Land_HBarrier5%1"] createVehicle _temp_pos;
_sndwll4 setVariable ["HQ_disabled", true, true];
_sndwll4 setPos _temp_pos;
_sndwll4 setDir (_direction +150);
sleep 0.2;

_temp_pos = [[5, 12.5], _direction, _position] call _fnc_calc_pos_angle;
_sndwll5 = format ["Land_HBarrier5%1"] createVehicle _temp_pos;
_sndwll5 setVariable ["HQ_disabled", true, true];
_sndwll5 setPos _temp_pos;
_sndwll5 setDir (_direction +240);
sleep 0.2;

_temp_pos = [[2, 13.3], _direction, _position] call _fnc_calc_pos_angle;
_sndwll6 = format ["Land_HBarrier5%1"] createVehicle _temp_pos;
_sndwll6 setVariable ["HQ_disabled", true, true];
_sndwll6 setPos _temp_pos;
_sndwll6 setDir (_direction +150);
sleep 0.2;

_temp_pos = [[-14.5, 1], _direction, _position] call _fnc_calc_pos_angle;
_sndwll7 = format ["Land_HBarrier5%1"] createVehicle _temp_pos;
_sndwll7 setVariable ["HQ_disabled", true, true];
_sndwll7 setPos _temp_pos;
_sndwll7 setDir (_direction +240);
sleep 0.2;

_temp_pos = [[-14, 4], _direction, _position] call _fnc_calc_pos_angle;
_sndwll8 = format ["Land_HBarrier5%1"] createVehicle _temp_pos;
_sndwll8 setVariable ["HQ_disabled", true, true];
_sndwll8 setPos _temp_pos;
_sndwll8 setDir (_direction +150);
sleep 0.2;

_temp_pos = [[9.3, 5.8], _direction, _position] call _fnc_calc_pos_angle;
_sndwll9 = format ["Land_HBarrier3%1"] createVehicle _temp_pos;
_sndwll9 setVariable ["HQ_disabled", true, true];
_sndwll9 setPos _temp_pos;
_sndwll9 setDir (_direction +240);
sleep 0.2;

_temp_pos = [[-10, -6], _direction, _position] call _fnc_calc_pos_angle;
_sndwll10 = format ["Land_HBarrier3%1"] createVehicle _temp_pos;
_sndwll10 setVariable ["HQ_disabled", true, true];
_sndwll10 setPos _temp_pos;
_sndwll10 setDir (_direction +240);
sleep 0.2;

_hq setVariable ["HQ position objects created", [_hq, _net, _med, _sndwll1, _sndwll2, _sndwll3, _sndwll4, _sndwll5, _sndwll6, _sndwll7, _sndwll8, _sndwll9, _sndwll10]];
_hq setVariable ["HQ_disabled", true, true];
_hq setVariable ["hq_busy", 0, true];
};

undeploy_hq.sqf

private ["_hq", "_mhq", "_net", "_med", "_sndwll1", "_sndwll2", "_sndwll3", "_sndwll4", "_sndwll5", "_sndwll6", "_sndwll7", "_sndwll8", "_sndwll9", "_sndwll10"];
_hq hideObject true;
_net hideObject true;
_med hideObject true;
_sndwll1 hideObject true;
_sndwll2 hideObject true;
_sndwll3 hideObject true;
_sndwll4 hideObject true;
_sndwll5 hideObject true;
_sndwll6 hideObject true;
_sndwll7 hideObject true;
_sndwll8 hideObject true;
_sndwll9 hideObject true;
_sndwll10 hideObject true;

_mhq hideObject false;

Share this post


Link to post
Share on other sites

loadScreen = [b]__Rev[/b](["pics\flags\jsf1.paa", "pics\flags\jsf2.paa", "pics\flags\jsf3.paa", "pics\flags\jsf4.paa"] select round random 4);  

Whats _rev? and it has 2 __ before it. dont know if thats your problem.

Just a few things to help me understand this next part.

How is init_hq.sqf executed? and are any of these addactions working?

Share this post


Link to post
Share on other sites

I'd say it has to be more like this

loadscreen = ["pics\flags\jsf1.paa", "pics\flags\jsf2.paa", "pics\flags\jsf3.paa", "pics\flags\jsf4.paa"] select round random 4;

Share this post


Link to post
Share on other sites

@Lifted86 the init_hq.sqf is executed with putting this script within the supply container:

nul = [this] execVM "scr\veh_sys\init_hq.sqf;

@F2k Sel I just tried your suggestion and the error is still happening.

To explain my question for the loadingscreen when I opened up Hohei Evolution to figure out how the creator of Hohei Evolution was able to get the loadingscreen to randomize. So I opened the description.ext file and found this:

loadScreen = __EVAL(["\ca\ui\data\loadscreen_generic_co.paa","\ca\ui\data\loadscreen_test_a_co.paa","\ca\ui\data\loadscreen_test_b_co.paa","\ca\ui\data\loadscreen_test_c_co.paa","\ca\ui\data\loadscreen_test_e_co.paa","\ca\ui\data\loadscreen_test_f_co.paa","\ca\ui\data\loadscreen_test_g_co.paa","\ca\ui\data\loadscreen_test_h_co.paa","\ca\ui\data\loadscreen_test_i_co.paa","\ca\ui\data\loadscreen_test_j_co.paa"] select round random 9);

How come this is able to work, or better yet how can I implement this into my mission but with my own pictures?

I think my next step I'm going to try is to create a "ca" folder withing the mission, then create the other folders within that "ui", "data" and put my own pictures in it and see if it works. I also would like to figure out how to create the cargo system that is found in domination but this will be another time until these two scripts I'm having troubles with work.

Share this post


Link to post
Share on other sites

I see now __EVAL is a command so yours would be :-

loadScreen = __EVAL(["pics\flags\jsf1.paa", "pics\flags\jsf2.paa", "pics\flags\jsf3.paa", "pics\flags\jsf4.paa"] select round random 4);

It's working for me with different pics.

It's basically evaluating the code and the result is what loadscreen sees.

Share this post


Link to post
Share on other sites

ok, so im guessing you walk up to the crate and select deploy hq and the base builds?

i would try using Dynamic Object Compositions

and doing something like

init_hq.sqf

private ["_crate"]; 

_crate = _this select 0; 
_crate setVariable ["hq_deployed", false, true]; 


_crate addAction ["Deploy HQ", "CREATE CUSTOM COMPOSITIONS SCRIPT", "", 6, false, true,"","!(_this getVariable ""hq_deployed"")"];
_crate addAction ["Undeploy HQ", "DELETE CUSTOM COMPOSITIONS SCRIPT", "", 6, false, true,"","_this getVariable ""hq_deployed"""];
sleep 5;

and just change "hq_deployed" where ever in those scripts?

Edited by Lifted86
bad code

Share this post


Link to post
Share on other sites

@Lifted86 Great find, it would have saved me 3 hours in placing the objects for the HQ. Since I have that done my next task is like you said being able to walk up to the crate and select deploy hq. But when the HQ is constructed I added the command "hideObject" to hide the crate so when the HQ is create it doesn't intersect the HQ. So my question would be how could I transfer the "Undeploy HQ" action to one of the other objects that are spawned so I can undeploy the HQ, deleting all the HQ objects and spawns the crate again?

I just though of an idea should I get all the objects to spawn to the side of the crate so I don't have to delete the crate work better?

Share this post


Link to post
Share on other sites

Yeah, leaving the crate there would probably be easier, i cant think of an easy way to add an action to one of those spawned objects off the top of my head.

Maybe nearestObect "TYPE OF OBJECT YOU WANT TO ADDACTION TO" somewhere?

Share this post


Link to post
Share on other sites

@Lifted86 I've tried what you posted above and have had no luck in getting it to work let alone show up; this is quite puzzling. Anyhow I'll post the updated scripts for you and the community to look at and try to figure out, at the same time I'll keep working on it.

init_mhq.sqf

private ["_caller"];
_caller = _this select 0;
_caller setVariable ["hq_deployed", 0, true];

if (isnil ("hq_deployed")) then
{
_caller addAction ["Deploy HQ", "scr\action_array.sqf", "", 6, false, true, "", "!(_this getVariable 'hq_deployed')"];
hq_deployed = 1;
sleep 5;
} else {
_caller addAction ["Undeploy HQ", "scr\undeploy_mhq.sqf","", 6, false, true, "", "_this getVariable 'hq_deployed'"];
};

action_array.sqf

private ["_list","_action_list","_action_nr","_action","_temp"];
_list = position player nearObjects ["hq_deployed", 5];
_action_list = [];
_action_nr = _this select 2;

player removeAction _action_nr;
{
if (getVariable "hq_deployed" == 0) then
{
	_action = player addAction ["Deploy HQ", "scr\deploy_mhq.sqf", "", 6, false, true, "", "!(_this getVariable 'hq_deployed')"];
	_temp = [_action];
	_action_list = _action_list + _temp;
}
}forEach _list;

sleep 10;

{ 
}forEach _action_list;

player addAction ["Undeploy HQ", "scr\undeploy_mhq.sqf", "", 6, false, true, "", "_this getVariable 'hq_deployed'"];

deploy_mhq.sqf

["Land_Misc_Cargo1Eo_EP1",[0,0,0],150,1,0,{}],
["Land_HBarrier3",[-3.12109,-5.84326,0],240,1,0,{}],
["Land_HBarrier5",[-6.49805,0.610474,0],240,1,0,{}],
["Land_HBarrier5",[-12.499,2.20618,0],330,1,0,{}],
["Land_HBarrier5",[1.56152,-13.1835,0],240,1,0,{}],
["CampEast",[-11.1699,-4.69849,0],330,1,0,{}],
["ACRE_RadioBox",[-3.89551,-12.3849,0],330,1,0,{}],
["Land_HBarrier5",[-2.60352,-15.286,0],330,1,0,{}],
["ACE_USVehicleBox_EP1",[-5.80566,-13.5011,0],330,1,0,{}],
["Land_CamoNetB_NATO_EP1",[-12.7773,-9.48438,0],330,1,0,{}],
["Land_HBarrier3",[-18.2666,-1.20483,0],330,1,0,{}],
["MASH",[-17.6621,-9.63855,0],150,1,0,{}],
["Land_HBarrier3",[-9.42285,-18.9055,0],330,1,0,{}],
["Land_HBarrier5",[-26.0039,-5.53149,0],330,1,0,{}]

undeploy_mhq.sqf

private = ["_mhq"];
_mhq ["Land_HBarrier3", "Land_HBarrier5", "CampEast", "ACRE_RadioBox", "ACE_USVehicleBox_EP1", "Land_CamoNetB_NATO_EP1", "MASH"];

{deleteVehicle _x;}forEach _mhq;

Share this post


Link to post
Share on other sites

I'm not sure where to start. You're using both setVariable and global variables which is very confusing. And then you setVariable on the MHQ but in the addAction you're checking the player for the value of the variable.

_list = position player nearObjects ["hq_deployed", 5]; 

There are no objects called "hq_deployed". You could get all of the closest vehicles to the player and check them for the variable

{  
}forEach _action_list; 

?

private = ["_mhq"]; 
_mhq ["Land_HBarrier3", "Land_HBarrier5", "CampEast", "ACRE_RadioBox", "ACE_USVehicleBox_EP1", "Land_CamoNetB_NATO_EP1", "MASH"]; 

{deleteVehicle _x;}forEach _mhq;  

You can't delete classnames and the = sign is at the wrong place. You could place that array inside the nearObjects array as long as you know where the MHQ is. But the best thing would be to save the objects when you spawn them, so they can be deleted later on.

Have you tried searching around for MHQ scripts? I'm certain there's plenty

Edited by cuel

Share this post


Link to post
Share on other sites

@Cuel I think I'll re-create the scripts from scratch and and post an update on them once they're done.

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  

×