th3gingergamer 2 Posted June 15, 2018 I've created a small script for lowering bollards and then raising them again but when I use the action on the bollard I receive the error that line 6 is missing a semicolon. _type = ["Land_Bollard_01_F"]; _playerCalling = vehicle player; for [{_i=0},{_i < (count _bollards)},{_i=_i+1}] do { __bollards = _this nearObjects [_type select _i, 15]; {setDamage 1;} forEach _bollards; }; hintSilent "Barrier Opened"; waitUntil {_playerCalling distance _type > 10}; for [{_i=0},{_i < (count _bollards)},{_i=_i+1}] do { __bollards = _this nearObjects [_type select _i, 15]; sleep 1; {setDamage 0;} forEach _bollards; }; hintSilent "Barrier Closed"; sleep 5; hint ""; I've tried to figure out what the problem is for an hour now but I can't work it out. Any help at all is appreciated. 1 Share this post Link to post Share on other sites
KC Grimes 79 Posted June 15, 2018 In Line 6 you are missing the _x argument for setDamage. {setDamage 1;} forEach _bollards; {_x setDamage 1;} forEach _bollards; The same error occurs in Line 14. Also be advised that you are defining __bollards (2 underscores) but referencing _bollards (1 underscore). 4 Share this post Link to post Share on other sites
th3gingergamer 2 Posted June 15, 2018 Thankyou that seemed to have fixed the first problem but after reworking the code I realised I didn't need the loops(hopefully). I removed them and now I am getting an error with _bollards = _this nearObjects [_type, 15]; I already removed the double underscore but now I am getting the error: "4 elements provided, 3 expected" I tried wrapping from _this to the ned of the line with curly brackets but this cased an error with the forEach later in the code... (I was getting this error before removing the loops) Here is the edited code in case it would help: _type = ["Land_Bollard_01_F"]; _playerCalling = vehicle player; _bollards = _this nearObjects [_type, 15]; {_x setDamage 1;} forEach _bollards; hintSilent "Barrier Opened"; waitUntil {_playerCalling distance _type > 10}; {_x setDamage 0;} forEach _bollards; hintSilent "Barrier Closed"; sleep 5; hint ""; Share this post Link to post Share on other sites
squeeze 22 Posted June 15, 2018 put this line above your problem code, you might find your own answer. player sideChat format["_this = %1",_this]; use hint if you like hint format["_this = %1",_this]; or my fav diag_log format["_this = %1",_this]; or player sideChat format["_type = %1 _playerCalling = %2 _bollards = %3 ", ["Land_Bollard_01_F"],vehicle player, _this nearObjects [_type, 15]]; Share this post Link to post Share on other sites
th3gingergamer 2 Posted June 15, 2018 so what i've learned from that is _this doesn't actually contain the coordinates of the object that called the script... So can anyone tell me how to get the coordinates of the object calling the script? Share this post Link to post Share on other sites
squeeze 22 Posted June 15, 2018 _bollards = (getPos _this) nearObjects [_type, 15]; Share this post Link to post Share on other sites
th3gingergamer 2 Posted June 15, 2018 I then get the error "Type Array expected object,location" Share this post Link to post Share on other sites
squeeze 22 Posted June 15, 2018 want to share how you are calling this script, are you passing anything to the script to use the _this variable Share this post Link to post Share on other sites
th3gingergamer 2 Posted June 20, 2018 I'm calling the script through an addaction on one of the bollards. I want to be able to just place a bollard anywhere on the map and add the addAction for it to just work. I'm not passing anything to the script for _this. It does still store info such as who called the script though. Share this post Link to post Share on other sites
Grumpy Old Man 3545 Posted June 20, 2018 On 6/16/2018 at 12:52 AM, th3gingergamer said: I then get the error "Type Array expected object,location" waitUntil {_playerCalling distance _type > 10}; Most likely this line. _type holds an array of strings, distance expects an object or location. Cheers 1 Share this post Link to post Share on other sites
th3gingergamer 2 Posted June 20, 2018 Thanks for everyone who helped me with this. I finally fixed it. I changed _this to (_this select 0) and fixed that problem where _type was used instead of _this select 0. Share this post Link to post Share on other sites
Larrow 2821 Posted June 20, 2018 You can always use gamelogics and syncing to do stuff like this, instead of relying on any near commands. Here is a test composition. In essence the compositions gamelogic is very similar to a module ( a gamelogic that runs code ) except it runs it from init, rather than a specified function, and of course it has no editor attributes. Spoiler nul = this spawn { params[ "_logic" ]; _controller = synchronizedObjects _logic select{ _x getVariable[ "Controller", false ] } select 0; _table = synchronizedObjects _logic select{ _x getVariable[ "ControlTable", false ] }; _table = ( [ _table, [ objNull ] ] select ( _table isEqualTo [] )) select 0; _bollards = synchronizedObjects _logic - [ _controller, _table ]; if !( isNull _table ) then { _controller setDir getDir _table; _controller attachTo[ _table, [ 0, 0, ( boundingBoxReal _table select 1 select 2 ) + ( boundingBoxReal _controller select 1 select 2 ) ] ]; }; _controller addAction [ "Lower Bollards", { params [ "_target", "_caller", "_id", "_args" ]; _args params[ "_bollards", "_logic" ]; switch ( _logic getVariable [ "lowered", false ] ) do { case false : { for "_h" from 0 to 1 step 0.1 do { uiSleep 0.1; { _x setPosATL (( getPosATL _x ) vectorAdd [ 0, 0, -0.1 ] ); }forEach _bollards; }; _target setUserActionText[ _id, "Raise Bollards" ]; _logic setVariable[ "lowered", true ]; }; case true : { for "_h" from 0 to 1 step 0.1 do { uiSleep 0.1; { _x setPosATL (( getPosATL _x ) vectorAdd [ 0, 0, 0.1 ] ); }forEach _bollards; }; _target setUserActionText[ _id, "Lower Bollards" ]; _logic setVariable[ "lowered", false ]; }; }; }, [ _bollards, _logic ] ]; }; Example code from the init of the compositions gamelogic 1 Share this post Link to post Share on other sites
th3gingergamer 2 Posted June 20, 2018 I'm using near commands for it since I'm quite new to scripting and I want it to work anywhere a group of bollards are placed. The script is just for fun mainly but also for a server I help with which is why I made it a script which is run from the addaction on one of the bollards. I've changed it from setDamage to setPos since it looks better and setDamage made them fall random directions. I'm currently going to modify the script so that it works on any object the addaction is put onto. Share this post Link to post Share on other sites
th3gingergamer 2 Posted June 20, 2018 (edited) Okay so i changed the script to use setPos instead. Every bollard has allowDamage false applied to it. After activating the script it seems like the bollards no longer have collisions. Anyone know what's going on? It also seems like the bollard with the addAction loses this addAction after it collides with a vehicle. This means if a car bumps into it then they become useless. Edited June 20, 2018 by th3gingergamer Added more info Share this post Link to post Share on other sites