Jump to content
Sign in to follow this  
FanBF2

How to make a basic GUI to spawn vehicles ?

Recommended Posts

Hi everyone.

I use the very good Virtual Vehicle Spawner script in my mission. Unfortunately, some addons are not fetched by VVS.

I would like to know if I can simply create a basic GUI where I can add the classnames of addons and then they appears in a sort of basic list so I can choose which one to spawn on a marker.

There is a simple way to do that ?

Thanks. :)

Share this post


Link to post
Share on other sites

Making a GUI itself is pretty complicated, actually, at least before you have some experience. I recommend

to start.

Luckily, our very own Iceman77, whose pdf tutorial is referenced in the video, is very active on the forum, so I'm sure he'll see this thread and be able to answer any questions. I've even made a dialog or two in my day :p

Share this post


Link to post
Share on other sites

This is similar to what I have been trying to do, create a dialog to spawn a script. If you follow the video then all you need to know extra is to add

action = "closeDialog 0;_nil=[]ExecVM ""yourscriptname.sqf""";

to your button in the dialogs.hpp to call your spawn script. But personally I cannot get my own created dialogs to show up and found the example mission on the linked tutorial video to not work. Also that video doesn't explain how you get defines.hpp - you press Ctrl + P while in GUI editor and then copy paste that.

---------- Post added at 18:44 ---------- Previous post was at 18:23 ----------

If you get it working id love to see an example mission because i am having no end of trouble getting this to just show up

Share this post


Link to post
Share on other sites

You could take a look at VSYS in my sig. It's pretty trimmed down I suppose. It pulls the vehicle's from the cfg. Which should load your addon vehicles automatically. Maybe you can have a look there to see how it's done.

Share this post


Link to post
Share on other sites

So I followed your tutorial Iceman77 and when I want to pass an argument (classname of a vehicle) in my execVM command when a load my mission I get an error message:

dialog.hpp

class HMMWV_SPAWN_dialog
{
idd=-1;
movingenable=false;

class controls 
{
////////////////////////////////////////////////////////
// GUI EDITOR OUTPUT START (by FanBF2[CH], v1.063, #Jelony)
////////////////////////////////////////////////////////

class hmmwv_frame: RscFrame
{
idc = 1800;
text = "HMMWV"; //--- ToDo: Localize;
x = 0.29375 * safezoneW + safezoneX;
y = 0.225 * safezoneH + safezoneY;
w = 0.4125 * safezoneW;
h = 0.55 * safezoneH;
};
class hmmwv1_button: RscButton
{
idc = 1600;
text = "HMMWV M2"; //--- ToDo: Localize;
x = 0.324687 * safezoneW + safezoneX;
y = 0.302 * safezoneH + safezoneY;
w = 0.0876563 * safezoneW;
h = 0.033 * safezoneH;
action = "closeDialog 0;_nil=["HMMWV2_M2"]ExecVM ""SPAWN\HMMWV.sqf""";
};
////////////////////////////////////////////////////////
// GUI EDITOR OUTPUT END
////////////////////////////////////////////////////////



};

HMMWV.sqf

_typeHMMWV = _this select 0;
hint format["%1",_typeHMMWV];
_spawnHMMWV = _typeHMMWV createVehicle position player; 

Here the error:

E1DbJZx.jpg

I don't understand what I am doing wrong.

Share this post


Link to post
Share on other sites

In hmmwv1_button class must to be

action = "closeDialog 0;_nil=['HMMWV2_M2']ExecVM 'SPAWN\HMMWV.sqf'";

Also if I'm not mistaken must to be

movingEnable = 0;

Or add

#define false 0

Edited by Schatten

Share this post


Link to post
Share on other sites

action = "closeDialog 0;_nil=['HMMWV2_M2']ExecVM 'SPAWN\HMMWV.sqf'";

Share this post


Link to post
Share on other sites

Yes it works ! Many thanks to everyone !

Anthonyfromtheuk, do you still need an example mission ?

Edit: Why in this case, strings need to be in ' ' instead of quote ?

Edited by FanBF2[CH]

Share this post


Link to post
Share on other sites

Because it's just standard programming protocol, if you ever have " " encompassing a piece if code anything within that, you use ' ' instead, and anything within that you use "" "", and really anymore than that you need to re-think the code overall. I have had to go that deep with the quotes before in a script thag creates a trigger, and the onAct statement had an addAction creation, and with those two commands I had to go as deep as double double quotes, it's just one of those things :p.

Share this post


Link to post
Share on other sites

So, if I understand correctly:

CODE_lvl1 "CODE_lvl2 'CODE_lvl3 ""CODE_lvl4 """CODE_lvl5"""""'" right ?

Share this post


Link to post
Share on other sites
;2803817']So' date=' if I understand correctly:

CODE_lvl1 "CODE_lvl2 'CODE_lvl3 ""CODE_lvl4 """CODE_lvl5"""""'" right ?

Your "CODE_lvl5" should be quadruple double quotes. This is because to have/use double quotes inside a string, you need to use 2 double quotes. Alternatively, you can use single quotes because they are still recognized as string definitions, but does not have the same restriction as double quotes regarding nested strings. For example:

hint "Hello world"; //puts a box on screen with Hello World
hint """Hello world"""; //puts a box on screen with "Hello world"
hint "'Hello world'"; //puts a box on screen with 'Hello world'

Alternatively, it could even look like this:

CODE_lvl1 "CODE_lvl2 ""CODE_lvl3 """"CODE_lvl4 """"""""CODE_lvl5"""""""""""""""

Share this post


Link to post
Share on other sites

Too... much... quotes...

Alright, I think I get it thanks !

Share this post


Link to post
Share on other sites
;2803875']Too... much... quotes...

Alright' date=' I think I get it thanks ![/quote']

No problem, but really nowadays with the arma engine, if you need to nest strings 4 times, you're doing something wrong. I made a mistake in my post, also. Rather than doubling the number of quotes each time, you only need to add 2 more double quotes. So in the blue CODE_lvl5 you would only need 6 double quotes, rather than 8. Then, if you were to go one scope deeper, you would use 8 double quotes, rather than 16.

Linear scaling, not exponential.

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
Sign in to follow this  

×