Untitled conversation
- User
[ML] (error) coord_incar.lua: ...na Games Launcher\bin\arizona\moonloader\coord_incar.lua:8: attempt to index local 'targetPos' (a nil value) stack traceback: ...na Games Launcher\bin\arizona\moonloader\coord_incar.lua:8: in function 'moveSmoothly' ...na Games Launcher\bin\arizona\moonloader\coord_incar.lua:23: in function <...na Games Launcher\bin\arizona\moonloader\coord_incar.lua:20> [ML] (error) coord_incar.lua: Script died due to an error. (067A0E14)
local vec = require'vector3d' function lerp(a, b, t) return a + (b - a) * t end function moveSmoothly(currentPos, targetPos, speed, deltaTime) local t = speed * deltaTime currentPos.x = lerp(currentPos.x, targetPos.x, t) currentPos.y = lerp(currentPos.y, targetPos.y, t) currentPos.z = lerp(currentPos.z, targetPos.z, t) end local speed = 5 local deltaTime = 0.016 function main() while not isSampAvailable() do wait(0) end sampRegisterChatCommand('act', function() local currentPosition = vec(getCharCoordinates(PLAYER_PED)) local _, targetPosition = vec(getTargetBlipCoordinates()) moveSmoothly(currentPosition, targetPosition, speed, deltaTime) if math.abs(currentPosition.x - targetPosition.x) < 0.01 and math.abs(currentPosition.y - targetPosition.y) < 0.01 and math.abs(currentPosition.z - targetPosition.z) < 0.01 then print('Reached target position!') end end) while true do wait(0) end end - Assistant
- User
просто bool result, float posX, float posY, float posZ = getTargetBlipCoordinates(), с начала вызывает bool
- Assistant
Понял, ваша функция
getTargetBlipCoordinates()возвращает несколько значений, включая булевое значение, указывающее, есть ли целевая метка, и координаты, если они существуют. Давайте правильно распараллелим результаты этой функции, чтобы избежать проблемы с обращением к .