Jump to content
Samcot

[SOLVED] Help with Simple Conversation Script + Addaction

Recommended Posts

Hey guys.

 

So I need some help with the following.

 

  • I set up a task for my player to talk to an officer before heading off onto his next task. (I use an addaction command to talk to the officer (See below) which also sets my task state to succeeded.

 

Code below is put into the init of my officer unit.

inspector= this addAction ["Talk to the Officer", "[""task1"",""SUCCEEDED""] call BIS_fnc_taskSetState"];
  • I wanted to add a short conversation between the player and officer which initiates as soon as the above command is used. (Via addAction "Talk to the officer")
  • Here is the script which initiates the conversation. (Thanks to R3vo's Simple Conversation Script)
line1 = ["CDF Officer", "Welcome to Altis, Captain. We're glad your here.",officer1]; 
line2 = ["Michael", "Glad to be here. So what's the situation?",michael]; 
line3 = ["CDF Officer", "The reds have been hitting our supply lines from the east to try and cripple us.",officer1];
line4 = ["CDF Officer", "So far we're holding them off in the south but we're noticing their strength increase by the day.",officer1];
line5 = ["Michael", "Just keep doing what you're doing and hold firm Sir. Is my lift ready?",michael];
line6 = ["CDF Officer", "Your carriage awaits, Captain. Board the helicopter when you're ready.",officer1];
[[line1,line2,line3,line4,line5,line6],"CUSTOM",0.15,true] execVM "fn_simpleConv.sqf";
  • So the above script works perfectly when ran locally from the debug console.
  • How do I combine both scripts together so when I "Talk to the Officer" the conversation script is also played?

 

Thanks in advance.

Share this post


Link to post
Share on other sites

@Samcot,
If I understand correctly, try this,

inspector=this addAction ["Inspect", { 
  	["task1","SUCCEEDED"] call BIS_fnc_taskSetState; 
	[[line1,line2,line3,line4,line5,line6],"CUSTOM",0.15,true] execVM "fn_simpleConv.sqf";
 }];

Like @pierremgi said in the previous topic it's way cleaner to use parentheses.

Have fun!

  • Like 1

Share this post


Link to post
Share on other sites
1 hour ago, wogz187 said:

@Samcot,
If I understand correctly, try this,


inspector=this addAction ["Inspect", { 
  	["task1","SUCCEEDED"] call BIS_fnc_taskSetState; 
	[[line1,line2,line3,line4,line5,line6],"CUSTOM",0.15,true] execVM "fn_simpleConv.sqf";
 }];

Like @pierremgi said in the previous topic it's way cleaner to use parenthesis.

Have fun!

 

Thanks for the reply @wogz187

 

Because I'm fairly new to this scripting stuff I'm unsure what paranthesis is. I assume it's just using 1 set of " instead of multiple ones? (Sorry in advance for me being dumb lol)

 

The script you posted above works great but I'm having a weird issue which I think is due to my lack of scripting knowledge and I wondered if you may know what's going wrong? I'll reproduce my steps for you. 

 

  • Added your script to my officer unit's init. Hit play.
  • Spoke to the officer unit using the addAction and it triggered the taskSetState perfectly.
  • It then gave me This error and did not play my simpleConv script.
  • I spoke to the officer again (As I don't know how to remove addAction once activated for the 1st time)
  • Then my simpleConv script worked fine with no error message.

 

423ac7363f81d0a5649751423f395d9a.png

 

I think the error message has something to do with defining the unit so the built-in lip movement script can activate on the right guy?. In my fn_simpleConv.sqf script that @R3vo made he included an example. Located at the bottom of This image.

 

I was unsure where to post my line1,line2 etc so I just put them at the start. See Here (Located at bottom of image). In my lines I defined the unit which will say the message. "Michael and officer1" 

 

I hope I haven't super confused you and I've tried to include as much information as possible. 

 

Thanks in advance. 

 

Edit - This is the script I'm using. 

  • Like 1

Share this post


Link to post
Share on other sites

@Samcot,

Quote

(Sorry in advance for me being dumb lol)

Don't undermine yourself, man. You're doing fine. I super-appreciate you supply all the needful information.
 

Quote

 

I spoke to the officer again (As I don't know how to remove addAction once activated for the 1st time)

Then my simpleConv script worked fine with no error message.

 

removeAction

Without researching the script I can't say exactly what's happening beyond what you already deduced: the variables are undefined the first time the script runs. Your lines must work (it goes the second time). I'm sure anybody familiar with the script knows what's up. Check here,


Have fun!

  • Like 1

Share this post


Link to post
Share on other sites
3 minutes ago, wogz187 said:

@Samcot,

Don't undermine yourself, man. You're doing fine. I super-appreciate you supply all the needful information.

 parentheses= { }, commonly called "curly brackets"
 

removeAction

Without researching the script I can't say exactly what's happening beyond what you already deduced: the variables are undefined the first time the script runs. Your lines must work (it goes the second time). I'm sure anybody familiar with the script knows what's up. Check here,


Have fun!

 

Thanks for the info man! I checked the thread already and there's nothing about it. I made a post anyway. Hopefully it's an easy fix as I'd love to make progress on my mission :)

  • Like 1

Share this post


Link to post
Share on other sites
42 minutes ago, wogz187 said:

parentheses= { }, commonly called "curly brackets"

() - parentheses

{} - braces

[] <> - (Square, Angle(unless used in a conditional statement where they are smaller/greater than instead)) brackets

 

2 hours ago, Samcot said:

I was unsure where to post my line1,line2 etc so I just put them at the start.

Remove your lines from within the simple conversation script.

inspector = this addAction[ "Inspect", { 
	params[ "_target", "_caller", "_ID" ];
	
	[ "task1", "SUCCEEDED" ] call BIS_fnc_taskSetState;
	
	[[
		[ "CDF Officer", "Welcome to Altis, Captain. We're glad your here.", _target ], 
		[ "Michael", "Glad to be here. So what's the situation?", _caller ], 
		[ "CDF Officer", "The reds have been hitting our supply lines from the east to try and cripple us.", _target ], 
		[ "CDF Officer", "So far we're holding them off in the south but we're noticing their strength increase by the day.", _target ], 
		[ "Michael", "Just keep doing what you're doing and hold firm Sir. Is my lift ready?", _caller ], 
		[ "CDF Officer", "Your carriage awaits, Captain. Board the helicopter when you're ready.", _target ]
	], "CUSTOM", 0.15, true ] execVM "fn_simpleConv.sqf";
	
	_target removeAction _id;
}];

I'm presuming here that Michael is the player who initiates the conversation and officer1 is the unit that has the action attached. If not just change _target/_caller in each conversation line back to how they where.

  • Like 2
  • Thanks 2

Share this post


Link to post
Share on other sites
57 minutes ago, Larrow said:

Remove your lines from within the simple conversation script.


inspector = this addAction[ "Inspect", { 
	params[ "_target", "_caller", "_ID" ];
	
	[ "task1", "SUCCEEDED" ] call BIS_fnc_taskSetState;
	
	[[
		[ "CDF Officer", "Welcome to Altis, Captain. We're glad your here.", _target ], 
		[ "Michael", "Glad to be here. So what's the situation?", _caller ], 
		[ "CDF Officer", "The reds have been hitting our supply lines from the east to try and cripple us.", _target ], 
		[ "CDF Officer", "So far we're holding them off in the south but we're noticing their strength increase by the day.", _target ], 
		[ "Michael", "Just keep doing what you're doing and hold firm Sir. Is my lift ready?", _caller ], 
		[ "CDF Officer", "Your carriage awaits, Captain. Board the helicopter when you're ready.", _target ]
	], "CUSTOM", 0.15, true ] execVM "fn_simpleConv.sqf";
	
	_target removeAction _id;
}];

I'm presuming here that Michael is the player who initiates the conversation and officer1 is the unit that has the action attached. If not just change _target/_caller in each conversation line back to how they where.

 

@Larrow Well I don't know how you did it but it worked! Thank you so much.

 

Some of the guys on here said I should learn about params as they make things a lot easier. I'm presuming you have used 3 params (_target, _caller and _ID) to completely simplify everything and make it work, honestly I'm amazed. 

 

How do the params know who each person is? I presume _target is the officer who's variable name is "officer1", _caller is my player who is "michael" and I have no clue what _ID means?

 

I'm learning new things every day thanks to this awesome community. :) 

  • Like 1

Share this post


Link to post
Share on other sites
2 hours ago, Samcot said:

I presume _target is the officer who's variable name is "officer1", _caller is my player who is "michael" and I have no clue what _ID means?

Yes. _target is the object the action is attached/added to. _caller is the person using the action. _id is the index of the action attach to _target, and can be used to remove that specific action, as I have done in the last line.

 

2 hours ago, Samcot said:

How do the params know who each person is?

The code given to the action when called is passed a set of parameters, as can be seen on its wiki page.

Quote

Parameters array passed to the script upon activation in _this variable is:

params ["_target", "_caller", "_actionId", "_arguments"];

  • target (_this select 0): Object - the object which the action is assigned to
  • caller (_this select 1): Object - the unit that activated the action
  • ID (_this select 2): Number - ID of the activated action (same as ID returned by addAction)
  • arguments (_this select 3): Anything - arguments given to the script if you are using the extended syntax

 

  • Like 1

Share this post


Link to post
Share on other sites
7 hours ago, Larrow said:

Yes. _target is the object the action is attached/added to. _caller is the person using the action. _id is the index of the action attach to _target, and can be used to remove that specific action, as I have done in the last line.

 

The code given to the action when called is passed a set of parameters, as can be seen on its wiki page.

 

 

Ahh I see. This makes sense, thank you for the description man! 

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

×