xXMADEXx Posted March 30, 2013 Share Posted March 30, 2013 Hello guys, i made this script, but for some reason "attachElements" is failing to work.... ------------------------------- -- Create attached drug object ------------------------------- newObject = {} updateNewObjectIntAndDim = {} arrowMarker = {} addEvent("onPlayerPickupDrugs",true) addEventHandler("onPlayerPickupDrugs",root, function () p = source local x,y,z = getElementPosition(p) newObject[p] = createObject(1279,x,y,z) attachElements(newObject[p],source,1,0,0) -- Here updateNewObjectIntAndDim[p] = setTimer( function () local x,y,z = getElementPosition(p) setElementInterior(newObject[p],getElementInterior(p)) setElementDimension(newObject[p],getElementDimension(p)) setElementPosition(newObject[p],x+1,y,z) -- I had to use this shitty code, because attachElements wouldn't work D: end, 500, 0 ) addEventHandler("onVehicleEnter",root, function (pl) if (pl==p) then if (isElement(newObject[p])) then local car = source arrowMarker[p] = createMarker(0,0,0,"arrow",2,120,0,255,100,p) attachElements(arrowMarker[p],car,0,0,5) destroyElement(newObject[p]) if (isTimer(updateNewObjectIntAndDim[p])) then killTimer(updateNewObjectIntAndDim[p]) end addEventHandler("onVehicleExplode",car, function () if (isElement(arrowMarker[p])) then destroyElement(arrowMarker[p]) outputChatBox("The car containing your drugs has exploded.",p,255,0,0) end end ) end end end ) end ) Link to comment
Wrecker Posted March 30, 2013 Share Posted March 30, 2013 You're supposed to use an index number here: newObject[ index number here ], I think..I don't understand why you're using userdatas edit: nvm I see why you're using userdatas now, but it's preferable to use table constructors in my opinion nObjects = #newObject --total number of elements in the array newObject[nObjects + 1] = createObject(1279,x,y,z) Link to comment
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