Jump to content
wendaf

Wrong type of parameter passed with addAction

Recommended Posts

Hello,
I'm currently trying to make some sort of interaction system for civilians, but ran into an issue, where the addAction function passes parameter to my script.sqf, but wrong. My script requires the parameter to be a string, but addAction seems to pass object. Any ideas?
This is a code in a character init

_entityName = "Alexander";
this setName _entityName;
this addAction ["Interact", "script.sqf", _entityName, 1.5,true,true,"","player distance this < 2"];

This is my script.sqf

DialogOwner = (_this select 1) select 0;
DialogOption = 1;
_handle = createdialog "Interakce";

then it creates a GUI window. When I try to create subtitles using spawn BIS_fnc_EXP_camp_playSubtitles, DialogOwner, which should be string is somehow an object.
Thanks for any help

Share this post


Link to post
Share on other sites
_entityName = "Alexander";
this setName _entityName;
this addAction ["Interact", "script.sqf", _entityName, 1.5,true,true,"","player distance this < 2"];



params [["_target",objNull,[objNull]], ["_caller",objNull,[objNull]], ["_actionId",-1,[0]], ["_arguments","",[""]]];
DialogOwner = _arguments;
DialogOption = 1;
_handle = createdialog "Interakce";

 

Share this post


Link to post
Share on other sites

Thanks for reply.
Unfortunately, I'm still getting error:

'...= false;

private _start = time;

{
_x |#|params [
["_name", "", [""]],
["_subtitl...'
Error Params: Type Object, expected String
File a3\missions_f_exp\campaign\functions\fn_EXP_camp_playSubtitles.sqd
[BIS_fnc_EXP_camp_playSubtitles], line 24

The way I understand it, addAction sends wrong type of parameter, therefore DialogOwner is not a string and it doesn't show but creates error instead.
Here's my dialog launching code:

_DialogText = [DialogOwner, DialogOption] call compile preprocessFileLineNumbers "getText.sqf";

[ 
 [DialogOwner, _DialogText ,0] 
] spawn BIS_fnc_EXP_camp_playSubtitles;

 

Share this post


Link to post
Share on other sites

Just for more intel, this is my getText.sqf

params ["_speaker", "_option"];

_outputText = "";

switch (_speaker) do {
	case "Alexander": { 
		switch (_option) do {
			case 1: { 
				_outputText = "I am standing here";
			};
			case 2: { 
				_outputText = "Noting happened here";
			};
			case 3: { 
				_outputText = "I don't need help";
			};
			default { 
				_outputText = "Que?";
			};
		};
	};
	case "Rebel": { 
		switch (_option) do {
			case 1: { 
				_outputText = "Fighting for the motherland";
			};
			case 2: { 
				_outputText = "Nothing";
			};
			case 3: { 
				_outputText = "Come help fight with us";
			};
			default { 
				_outputText = "Que?";
			};
		};
	};
	default { 
		_outputText = "... Silence ...";
	};
};

_outputText

 

Share this post


Link to post
Share on other sites

@wendaf, add this code to Init field:

this call {
    _entityName = "Alexander";

    _this setName _entityName;
    _this addAction ["Interact", "script.sqf", _entityName, 1.5, true, true, "", "player distance this < 2"];

    nil
};

and use code provided by @davidoss.

  • Like 1

Share this post


Link to post
Share on other sites

Still the same error, still doesn't work.
I have everything as you said, but still the same error

Share this post


Link to post
Share on other sites

@wendaf, well, can you provide test mission?

 

P. S.

Another way to get name is using name command (in script.sqf) insteand of using global variable.

Share this post


Link to post
Share on other sites

Thanks both of you :D
I found out, that our group's framework was interfering with the script somehow. This works perfectly on it's own with your corrections.
Thanks again :)
 

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

×