Impavido 0 Posted May 26, 2007 I've started using a very simple script to change the height of an object. Such as sand-bag bunkers and static weapons for defending a building or urban area. The scipt works fine in single player or on the server, but the height changes do not take effect online on the client computers. Here is the code I'm using: Quote[/b] ]_Object = _this select 0_height = _this select 1 _ObjPos = getpos _Object _cmx = _ObjPos select 0 _cmy = _ObjPos select 1 _cmz = _ObjPos select 2 _Object setpos [_cmx,_cmy,_cmz+_height] exit the modeltoworld command was recommended to me but the same problem persists. Suggestions? Share this post Link to post Share on other sites
Junker 0 Posted May 26, 2007 setpos does not work on MP for objects. read the bottom line. Biki Share this post Link to post Share on other sites
dr_eyeball 16 Posted May 26, 2007 Yeah, I've just discovered the same thing after finishing a large mission and had to redo the positioning of every object to simpler ground level concepts only. (v1.05) Even with all the workarounds that have been suggested and discussions over the past few months which, mind you, provide good solutions in preview or a client hosted MP game, I now find that setPos doesn't work from the dedicated server exe. Things like putting radio towers on top of buildings, air-dropping crates and things like that. It drives you nuts. Share this post Link to post Share on other sites
Op4 BuhBye 0 Posted May 26, 2007 Im not sure what is going on with this command. This topic has been put up 3 times that Ive seen. The first said it didnt work. Second said it did and now this one says no. All I can say for this is that I have used it in a mission to set the x, y, z coords and it worked fine Locally, on the server and for all clients. Share this post Link to post Share on other sites
Junker 0 Posted May 27, 2007 Im not sure what is going on with this command. This topic has been put up 3 times that Ive seen.The first said it didnt work. Second said it did and now this one says no. All I can say for this is that I have used it in a mission to set the x, y, z coords and it worked fine Locally, on the server and for all clients. it will work on vehicles and units but not static Objects. Share this post Link to post Share on other sites
Op4 BuhBye 0 Posted May 27, 2007 As far as I know it doesnt work on vehicles either as their configs are set to the ground just like a static object. Share this post Link to post Share on other sites
dr_eyeball 16 Posted May 27, 2007 It does work on vehicles. I can air drop a vehicle on a dedicated server. I think people are misusing the term "static" to mean different things, which is confusing the issue. Share this post Link to post Share on other sites
Op4 BuhBye 0 Posted May 27, 2007 I dont know about anyone else but Im not confusing "static". So what are we talking about here for my own knowledge. If you use SetPos on a static object , it doesnt work at all or it just falls to the ground through anything you set it on? Share this post Link to post Share on other sites
UNN 0 Posted May 27, 2007 Static objets (objects with Simulation="House") can be set at different heights in an MP game. But only at the config level. Doing it via the mission editor init field is to late. The objects position has been broadcast to all the clients by then, and cant be changed. AFAIK other MP things like the killed event, Ammo counts for Ammo boxes and animated doors on buildings still work across all the clients. So atm there are three choices: Create your static objects as addons and set the height there. Create the static objects as addons using a different simulation. Create your static objects locally on each client and the server with scripts. Creating objects locally works ok, using something like this: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">////////////////////////// // This Script By UNN V1.0 ////////////////////////// _Object=_This Select 0; _Type=_This Select 1; _Dir=GetDir _Object; _Pos=GetPos _Object; _Name=VehicleVarName _Object; DeleteVehicle _Object; _Result=_Type CreateVehicleLocal _Pos; _Result SetVehicleVarName _Name; [_Result] Call Compile Format ["%1=_This Select 0",_Name]; _Result SetDir _Dir; _Result SetPos _Pos; You pass this script a game logic and the class name of the static object you want creating. Position your game logic at the height you want, then call the script: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">[Logic01,"AmmoBoxWest"] ExecVM "Script.sqs" However because this creates the object locally for each client, certain things won't work: It can only be destroyed by units local to the client. So for a player, it's his squad and for the server it's everything else that isn't in a players squad or vehicle. Ammo counts for Ammo boxes will probably be local to. In other words if a player destroys an ammo crate, it will only be destroyed on his client. Everyone else will still have an intact ammo crate. I'm sure there will be other issues to. Share this post Link to post Share on other sites
Maddmatt 1 Posted May 27, 2007 Just an idea which I haven't tried: Could you edit the mission.sqm file in notepad and change the height coordinates of the object there? Would that work? Share this post Link to post Share on other sites
Junker 0 Posted May 27, 2007 Just an idea which I haven't tried: Could you edit the mission.sqm file in notepad and change the height coordinates of the object there? Would that work? that wont work it still loads the config before that. Share this post Link to post Share on other sites
UNN 0 Posted May 27, 2007 Quote[/b] ]Could you edit the mission.sqm file in notepad and change the height coordinates of the object there? Would that work? It doesn’t work in SP, so I guess it will be the same for MP. Shame, would have been a simple solution. There is another possibility. If one of the editor update addons was made multiplayer compatible. Would you be ok with the following method? Place your MP compatible object in the editor and give it a name (AmmoBox01 for example). Create a script in your mission called MPP_Positions.sqf. Add references to MPP_Positions.sqf,  for the Objects you want positioning and the offsets. For example MPP_Positions.sqf would look like this: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">[ ["AmmoBox01",[0,0,10]], ["AmmoBox02",[0,0,10]], ["AmmoBox03",[0,0,10]], ["Empty",[0,0,0]] ] The above would place the three named ammo boxes, 10 meters above their locations once the mission starts. At least this way you can position objects without compromising their behaviour in MP. But seen as mission makers appear to be reluctant to included addons with their missions, I just wondered if it was worth the hassle? Share this post Link to post Share on other sites
Junker 0 Posted May 27, 2007 have you tried spawning/creating the objects at a height just a suggestion Share this post Link to post Share on other sites
UNN 0 Posted May 27, 2007 That’s what the above does? Only you use the names you give the objects in the Editor rather than having to dig out the class names. As hard as it is to believe, addons can actually make the life of a mission editor easier Share this post Link to post Share on other sites
somethingcool 0 Posted May 28, 2007 @UNN you say to position the GameLogic itself would i use the standard GL1 setPos [getpos GL1 select 0, getpos GL1 select 1, (getpos GL1 select 2) +20] Because to me that still seems to spawn it on the ground floor?! I fancy placing an ammo box, a field hospital and an assortment of sandbags around one of the hotels on Sahrani (well "Hotel" placed from SickBoys editor addon) But obviously making it MP compatible is being a complete Swine! Any help would be most appreciated Share this post Link to post Share on other sites
UNN 0 Posted May 28, 2007 The problem is caused by the Roadway LOD's defined with in the Hotel. I've modified the script slightly, as the height of the Game Logics were also being affected. You have to be careful with multiple roadway LOD's. For example the Hotel has some parts with roadways and others parts without, so you may have to adjust your heights accordingly. Anyway here is the test mission I used, with the revised script. It just places the player and an Ammo box on the Hotel roof. Object_Pos_MP.Intro.zip Also notice how, compared to the player. You have to be much more exact, when setting the height of the Ammo box. Share this post Link to post Share on other sites
Henk 0 Posted May 29, 2007 Hi all, I've been trying to use the setpos command on vehicles: OnMapSingleClick "bmp setpos _pos"; After testing I can only use this on infantry and single seated vehicles, confirmed ones are the camel and the A-10. Any other vehicle that has more seats than one, full or empty, won't move. Could anybody else try to fiddle with this? I think we might have a bug there. edit: I've been using 1.07 beta with the small extra fix. Share this post Link to post Share on other sites
Taurus 20 Posted May 29, 2007 Well "join in the chant" http://www.flashpoint1985.com/cgi-bin....t=63323 Share this post Link to post Share on other sites
Big Dawg KS 6 Posted May 29, 2007 [moose]henk, you should always tell us whether you were testing it in MP with multiple clients or in SP. It really does matter. Edit: I just opened up the editor (v1.07 beta) and placed an empty abrams named tank. In the player's init field I wrote the following: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">onMapSingleClick "tank setPos _pos;" It worked perfectly fine, no problems encountered at all. The tank was placed at the position I clicked every time. That means you must be doing something different/wrong. Share this post Link to post Share on other sites
shadow 6 Posted May 29, 2007 Merged Setpos bug with existing thread. Share this post Link to post Share on other sites
Nutty_101 0 Posted May 30, 2007 If you guys are having issues there is a workaround that I figured out (Unless someone else did also). Just set the static objects init line. Then when the player loads it will process that. Example: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> _bldg = createvehicle ["Land_hospoda_mesto",[12231.96,17612.2,0],[],0,"FORM"]; _bldg setVehicleInit "this setdir 225;this setpos [12231.96,17612.2,0];"; Since the setpos and setdir don't seem to work correctly via MP this will. There is a delay however before this kicks in. So if they are looking right at it you can see it happen. Share this post Link to post Share on other sites
Taurus 20 Posted May 30, 2007 If you guys are having issues there is a workaround that I figured out (Unless someone else did also).Just set the static objects init line. Then when the player loads it will process that. Example: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> _bldg = createvehicle ["Land_hospoda_mesto",[12231.96,17612.2,0],[],0,"FORM"]; _bldg setVehicleInit "this setdir 225;this setpos [12231.96,17612.2,0];"; Since the setpos and setdir don't seem to work correctly via MP this will. There is a delay however before this kicks in. So if they are looking right at it you can see it happen. can somebody please update the wiki with the above "work around"? BIs please fix this thing in a service pack! Share this post Link to post Share on other sites
Nutty_101 0 Posted May 30, 2007 Bah, if there is something in the way the setpos is moving the stupid building around when used in the init line. I am going to cry, i want my own building setup in this base. WHAAAAAA!!!!! laugh Share this post Link to post Share on other sites
HitmanFF 6 Posted May 30, 2007 I've wanted to create a double row of sandbags (a row above another) in a map, which never worked due to the setpos bug. Based on Nutty_101's idea, I've made a small script that I use in the init line of the sandbags I want to elevate, and it works well in multiplayer. You just need to add<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">[this, 0.95] exec "setposz.sqs"in your object's init line in the mission editor, to get it elevated 0.95 units. the script: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_object = _this select 0 _height = _this select 1 _objecttype = typeOf _object _pos = getPos _object _dir = getDir _object _initline = format["this setDir %1; this setPos[%2, %3, (%4 + %5)];", _dir, _pos select 0, _pos select 1, _pos select 2, _height] deleteVehicle _object _newobj = createVehicle[_objecttype, [_pos select 0, _pos select 1, 0], [], 0, "FORM"] _newobj setVehicleInit _initline processInitCommands processInitCommands will immediately invoke the init line. With a slight bit of imagination this script can be extended to setting the direction as well... There's no visible delay involved btw, probably because processInitCommands is invoked straight away. Share this post Link to post Share on other sites
UNN 0 Posted May 31, 2007 Just a thought, but if your executing createVehicle on every client and server, everyone who JIP's. Won't that create multiple copies of the same object on all the clients and server? If it's doesn't lag then I guess it's not a problem, but might be worth considering. You might be able to get away with adding locality checks, so you only create them on the server. Share this post Link to post Share on other sites