par4doxon Posted August 23, 2013 Share Posted August 23, 2013 I want to close / open a door object with interpolateBetween. Here is the code: local adminGateArea51Right = createObject(2929,215.89999389648,1875.4000244141,13.89999961853, 0, 0, 0) function closeGates() startTime = getTickCount() endTime = startTime + 2000 closeGatesInter() end function closeGatesInter() local now = getTickCount() local elapsedTime = now - startTime local duration = endTime - startTime local progress = elapsedTime / duration while progress <= 1 do now = getTickCount() elapsedTime = now - startTime duration = endTime - startTime progress = elapsedTime / duration local x, y, z = interpolateBetween(208.5, 1875.4000244141, 13.89999961853, 211.89999389648, 1875.4000244141, 13.89999961853, progress, "OutBounce") setElementPosition(adminGateArea51Left, x, y, z) end end addCommandHandler("close", closeGates) This code should close the left door, but the only think it does, is making heavy lags, and the door is lagging as well, prolly because of the while loop. I admit, using a while loop isnt the best idea, but I didnt have better idea. Can somebody help me correct this? Because I know, in client-side I can use onClientRender, but I dont know what to use in server-side, for this problem. Thanks in advance. Link to comment
EstrategiaGTA Posted August 25, 2013 Share Posted August 25, 2013 You should use: moveObject Instead 'setElementPosition'. Link to comment
WASSIm. Posted August 25, 2013 Share Posted August 25, 2013 read arguments moveObject and see easing this exmple: local x,y,z = 2096.3, 1721, 12.7 local easing = "OutBounce" local time = 2000 local gate = createObject(980, x,y,z, 0, 0, 63) local marker = createMarker(x,y,z, "cylinder", 12, 0, 0, 0, 0) function moveGate(hitPlayer, matchingDimension) moveObject(gate, time, x+4.9, y+9.6, z, 0, 0, 0, easing) end addEventHandler("onMarkerHit", marker, moveGate) function moveBack() moveObject(gate, time, x, y, z, 0, 0, 0, easing) end addEventHandler("onMarkerLeave", marker, moveBack) 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