Jump to content

Help with attachElements


Hunter567T

Recommended Posts

I don't get it... How can place move where you warp? Show some code and try to explain in more detail.

maybe :

androm=createVehicle(592,x,y,z,rx,ry,rx)
             mark=createMarker (0.0.0.corona.10,255)
             AttachElements(androm,mark,0,0,0)
setElementData(mark, "mark")

----

IT,s only sketch!!!)

Edit by varez: Fixed typo in your script.

Link to comment

Ok here is the code. I want to make the marker attached to the andromada. But when i attach the marker only the marker moves and the markerhit place doesnt move.

local andromada = createVehicle ( 592, 1073.08, 3979.52, 2.59, 0, 0, 180 )
local goThere = createMarker( 1073.09, 3994.62, 1.60, 'arrow', 1, 0, 0, 255, 150 ) 
local comeBack = createMarker( 315.74, 1036.47, 1942.36, 'cylinder', 6, 0, 0, 255, 150 )   -- The markers and the Andromada
-- Attachment of the Marker to the Andromada
attachElements ( goThere, andromada, 0, -20, 0 )
 
function MarkerHit( hitPlayer, matchingDimension )
setElementInterior( hitPlayer, 9, 315.74, 1020.47, 1950.36 )                        -- Places the Player Inside The Andromada
end
addEventHandler( "onMarkerHit", goThere, MarkerHit )
 
function MarkerHit1( hitPlayer, matchingDimension ) 
local x,y,z = getElementPosition( andromada )
setElementPosition ( hitPlayer, andromada )      -- Places the Player just behind the Andromada -- needs working not finished
end
addEventHandler( "onMarkerHit", comeBack, MarkerHit1 )

Edit by varez: Changed code tags to lua tags. Please use lua tags next time.

Link to comment

dunno about your problem but this:

function MarkerHit( hitPlayer, matchingDimension )
setElementInterior( hitPlayer, 9, 315.74, 1020.47, 1950.36 )                        -- Places the Player Inside The Andromada
end

you arent checking what exactly hit marker. it could be another vehicle too - and you will warp that vehicle. Or any other element. use getElementType to check what hit marker. Checking if dimension is matching should be good too.

And:

Use [lua][/lua] tags instead of [code][/code]

Link to comment
He created vehicle, attached marker, but the market hit position stays the same - even when he drive his vehicle, moving marker position with vehicle. Show us your code Hunter567T!

Is there anyway to get the marker hit position to move with the marker? The marker moves when i drive but the marker hit position doesn't move.

Link to comment
Is there anyway to get the marker hit position to move with the marker? The marker moves when i drive but the marker hit position doesn't move.

no, there is no way, as I discovered long time ago :(https://forum.multitheftauto.com/viewtop ... 68#p301568

i reccomend to move this script client side and check the distance betwen andromada and the local player, as for:

setElementPosition ( hitPlayer, andromada )      -- Places the Player just behind the Andromada -- needs working not finished

use this client side function: https://wiki.multitheftauto.com/wiki/GetElementMatrix

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...