Jump to content
C.Ritter

How to add Interactable Objects with links? [Solved]

Recommended Posts

I want to try and add a billboard or any object with a script Example, "Click here to join our discord server" and then when you click it then you get onto the discord but i simple dont know how or if its possible, if so then i dont know how you do it, can anybody help me please? :i

Share this post


Link to post
Share on other sites

I have 0 skillz in scripting, but forgot about this thread sorry, already have it sorted :)

Share this post


Link to post
Share on other sites
2 hours ago, C.Ritter said:

I have 0 skillz in scripting, but forgot about this thread sorry, already have it sorted :)

It is best practice to share your solutions, so that others with the same question will find something other than an empty topic.

  • Like 2

Share this post


Link to post
Share on other sites

In lieu of the OPs solution:

Two examples of how to achieve this at the end (mine and larrows). I think mine might be the simplest to implement, but larrows is probably the better solution no doubt. 

 

  • Like 2

Share this post


Link to post
Share on other sites

Got a better and easier solution, this template mission teach you something or two

 

Download: https://www.dropbox.com/s/umfv7j6nkrmm1ix/concept_recruitmentBoard.VR.rar?dl=0 (WinRar file.)

 

Put the recruitment_action.sqf into you're mission then copy and paste this line " call{0=[this] execVM "recruitment_action.sqf"} " into any object you may want to link the script to.

I wrote // on one or more of them in recruitment_action.sqf to help you understand what they do.

 

The mission.sqm is just for show, you will not need this for you're own missions, only the script (.sqf)

 

Would have done it earlier but forgot about it right after, my bad.

 

XianGrim helped me for this script, not that this is needed but some credits is better than nothing.

 

 

If you dont want to download the mission "tutorial" then.

 

Make a recruitment_action.sqf in you're mission.

copy and paste this into it:

 

Quote

_recruitmentApparatus = _this select 0;

[
    _recruitmentApparatus,
    "join our discord channel!", //use lower case becaues its prefaces with "Hold Space to"
    "",
    "",
    "_this distance _target < 5",
    "_caller distance _target < 5",
    {},
    {},
    {
        _string = ""; // Paste you're link inside the ""
        _callNamed = (name _caller);
        hint format ["Hey %2!\n--------\nA link to our discord has been copied to your clipboard! Come hang out with us!\n\nLink = %1",_string,_callNamed]; // You can edit this line " link to our discord has been copied to your clipboard! Come hang out with us! "
        copyToClipboard _string; // This makes the link copy to your clipboard
    },
    {},
    [],
    1,
    0,
    false,
    false
] remoteExec ["BIS_fnc_holdActionAdd",0,_recruitmentApparatus];

// Do NOT delete any of these "//" in this script. (Helping Purposes).
// 0 = [this] execVM "recruitment_action.sqf"; place that in any of the objects you might wanna use. (Init of the object)

 

Then inside the object paste in the init:

 

Quote

0 = [this] execVM "recruitment_action.sqf"; (Same line says in the recruitment_action.sqf)

 

Share this post


Link to post
Share on other sites

Why:

call{0=[this] execVM "recruitment_action.sqf"}

Just wondering if there is a specific reason? Never seen that. I just use execVM, call or spawn but not together.

0 = [this] execVM "recruitment_action.sqf";

 

Share this post


Link to post
Share on other sites

Script was first made to make me able to do it in one object only, then i asked him how i could have it in multiple objects at once and this is the final.

Why i dunno, as said 0 skillz, but that is how i got it, and works just fine either way :)

Share this post


Link to post
Share on other sites

What??? Why not just:

0 = [this] execVM "recruitment_action.sqf";

I don't see why you added call there too hence why I asked if there was a specific reason.

Share this post


Link to post
Share on other sites

It is great to supply an example mission, but it would be ideal to post the contents of the script here, so those seeking help don't have to download a mission that might not be there in a month.

  • Like 1

Share this post


Link to post
Share on other sites

I understood that, and i asnwered mate, i dunno, got the script like this, cant really say, the script works as it is.

Share this post


Link to post
Share on other sites

Am never deleting my files in dropbox so no worries.

Share this post


Link to post
Share on other sites

Had to be a typo, 

 

0 = [this] execVM "recruitment_action.sqf";

 

is all you need

  • Like 1

Share this post


Link to post
Share on other sites

Well thats what you gave me mate xD

Works aswell as the other, updating with this then.

Share this post


Link to post
Share on other sites
7 minutes ago, C.Ritter said:

Am never deleting my files in dropbox so no worries.

Sometimes things change. Regardless, there is no reason not to post the code here, and you are still forcing a download where one is not necessary.

  • Like 1

Share this post


Link to post
Share on other sites

@XianGrim - Yeah, I guess. I was just making sure. :dontgetit:

Edit: Ah, he copied it from mission.sqm directly. @XianGrim

			class Attributes
			{
				init="call{0=[this] execVM ""recruitment_action.sqf""}";
			};

I downloaded the archive and looked at the code, made a few tweaks for anyone else that comes here for help.

Original version:

_recruitmentApparatus = _this select 0;

[
    _recruitmentApparatus,
    "join our discord channel!", //use lower case becaues its prefaces with "Hold Space to"
    "",
    "",
    "_this distance _target < 5",
    "_caller distance _target < 5",
    {},
    {},
    {
        _string = ""; // Paste you're link inside the ""
        _callNamed = (name _caller);
        hint format ["Hey %2!\n--------\nA link to our discord has been copied to your clipboard! Come hang out with us!\n\nLink = %1",_string,_callNamed]; // You can edit this line " link to our discord has been copied to your clipboard! Come hang out with us! "
        copyToClipboard _string; // This makes the link copy to your clipboard
    },
    {},
    [],
    1,
    0,
    false,
    false
] remoteExec ["BIS_fnc_holdActionAdd",0,_recruitmentApparatus];

// Do NOT delete any of these "//" in this script. (Helping Purposes).
// call{0=[this] execVM "recruitment_action.sqf"} place that in any of the objects you might wanna use. (Init of the object)

Tweaked version:

params ["_target", "_title", "_idleIcon", "_progressIcon", "_condShow", "_condProgress", "_codeStart", "_codeProgress", "_codeCompleted", "_codeInterupted", "_arguments", "_duration", "_priority", "_removeCompleted", "_showUncon"];

// you can also set default for these if you wish
// https://community.bistudio.com/wiki/params
// see https://community.bistudio.com/wiki/BIS_fnc_holdActionAdd for arguments

[
	_target,
	_title
	_idleIcon
	_progressIcon,
	_condShow,
	_condProgress,
	_codeStart,
	_codeProgress,
	_codeCompleted,
	_codeInterupted,
	_codeInterupted,
	_arguments,
	_duration,
	_priority,
	_removeCompleted,
	_showUncon
] remoteExec ["BIS_fnc_holdActionAdd", [0, -2] select isDedicated, _target];
[player, "Some action", "\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_connect_ca.paa", "\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_connect_ca.paa", "_this distance _target < 3", "_caller distance _target < 3", {}, {}, {hintSilent "Hello!";}, {}, [], 12, 0, true, false] call TAG_fnc_addHoldAction;

Don't forget to compile function, I use CfgFunctions but you can also do it like:

TAG_fnc_addHoldAction = compile preprocessFileLineNumbers "fn_addHoldAction.sqf";

This way you don't need to duplicate code/files.

  • Like 1

Share this post


Link to post
Share on other sites

I put in the mission link and wrote the whole script, not sure why your still posting on a solved thread tho.

Btw i didnt get it from the mission.sqm.

Share this post


Link to post
Share on other sites

Yeah I'm a big fan of the hold actions as well. He didn't want them lol

Share this post


Link to post
Share on other sites
2 minutes ago, C.Ritter said:

I put in the mission link and wrote the whole script, not sure why your still posting on a solved thread tho.

What is your problem lol? I am posting in a solved because:

1) I shared the code and not just a download link.

2) I improved the code and clearly stated why.

3) Because I can.

Quote

This way you don't need to duplicate code/files.

 

Share this post


Link to post
Share on other sites

Well for my sake, my case is solved so i don't need more help.

Share this post


Link to post
Share on other sites

Cool. I didn't do it just for your sake. It is community forums, other people may benefit from it as well which is what @Harzach was saying.

  • Like 2

Share this post


Link to post
Share on other sites

 

 

5 hours ago, HazJ said:

Why:


call{0=[this] execVM "recruitment_action.sqf"}

Just wondering if there is a specific reason? Never seen that. I just use execVM, call or spawn but not together.


0 = [this] execVM "recruitment_action.sqf";

 

 

 

The call is just automatically added by the trigger code in mission.sqm. You don't see it in Editor but it exists in mission.sqm. This is implemented since Apex if I'm right. I don't know the exact reason, probably more consistent in case of error.

So, in on activation field, I confirm, You don't need that..

Share this post


Link to post
Share on other sites
5 hours ago, HazJ said:

@XianGrim - Yeah, I guess. I was just making sure. :dontgetit:

Edit: Ah, he copied it from mission.sqm directly. @XianGrim


			class Attributes
			{
				init="call{0=[this] execVM ""recruitment_action.sqf""}";
			};

@pierremgi - Yeah, already figured. :dontgetit:

 

Share this post


Link to post
Share on other sites

Just to point out " Edit: Ah, he copied it from mission.sqm directly " no i didnt, XianGrim gave me the line " call{0=[this] execVM ""recruitment_action.sqf""} " so stop trying to guess what i did and did not, before knowing it. Thank you. call{0=[this] execVM ""recruitment_action.sqf""} and 0 = [this] execVM "recruitment_action.sqf"; works both even tho there is a typo, so i don't see a problem carrying on this matter.

Share this post


Link to post
Share on other sites

It's not an accusation. They are just trying to figure out why the call and other unnecessary formatting is there. And I'll point out that the code is absolutely copied from a mission.sqm, just not by you.

  • Like 1

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

×