Jump to content
Sign in to follow this  
mattxr

Sep Pos Height

Recommended Posts

How can i get this command to work in a script?

In Game i use:

this setpos [getpos this select 0, getpos this select 1, (getpos this select 2) +1];

and it works

In A Script i want to use:

f11 setpos [getpos this select 0, getpos this select 1, (getpos this select 2) +1];

but i get an error when the script runs? anyhelp.

Share this post


Link to post
Share on other sites

havent got game running but i am sure i had probs if i did not put

[( getpos this select 0),(getpos this select 1),blah]

in essence used th ( ) for every select

Share this post


Link to post
Share on other sites

not even

_x = (getpos f11 select 0)

_y = ( getpos f11 select 1)

_z= (getpos f11 select 2)

_z = _z +1

f11 setpos [_x,_y,_z]

?

sorry i cant start game i got some big vid conversion going on.

maybe first version dont work cause ya didnt tell it what this is.

try

f11 setpos [(getpos f11 select 0), (getpos f11 select 1), (getpos f11 select 2) +1];

Share this post


Link to post
Share on other sites

thatll take too long with 30 so plus objects.

Share this post


Link to post
Share on other sites

When running it from a script, you cant use this.

You would have to have something like this, in each objects init field. That calls a single generic script.

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">Script=[This] ExecVM "Script.sqf"

Script.sqf would then contain:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_Obj=_This Select 0;

_Pos=GetPos _Obj;

_Pos Set [2,(_Pos Select 2)+1];

_Obj setpos _Pos;

I say something like this, it's not really clear what you actualy want to do. So I'm making a guess, based on your two examples.

Share this post


Link to post
Share on other sites

Setpos doesnt seem to work in Multiplayer for me. Whenever i try to put sandbags one on the top of another [typing in its initation : this setpos [(getpos this select 0), (getpos this select 1), 2], they work only on a local server (visible 2 metres above the surface). However people who join the server will see the same sandbags lying on the ground... Any work around?

Share this post


Link to post
Share on other sites

SetPos didn´t work @ MP! Currently...

On which position you´ll set this ´vehicle? On intself?

Try:

F11 setpos [(getpos F11 select 0),(getpos F11 select 1),10]

Regards,

Mr-Murray

Share this post


Link to post
Share on other sites

I didn't get what you wrote.. Anyway i want to put 3 sandbags, on on the another, height of a sandbag is aprox. 1 metre... When playing SP or MP as a host it works well but the client doesnt see the stuff...

Share this post


Link to post
Share on other sites

haven't tried it to see if will help your issue, but I ALWAYS put a game logic named server in my MP missions.  It will solve many problems like you describe, but nobody seems to know why!  That is the 1st thing I would try.

Share this post


Link to post
Share on other sites

@Matt:

Quote[/b] ]In A Script i want to use:

f11 setpos [getpos this select 0, getpos this select 1, (getpos this select 2) +1];

but i get an error when the script runs? anyhelp.

These commands definitely work in scripts in single player. I have used them. What may be your problem is "this" is only recognized in object initialization fields and waypoints as the current object. In a script, you need to pass in the object name, or reference the object name directly (what you named the object in the editor). You say you want to do this for many objects, so pass in an array of object names, and loop through the array, setposing each object.

Also, there is a new command that simplifies the process of finding a position relative to an object: <a href="http://community.bistudio.com/wiki/modelToWorld" target="_blank">

modelToWorld</a>. Example usage:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

; following command will move the tank object to a position

; relative to the man object of two meters in front, one meter

; to the right, and 3 meters above ground.

tank setpos (man modelToWorld [2, 1, 3 ]);

; following command wil have man1 move to a position that is

; one meter to the left, and two meters behind man2's position.

man1 domove (man2 modelToWorld [-1, -2, 0 ]);

The modelToWorld command eliminates the need to "getpos this select ..." to get each coordinate.

Regarding setpos not working in multiplayer, I have no idea, as I am not set up to test that.

Share this post


Link to post
Share on other sites

Examples:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">f11 setpos [getpos f11 select 0, getpos f11 select 1, (getpos f11 select 2) +1];

Or as the gentleman above me states, put the objects in array and use a ForEach loop:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">private ["_objs","_p"];

_objs=[f11,f12,f13,f14,g1,h15];

{

    _p=getpos _x;

   _x setpos [_p select 0,_p select 1,(_p select 2)+1];

} forEach _objs;

or if you want to specify different heights, [object,height]:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">private ["_objs","_u","_p"];

_objs=[[f11,1],[f12,5],[f13,3],[f14,2],[g1,1],[h15,1]];

{

   _u=_x select 0;

   _p=getpos _u;

   _u setpos [_p select 0,_p select 1,(_p select 2)+_x select 1];

} forEach _objs;

Quote[/b] ]...The modelToWorld...
AWESOME... taking a look asap wink_o.gif

Share this post


Link to post
Share on other sites

One thing I just found out about static objects is that they'll only setpos for the client that gives the command. In other words, you setpos a static object on your client, and it doesn't change for anyone else.

Suma told me it was for optimization. Gonna be a pain to script for RTS though. Creating a base...ugh.

Share this post


Link to post
Share on other sites

Hope we will get back our global setpos command. Otherwise I will go crazy.

Share this post


Link to post
Share on other sites
Hope we will get back our global setpos command. Otherwise I will go crazy.

It still is global, but not for objects with simulation="house"... sad_o.gif

Share this post


Link to post
Share on other sites

You know what I mean. I want that it works again like in good ol' OFP inlove.gif

Share this post


Link to post
Share on other sites

I can see why they did it, though.  That's a lot less movement the netcode has to worry about.  I think it could be worked around in an addon, though.  You could probably give it a different simulation type but remove any driver/cargo positions, etc and also put destructType as "House" or whatever that type is to get the interesting building destruction effects.

The destruction sequence for buildings is actually a clever illusion using setPos, by having the destroyed buildings drop about 38 meters below the ground.

For the time being, I think it's also as easy to have a client-side loop which looks for a public string.  This string would in essence be a script and could have multiple uses.  In this case, the builder client could publicVariable a script to set the position and direction of the building.

The direction is the most problematical.  If only that were global.  Then I wouldn't mess with sending the other info to clients.  In OFP RTS I had the buildings "grow" from the ground.

MP issues strike again!

Share this post


Link to post
Share on other sites

If I create a config and change the simulation type to something else for an object what would you recomend we set it to.

Share this post


Link to post
Share on other sites

did some more work on this.

OMG this is going to be a nightmare for some unless I'm missing something simple.

What I did:-

- Created an init.sqs

- It moved the objects arround instead of doing it in the mission editor

- Made it print out a hint message

All clients get the hint message but no object moves so I presume not even on the server.

What this means is that any static object (bar them simulating house) will not be able to move via the setPos command. I bring it to your attention cos well that's just lame.

Any recomendations on fixing this? I could change the simulation by making a new addon with a new a sub class np chaning the simulation np. However that's kind of lame because I don't know what simulation to use. This needs resolving because many will want to do object placements for mpmissions I'm sure in the near future and the problem will keep popping up. Understand the net code lag but I think we should have the option.

Wonder if the setPosASL would work as the wiki says

Multiplayer: Behaviour unknown.

Good O crazy_o.gif

Share this post


Link to post
Share on other sites

This is really terrible. I love putting nice details in my map and this sort of ruins it. :/ No way to put ammo crates in the second story rooms of houses, no way to place radios on top of crates or sandbags... this needs to be ammended somehow.

Share this post


Link to post
Share on other sites

The work arround I came up with in the end is to make a subclass of StaticWeapon. This works well and the objects can be animated and work as nomal but with mp setPos possibilites. I still feel this n eeds looking at.

The StaticWeapon uses the simulation type 'tank' for those interested.

Share this post


Link to post
Share on other sites

Isn't it possible to make a trigger that is activated by the players, and then run a setPosition script for each of the units with an

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">if(isPlayer _unit)then{

sandbag1 setPos [getpos sandbag1 select 0,getpos sandbag1 select 1,(getpos sandbag1 select 2) + 10];

};

I dont have access to a dedicated server so I haven't tested in in MP

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  

×