Jump to content
Sign in to follow this  
FlowerzNDaizyz

Help With Error In Base Building Scripts

Recommended Posts

Hi all,

I am making a base building menu, and I am encountering an error in one of the scripts. In order to properly understand what I'm doing I'll explain the concept.

1.) I am using a scroll menu to execute the building spawn script

2.) The building spawn script contains another scroll menu, which is how i position the object.

Here is the scripts:

_class = _passedclass;
_gpos = getPos player; 
_pos = [(_gpos select 0)+1,(_gpos select 1)+1,(_gpos select 2)];
_rid = random 999999;
_spawn = format["
if (isServer) then {
_object = createVehicle ['%1', %2, [], 0, 'CAN_COLLIDE']; 
_object setVariable ['ObjectID', %3, true];
}",_class,_pos,_rid];
sleep 0.1;
player setVehicleInit _spawn;
sleep 0.1;
processInitCommands;
sleep 0.1;
clearVehicleInit player;
hint "Spawned!";
sleep 1;
titleText [format["Positioning Menu Loaded!\n%1, Hold Control While Clicking On Positions, Or The Menu Will Go Away!", name player], "PLAIN"];

//THIS PART ISNT SHOWING UP:
objmenu =
[
["",true],
["==============", [], "", -5, [["expression", ""]], "1", "0"],
["Sam [22] v 0.5", [], "", -5, [["expression", ""]], "1", "0"],
["  *Building*  ", [], "", -5, [["expression", ""]], "1", "0"],
["==============", [], "", -5, [["expression", ""]], "1", "0"],
["Move Object x + 0.2m",[],"",-5,[["expression",'[0.2,0,0,1] execVM "\sam\build\moveobj.sqf"']],"1","1"],
["Move Object x + 0.5m",[],"",-5,[["expression",'[0.5,0,0,1] execVM "\sam\build\moveobj.sqf"']],"1","1"],
["Move Object x - 0.2m",[],"",-5,[["expression",'[0.2,0,0,-1] execVM "\sam\build\moveobj.sqf"']],"1","1"],
["Move Object x - 0.5m",[],"",-5,[["expression",'[0.5,0,0,-1] execVM "\sam\build\moveobj.sqf"']],"1","1"],
["Move Object y + 0.2m",[],"",-5,[["expression",'[0,0.2,0,1] execVM "\sam\build\moveobj.sqf"']],"1","1"],
["Move Object y + 0.5m",[],"",-5,[["expression",'[0,0.5,0,1] execVM "\sam\build\moveobj.sqf"']],"1","1"],
["Move Object y - 0.2m",[],"",-5,[["expression",'[0,0.2,0,-1] execVM "\sam\build\moveobj.sqf"']],"1","1"],
["Move Object y - 0.5m",[],"",-5,[["expression",'[0,0.5,0,-1] execVM "\sam\build\moveobj.sqf"']],"1","1"],
["Move Object z + 0.2",[],"",-5,[["expression",'[0,0,0.2,1] execVM "\sam\build\moveobj.sqf"']],"1","1"],
["Move Object z + 0.5",[],"",-5,[["expression",'[0,0,0.5,1] execVM "\sam\build\moveobj.sqf"']],"1","1"],
["Move Object z - 0.2",[],"",-5,[["expression",'[0,0,0.2,-1] execVM "\sam\build\moveobj.sqf"']],"1","1"],
["Move Object z - 0.5",[],"",-5,[["expression",'[0,0,0.5,-1] execVM "\sam\build\moveobj.sqf"']],"1","1"],
["Set Azimuth Object To Player",[],"",-5,[["expression",'[] execVM "\sam\build\dir.sqf"']],"1","1"],
["==============", [], "", -5, [["expression", ""]], "1", "0"]
];

showCommandingMenu "#objmenu";

moveobj.sqf

/*
How To Use This:
handle = [x,y,z,add or subtract] execVM "scripts\moveobj.sqf";
Ex.
[1,0,0,1] execVM "scripts\moveobj.sqf";
Result:
_object's position would be set to [(_pos select 0)+1,(_pos select 1),(_pos select 2)];
1 is add, -1 is subtract!
*/
_xval = _this select 0;
_yval = _this select 1;
_zval = _this select 2;
_type = _this select 3;
if (isServer) then { call fnc_delete_redo };
fnc_delete_redo = {
if (_type == 1) then {
_cursor = cursorTarget;
_pos = getPos _cursor;
_classname = getText(configFile >> "CfgVehicles" >> _cursor;
deletevehicle _cursor;
_set = [format [(_pos select 0)+_xval(_pos select 1)+_yval,(_pos select 2)+_zval];
_newobject = createVehicle [_classname, _set, [], 0, "CAN_COLLIDE"];
titleText [format["Object %1 Moved\n+ %2 On The X Axis\n+ %3 On The Y Axis\n+ %4 On The Z Axis",_newobject,_xval,_yval,_zval], "PLAIN"]; 
};
if (_type == -1) then {
_cursor = cursorTarget;
_pos = getPos _cursor;
_classname = getText(configFile >> "CfgVehicles" >> _cursor;
_set = [(_pos select 0)-_xval(_pos select 1)-_yval,(_pos select 2)-_zval];
deletevehicle _cursor;
_newobject = createVehicle [_classname, _set, [], 0, "CAN_COLLIDE"];
titleText [format["Object %1 Moved\n- %2 On The X Axis\n- %3 On The Y Axis\n- 4 On The Z Axis",_newobject,_xval,_yval,_zval], "PLAIN"]; 
};
if (_type == 0) then {
_cursor = cursorTarget;
_pos = getPos _cursor;
_dir = getDir player;
_classname = getText(configFile >> "CfgVehicles" >> _cursor;
deletevehicle _cursor;
_newobject = createVehicle [_classname, _pos, [], 0, "CAN_COLLIDE"]; 
_newobject setDir _dir;
};
};

I'd really appreciate it if you could help me figure out what is wrong. It seems like I wasted 20 minutes making these scripts for nothing.

~Flowerz

Share this post


Link to post
Share on other sites

In the first script, _passedclass is never defined.

Squint finds all sorts of issues with the second script, but I don't have the time to analyze them (likely some false positives).

It's also good practice to private your variables.

Share this post


Link to post
Share on other sites

as well as the above variable not being defined I think you will need to use

showCommandingMenu "#USER:objmenu";

to open the menu.

and just looking at the second script every instance of :-

_classname = getText(configFile >> "CfgVehicles" >> _cursor;

is missing a closing bracket and are usual in this sort of layout

_name = gettext (configFile > "CfgVehicles" >> (typeof _x) >> "displayName");

yours doesn't seem to have a final parameter.

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  

×