Jump to content
Nope.X

[SOLVED] Script to finish a mission when vehicles are loaded

Recommended Posts

Can be any launcher @pierremgi. Could you send me a version where the task finishes upon a player picking up a launcher with 2 players so it doesn't matter which player picks up which launcher?

Edit: Can I have explosions happen upon a trigger activation?

 

Share this post


Link to post
Share on other sites
//init.sqf
if (isServer) then {
	launcher_taken = false;
	publicVariable "launcher_taken";
	private _taskname = "pickup launcher";
	private _tittlesarray = [
		"You need launcher to accomplish next quest",
		"Take launcher",
		_taskname
	];
	private _task = [
				
		WEST,
		_taskname,
		_tittlesarray,
		getpos box,
		"CREATED",
		0,
		true
	] call BIS_fnc_taskCreate;

	0 = [_taskname,  "ASSIGNED", true] spawn BIS_fnc_taskSetState;
	
	0 = [_taskname] spawn {
		
		params [["_taskname","",[""]]];
	
		waitUntil {sleep 3; launcher_taken || !alive box};
		if (launcher_taken) then {
			0 = [_taskname,  "SUCCEEDED", true] spawn BIS_fnc_taskSetState;
		} else {
			0 = [_taskname,  "FAILED", true] spawn BIS_fnc_taskSetState;
		};
	
	};
};

//initPlayerLocal.sqf
player addEventHandler ["Take", {
	params ["_unit", "_container", "_item"];

	if !((secondaryWeapon _unit) isEqualTo "") exitWith {
		launcher_taken = true;
		publicVariable "launcher_taken";
	};
}];

you need to add variable for your box with launcher in editor. Name will be box

  • Like 1

Share this post


Link to post
Share on other sites
Just now, Nope.X said:

Can be any launcher @pierremgi. Could you send me a version where the task finishes upon a player picking up a launcher with 2 players so it doesn't matter which player picks up which launcher?

Edit: Can I have explosions happen upon a trigger activation?

 

 

If you added a task in editor, you can add a task state module set to "succeeded", linked to this task and linked to a trigger in which you just have to replace  the condition  this  by:

{secondaryWeapon _x != ""} count allPlayers > 0

You can replace allplayers by [yourPlayer1,yourPlayer2] if you named them as is.

 

For explosion, you can do something like:

"HelicopterExploBig" createVehicle yourPosition  //(position you want, like getpos thisTrigger in a trigger)

 

I like this one for the debris but you can test:

"Bo_GBU12_LGB"

"M_PG_AT"
"M_AT"
"Sh_155mm_AMOS"
"Sh_82mm_AMOS"
"Cluster_155mm_AMOS"
"SatchelCharge_Remote_Ammo"
"DemoCharge_Remote_Ammo"
"R_TBG32V_F"

and probably more with mines.

 

 

  • Like 1

Share this post


Link to post
Share on other sites
Just now, pierremgi said:

 

If you added a task in editor, you can add a task state module set to "succeeded", linked to this task and linked to a trigger in which you just have to replace  the condition  this  by:

{secondaryWeapon _x != ""} count allPlayers > 0

You can replace allplayers by [yourPlayer1,yourPlayer2] if you named them as is.

 

For explosion, you can do something like:

"HelicopterExploBig" createVehicle yourPosition  //(position you want, like getpos thisTrigger in a trigger)

 

I like this one for the debris but you can test:

"Bo_GBU12_LGB"

"M_PG_AT"
"M_AT"
"Sh_155mm_AMOS"
"Sh_82mm_AMOS"
"Cluster_155mm_AMOS"
"SatchelCharge_Remote_Ammo"
"DemoCharge_Remote_Ammo"
"R_TBG32V_F"

and probably more with mines.

 

 

Okay I'll try that.

Share this post


Link to post
Share on other sites

@pierremgi The 2 code lines which you send earlier those:

currentweapon player == secondaryWeapon player  // player has selected a launcher

or

 secondaryWeapon player != " "  // player has a launcher

 

those both had the same error which said: Invalid number in expression. What I actually meant with my first question regarding that topic with the OR part I meant it like this for example:

  secondaryWeapon player != " "  // player has a launcher OR   secondaryWeapon player != " "  // player has a launcher

 

And where do I need to put the variable names?

Share this post


Link to post
Share on other sites

It seems you're in MP session (2 players at least), so I gave you the code with allplayers or the array of named players you want.

 

Invalid number in expression is a generic error, not related to an existing variable number in your script. In MP, player is not defined on dedicated server, and  locally not before player JIP.

If you don't want to bother you with the initialization order, you can check:  (!isNull player) && { condition with player here }  . The code inside {} is checked only if the previous cond. is true.

So : (!isNull player) && {currentweapon player == secondaryWeapon player}

I don't have any other clue.

 

Note: If you write secondaryWeapon player != " " , that will fail because " " (with space) is not an empty string. I did that for visibility but it's my bad. an empty string is "". Corrected.

 

 

  • Like 1

Share this post


Link to post
Share on other sites

Thank you again I'll go ahead and try those listed things.

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

×