Jump to content

Help with attachElements


Hunter567T

Recommended Posts

Posted

I have made a script that creates a andromada and a marker. Then it attaches them together they move but the place where the marker warps you to the other spot doesn't move. Any help please?

Commander of the CIT SWAT Team.

Posted
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.

Fresh Russian Server! Fresh every day=D

Posted

why you put that setElementData ?

edit:

Ahh! I think i got what he means!

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!

Multi theft auto tools - replace cars and peds, move your map or compile your Lua files online!

programista php rzeszów

Need free webhosting for your small site? PM me. Need help with portforwarding? PM me. Do not PM me asking for help with scripting.

Having problems with port forwarding? Send me pm, I can do whole thing for you using TeamViewer (already helped about 20 people, no worries)!

Posted

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.

Commander of the CIT SWAT Team.

Posted

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]

Multi theft auto tools - replace cars and peds, move your map or compile your Lua files online!

programista php rzeszów

Need free webhosting for your small site? PM me. Need help with portforwarding? PM me. Do not PM me asking for help with scripting.

Having problems with port forwarding? Send me pm, I can do whole thing for you using TeamViewer (already helped about 20 people, no worries)!

Posted
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.

Commander of the CIT SWAT Team.

Posted

I never tried that.

To me it seems to be a bug, but i'm not sure. Code seems right, but i didn't test it. I will try it when I'll find 15 minutes.

Multi theft auto tools - replace cars and peds, move your map or compile your Lua files online!

programista php rzeszów

Need free webhosting for your small site? PM me. Need help with portforwarding? PM me. Do not PM me asking for help with scripting.

Having problems with port forwarding? Send me pm, I can do whole thing for you using TeamViewer (already helped about 20 people, no worries)!

Posted
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

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...