# line move

## Recommended Posts

Solved

Edited by Guest

He used dxDrawMaterialLine3D with special calculations I guess.

Solved

Edited by Guest

Think about it for a while, do some testing. Scripting and programming is a lot about trial and error, in fact, it's mostly trial and error. Can't expect to get everything served on a silver platter.

Issue 1: You need to draw in 3D space.

Issue 2: You need it to follow the vehicle.

Solution: Get the vehicle's position in 3D Space - getElementPosition.

Basically what you want to do is to get the vehicle's position and store it in a table. Then you draw whatever is stored inside this table. And to get the effect where it's removed after a certain distance you can either do by number of items in the table and remove the first item every time a new one is inserted. Or by time, which might be a bit more complicated.

1. Get vehicle position.

2. Store vehicle position in a table.

3. Loop through all items in the table, draw them.

4. Remove first item in the table if you want to.

You'll also probably want to use onClientPreRender instead of onClientRender. Just give it some time, read through the MTA Wiki examples and I'm sure you'll figure something out.

You shouldn't need any fancy trigonometry calculations unless you want to go over the top.

Solved

Edited by Guest

Aolved

Edited by Guest
• Moderators
```local myTable = {} -- Create an empty table.
```

```local amountOfItems = #myTable -- # < Will return the highest position in this table.
-- When the table is empty it will be 0.
-- When there is 1 item in it, it will be most likely 1, but not always when the array/table isn't clean.
```

What is the array?

```local positionOfLastItem = amountOfItems -- This is most likely the position of the last item in the table.
```

```local dataThatIsInside = {345,57567,5777} -- x,y,z This is what you are going to save.
```

```local nextItemPosition = positionOfLastItem +1 -- Get the next position in the table, where you want to store your item.
```

```myTable[nextItemPosition] = dataThatIsInside -- Saving in the Table.
```

The table will look like this at the end: (in the lua memory)

```myTable = {
{345,57567,5777}
}
```

There are also table.insert and table.remove. But those have more functionality. You should first understand the array before you start using those.

## Create an account

Register a new account