Jump to content
Sign in to follow this  
Raptor 2101

Problem with setpos

Recommended Posts

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

_add=_this select 1

_time = _this select 2

_ziel = _this select 3

_speed = _this select 4

_Granaten="SmokeShell" camcreate getpos _unit

_time= 1 / _time

_xs = (velocity _unit) select 0

_ys = (velocity _unit) select 1

#drehung

_x=(getPos _unit) select 0 +_xs

_y=(getPos _unit) select 1 +_ys

_z=(getPos _unit) select 2

_unit setPos[_x,_y,_z]

_x1 = (getPos _unit) select 0

_y1 = (getPos _unit) select 1

_z1 = (getPos _unit) select 2

_Granaten setPos [_x1, _y1, _z1+30]

_unit setDir ((getDir _unit) + _add)

~(_time)

goto "drehung"

Exit

this code give this error massage "'_unit setPos[_x,_y,_z]'|x| Fehler Typer jeder, zahl erwartet" and i dont understand why. i give the operator setpos legal numbers to operate

have anyone a idia

Share this post


Link to post
Share on other sites
Quote[/b] ]Fehler Typer jeder, zahl erwartet

If you translate that I might know whats going on.

Share this post


Link to post
Share on other sites

I´ve seen something on ofpec a setpos script maybe you should download that script, and that script on ofpec is working because i use it myself with no problems at all. smile_o.gif

Share this post


Link to post
Share on other sites

Error : Error Typer all: Number expected

@editing man: i know how setpos works (from the referens) but i dont understand the massage evere values i give are numbers i dont know who the programm get char values

Share this post


Link to post
Share on other sites

Try changing:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_x=(getPos _unit) select 0 +_xs

_y=(getPos _unit) select 1 +_ys

To:

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

_x=(getPos _unit select 0) +_xs

_y=(getPos _unit select 1) +_ys

You may be telling it to select an element that does not exist?

Share this post


Link to post
Share on other sites

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_x=(getPos _unit) select 0 +_xs

The above code will give me an error everytime in OFP with a Division by zero, error message?

If _xs = 10 then the code would translate to:

_x=(getpos _unit) select (0 + 10)

As GetPos only returns 3 elements, it will fall over trying to find element 10.

Because the line where you initialise _x fails, your code goes on to call:

Quote[/b] ]

_unit setPos[_x,_y,_z]

So you get the "Type all: Number expected" error message because _x un-initialised is of type any. And SetPos expects  numbers.

If you added:

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

#drehung

_x=0

_y=0

_x=(getPos _unit) select 0 +_xs

_y=(getPos _unit) select 1 +_ys

And then run your code, you will get the "Division by zero" error message as mentioned above.

You have to be careful, OFP only displays the last error message.

Share this post


Link to post
Share on other sites
Guest jacobaby
[code_x=(getPos _unit select 0) +_xs

_y=(getPos _unit select 1) +_ys

_z=(getPos _unit select 2)

_unit setPos[_x,_y,_z]

Brackets in the wrong places

fixed above

TJ

Share this post


Link to post
Share on other sites

thanks to all it works

now a other it is posibel to let a flying helicopter smoke?

i have found no way

an with camecreate "SmokeShell" that works with groudn units but, if you try it with a flying unit the granate fell down

Share this post


Link to post
Share on other sites

Use the drop command to create your own kind of smoke that you can attach to any object.

Here you can find a good tutorial and examples to get into it:

Vektorbosons homepage

Share this post


Link to post
Share on other sites

And at the Editing Centre, doolittles "Vehicle Respawn With Smoke"....use the smoke script

Gnat

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  

×