Jump to content

[HELP]Re-attaching to moving object


Tombaa

Recommended Posts

Posted (edited)

I have been trying to use this script:

viewtopic.php?f=91&t=32662&p=344109&hilit=Attach#p344109

But the problem is, that when I once get it to attach, and detach after that, it wont attach to it anymore, before I restart script.

  
function attach ( hitElement ) 
    if ( getElementType( hitElement ) == "vehicle" ) then 
        attachElements ( arrow1, cH, -1417 - hullx, 531 - hully, 18.5 - hullz ) 
        attachElements ( hitElement, arrow1 ) 
    do 
    end 
end 
addEventHandler ( "onMarkerHit", theMarker, attach ) 
      
function detach ( thePlayer, commandName ) 
    local pVehicle = getPedOccupiedVehicle( thePlayer ) 
    detachElements ( pVehicle ) 
 end 
addCommandHandler ( "detach", detach ) 
  

That is the code, could anyone please tell me, if there is some kind of loop thing or something, which I can use there.

Thanks in advance

Tombaa

Edited by Guest
Posted

The cH is a carrier, that I have attached the marker and the arrow to. The full script is nothing more than creating the carrier objects, and attaching them to each other.

Posted

I just noticed, that it actually works, when the carrier is still, but when you move the carrier to somewhere else, than detach and try to attach again, than it wont attach again. If its in the same place as stated in the script, it does work.

How to fix it so that it attached everywhere? :S

Posted

i think both elements should be streamed in before the attaching.

use

  
setElementStreamable(arrow1,flase) 
setElementStreamable(hitElement,flase) 
  

Posted

Yes, that one.

i have managed to find out the real problem i have. it is that the marker doesnt really attach to the carrier, so it doesnt move when the carrier does...

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