CheiN Posted November 24, 2013 Posted November 24, 2013 Hello, i made this script and i don't know why this doesn't detach passed 2 seconds could some one help me correcting me? gMe = getLocalPlayer() function gravity() marker1 = createMarker (6009, 392, 10.800000190735, "corona", 2, 0, 0, 0, 0) object = createObject (1681, 6009.2998046875, 396.39999389648, 16.10000038147) end function MarkerHit ( hitPlayer, matchingDimension ) vehicle = getPedOccupiedVehicle ( hitPlayer ) if hitPlayer ~= gMe then return end if source == marker1 then attachElements (vehicle, object, 0, 0, -5.5, 0, 0, 0) setTimer(function () detachElements (object) end,2000,1) moveObject (object, 2000, 6009.2998046875, 490, 16.10000038147) end end addEventHandler( "onClientResourceStart", getResourceRootElement(getThisResource()), gravity ) addEventHandler ( "onClientMarkerHit", getRootElement(), MarkerHit )
glowdemon1 Posted November 24, 2013 Posted November 24, 2013 Not sure if this might be the problem but "object" is already an element type, so I4d try giving it another name.
Callum Posted November 24, 2013 Posted November 24, 2013 You need to pass the object argument to the timer: setTimer(function (obj) detachElements (obj) end,2000,1,object)
Moderators IIYAMA Posted November 24, 2013 Moderators Posted November 24, 2013 You need to pass the object argument to the timer: setTimer(function (obj) detachElements (obj) end,2000,1,object) nope, only required when you call a function outside the function/if block. Try this: gMe = getLocalPlayer() function gravity() marker1 = createMarker (6009, 392, 10.800000190735, "corona", 2, 0, 0, 0, 0) object = createObject (1681, 6009.2998046875, 396.39999389648, 16.10000038147) end function MarkerHit ( hitPlayer, matchingDimension ) local vehicle = getPedOccupiedVehicle ( hitPlayer ) if hitPlayer ~= gMe then return end if source == marker1 then attachElements (vehicle, object, 0, 0, -5.5, 0, 0, 0) moveObject (object, 1999, 6009.2998046875, 490, 16.10000038147) setTimer(function () if isElement(vehicle) then detachElements (vehicle) -- you detach the elements from the object. So it should be the vehicle. end end,2000,1) end end addEventHandler( "onClientResourceStart", resourceRoot, gravity ) addEventHandler ( "onClientMarkerHit", getRootElement(), MarkerHit ) Required Arguments theElement: The element to be detached (the "child") vehicle = child. object = mother. (mother holds the child.)
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now