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.