cfsfirefighter 1 Posted October 15, 2013 Hey guys im having problems with the attach to command im trying to spawn a unit and get him to stand in the middle of the room this it what i have tried and all return errors _shopkeeper = "B_RangeMaster_F" createUnit [_position,group SPY_GAMELOGIC]; _shopkeeper attachTo [341b7900# 1442061: i_shop_01_v1_f.p3d,[0,0,0]]; "B_RangeMaster_F" createUnit [_position,group SPY_GAMELOGIC, this attachTo [341b7900# 1442061: i_shop_01_v1_f.p3d,[0,0,0]]]; This last one returns the error Error in expression <teUnit [_position,group SPY_GAMELOGIC,""this attachTo [341b7900# 1442061: i_shop> Error position: <this attachTo [341b7900# 1442061: i_shop> Error Missing ] Also 341b7900# 1442061: i_shop_01_v1_f.p3d is the name of the object which i found through _shop = nearestBuilding _position; diag_log format ["Shop %1",_shop]; Thanks for any help Share this post Link to post Share on other sites
na_palm 19 Posted October 15, 2013 hi cfsfirefighter, Creating the unit works? why are you trying to bind a unit on a house, it's unlikely that it will move, you know? Maybe i need more coffee to understand the intention here?? greetings Na_Palm Share this post Link to post Share on other sites
cfsfirefighter 1 Posted October 15, 2013 nah u dont need more coffee :-) i need to to go to a certain position in the building, as a user purchase the building an AI spawns and attaches to a certain spot on the building and he cannot then be run over or pushed out of position. i am going to have an array of buildings with positions cheers Share this post Link to post Share on other sites
Tajin 349 Posted October 15, 2013 You can't reference an object like that. This should work: _shop = nearestBuilding _position; _shopkeeper = "B_RangeMaster_F" createUnit [_position,group SPY_GAMELOGIC]; _shopkeeper attachTo [_shop,[0,0,0]]; Share this post Link to post Share on other sites
cfsfirefighter 1 Posted October 15, 2013 nah tried it that way and i get this error Error in expression <teUnit [_position,group SPY_GAMELOGIC]; _shopkeeper attachTo [_shop,[0,0,0]]; > Error position: <_shopkeeper attachTo [_shop,[0,0,0]]; > Error Undefined variable in expression: _shopkeeper Share this post Link to post Share on other sites
na_palm 19 Posted October 15, 2013 that error suggests that your createunit command is'nt working as _shopkeeper is empty... so does creating the unit work. does you see it in game? Share this post Link to post Share on other sites
kylania 568 Posted October 15, 2013 createUnit doesn't actually return anything, not even the unit created. To capture the unit you should use createUnit array. _shop = nearestBuilding _position; _shopkeeper = group SPY_GAMELOGIC createUnit ["B_RangeMaster_F", _position, [], 0, "NONE"]; _shopkeeper attachTo [_shop,[0,0,0]]; Share this post Link to post Share on other sites
cfsfirefighter 1 Posted October 15, 2013 Ok no errors but the people are spawning in the ocean at ref 999999 so its like it cannot find the location. and yes the soldier did appear with the last script but didnt attach Share this post Link to post Share on other sites
cfsfirefighter 1 Posted October 15, 2013 Im still banging my head on my bench anyone else have any ideas why the AI is being teleported to the edge of the map in the water, however without the attachto the AI placed in the building. Share this post Link to post Share on other sites
f2k sel 164 Posted October 15, 2013 You could try a test to see it the unit name is correct. Replace the attach line with this line _shopkeeper setdamage 1; if the unit dies then it's a problem with the attacto command not working with the building. Share this post Link to post Share on other sites
na_palm 19 Posted October 15, 2013 nearestBuilding awaits an object and no position on the right side from it. have you tried to change it to: _shop = nearestBuilding _shopkeeper; and change the order therefor too, to: _shopkeeper = group SPY_GAMELOGIC createUnit ["B_RangeMaster_F", _position, [], 0, "NONE"]; _shop = nearestBuilding _shopkeeper; _shopkeeper attachTo [_shop,[0,0,0]]; Share this post Link to post Share on other sites
cfsfirefighter 1 Posted October 16, 2013 Nope that still didnt work he was out in the ocean again Share this post Link to post Share on other sites
na_palm 19 Posted October 16, 2013 how do you get "_position" and what is in it? Share this post Link to post Share on other sites
cfsfirefighter 1 Posted October 16, 2013 [3871.25,17520.5,0.00143433] that is the position and it is stored in a database Share this post Link to post Share on other sites
na_palm 19 Posted October 16, 2013 to check it, i used now: this setpos [3871.25,17520.5,0.00143433]; this attachTo [nearestBuilding this,[0,0,0]]; on a newly created mission on Altis. Only created the player char and put the above in the init. It's working as intended. Could it be that you have somewhere in your mission code something that changes the shopkeepers position? In the Wasteland missions as an ex. the player chars get new positions as of JIP... Share this post Link to post Share on other sites
twoodz 10 Posted October 21, 2013 to check it, i used now: this setpos [3871.25,17520.5,0.00143433]; this attachTo [nearestBuilding this,[0,0,0]]; on a newly created mission on Altis. Only created the player char and put the above in the init. It's working as intended. Could it be that you have somewhere in your mission code something that changes the shopkeepers position? In the Wasteland missions as an ex. the player chars get new positions as of JIP... Hey Na_palm, The problem is this is run on the server as it starts up. Do the same thing with a dedicated server. Put that in the init line, then join. Unit isn't attached. Share this post Link to post Share on other sites
na_palm 19 Posted October 21, 2013 Ok, somehow i was under the impression you are working on an SP mission.... Nevermind, an init.sqf conform way would be this: if (!isServer) exitWith {}; shop_list = ["Shopkeeper_1"]; _group = createGroup civilian; { _pos = getMarkerPos _x; _shop = nearestBuilding _pos; _shopkeeper = _group createUnit ["B_RangeMaster_F", _pos, [], 0, "CAN_COLLIDE"]; _shopkeeper attachTo [_shop,[0,0,0]]; sleep 0.001; }forEach shop_list; This code assumes that you place an map marker on the house you want as a shop and then put the markers name in the "shop_list" ARRAY. Nothing else must be placed on the map. greetings Na_Palm Share this post Link to post Share on other sites