Jump to content

Recommended Posts

Is there any good way to imitate arrays with action on dialogs?

 

I have this right now:

action = "player addMagazine ""20Rnd_762x51_Mag"";";

It works 'n' all, but I was trying to make it add more than just one magazine to the player. Is this possible without using execVM to execute a script elsewhere?

 

 

  • Confused 1

Share this post


Link to post
Share on other sites

addMagazines

 

If you're using more than a couple of commands though you really would want to run a script. It's easier to read and edit then.

  • Like 2

Share this post


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

addMagazines

 

If you're using more than a couple of commands though you really would want to run a script. It's easier to read and edit then.

I don't want to make it run a .sqf file because it is only 1 line of code. 

 

So when using addMagazines how would I make it add more with just having an action? Since you can't use any brackets it is confusing how I would tell it how many magazines to add to the players inventory.

Share this post


Link to post
Share on other sites
7 minutes ago, HazJ said:

You mean more magazines?


action = "player addMagazines [""30Rnd_65x39_caseless_mag"", 10];";

?

I personally use UI EHs, in this case, ButtonClick.

https://community.bistudio.com/wiki/User_Interface_Event_Handlers

Wow, thanks. I thought that brackets weren't allowed with action, but I guess they are! Thanks for that!

 

One more question now though, how would you add a hint on the end of the line?

Share this post


Link to post
Share on other sites
1 minute ago, sbondo1234 said:

One more question now though, how would you add a hint on the end of the line?

Add it? Maybe?

 

Cheers

  • Haha 1

Share this post


Link to post
Share on other sites
1 minute ago, Grumpy Old Man said:

Add it? Maybe?

 

Cheers

I have tried to no result.

 

Share this post


Link to post
Share on other sites
6 minutes ago, sbondo1234 said:

I have tried to no result.

 

Are you serious? Come on dude, don't expect everything done for you. You can mess with it, it isn't gonna destroy your computer, not SQF at least, as far as I am aware. 😅

What did you try exactly? Show us.

https://community.bistudio.com/wiki/hintSilent

Share this post


Link to post
Share on other sites
8 minutes ago, HazJ said:

Are you serious? Come on dude, don't expect everything done for you. You can mess with it, it isn't gonna destroy your computer, not SQF at least, as far as I am aware. 😅

What did you try exactly? Show us.

https://community.bistudio.com/wiki/hintSilent

Sorry about that

I tried:

action = "player addMagazines [""30Rnd_65x39_caseless_mag"", 5];";"hint "5 mags added";";

 

Share this post


Link to post
Share on other sites

I found a way around it using the event handlers you sent above.

action = "player addMagazines [""30Rnd_65x39_caseless_mag"", 5];";
onMouseButtonDown = hint "hello";

Works so we are all good!

Thanks for the help @HazJ !

  • Like 1

Share this post


Link to post
Share on other sites
6 hours ago, sbondo1234 said:

action = "player addMagazines [""30Rnd_65x39_caseless_mag"", 5];";"hint "5 mags added";";

The action is a STRING. Anything contained in the STRING is executed by the action.

The reason you have double quotes on the magazine name is to signify that it is a string inside a string, you can quite easily replace them with single quotation marks.

action = "player addMagazines ['30Rnd_65x39_caseless_mag', 5];";"hint '5 mags added';";

As the STRING is a holder for the code to be executed you can think of the double quotations much the same as braces that you would use to contain the code to execute for a function.

In which case lets put them on separate lines.

action = "
	player addMagazines ['30Rnd_65x39_caseless_mag', 5];
";
"hint '5 mags added';";

Can you now see your error? Your hint is not contained within the actions STRING of code.

action = "
	player addMagazines ['30Rnd_65x39_caseless_mag', 5];
	hint '5 mags added';
";
action = " player addMagazines ['30Rnd_65x39_caseless_mag', 5]; hint '5 mags added'; ";

 

  • Like 4

Share this post


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

The action is a STRING. Anything contained in the STRING is executed by the action.

The reason you have double quotes on the magazine name is to signify that it is a string inside a string, you can quite easily replace them with single quotation marks.


action = "player addMagazines ['30Rnd_65x39_caseless_mag', 5];";"hint '5 mags added';";

As the STRING is a holder for the code to be executed you can think of the double quotations much the same as braces that you would use to contain the code to execute for a function.

In which case lets put them on separate lines.


action = "
	player addMagazines ['30Rnd_65x39_caseless_mag', 5];
";
"hint '5 mags added';";

Can you now see your error? Your hint is not contained within the actions STRING of code.


action = "
	player addMagazines ['30Rnd_65x39_caseless_mag', 5];
	hint '5 mags added';
";

action = " player addMagazines ['30Rnd_65x39_caseless_mag', 5]; hint '5 mags added'; ";

 

Yeah much clear now, thanks!

Share this post


Link to post
Share on other sites

Sorry for long reply. Yeah, Larrow said lol.

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

×