function onfoot() repeat if isKeyDown(1) then pow = pow + 0.001 printStringNow("~b~…
- User
function onfoot() repeat if isKeyDown(1) then pow = pow + 0.001 printStringNow("
bspeed +"..pow, 1000) elseif isKeyDown(2) then pow = pow - 0.001 if pow < 0 then pow = 0 end printStringNow("bspeed -"..pow, 1000) end local x, y, z = getCharCoordinates(playerPed) local x1, y1, z1 = getActiveCameraCoordinates() local head = math.rad(getHeadingFromVector2d(x-x1, y-y1)) if isKeyDown(87) then x = x-math.sin(-head+3.14)*pow y = y-math.cos(-head+3.14)*pow elseif isKeyDown(83) then x = x+math.sin(-head+3.14)*pow y = y+math.cos(-head+3.14)*pow end if isKeyDown(16) then z = z-pow/2.2 elseif isKeyDown(32) then z = z+pow/2.2 end local sync = samp_create_sync_data("player") sync.position = {f(x),f(y),f(z-1)} sync.moveSpeed = {f(0),f(0),f(0)} local x2,y2,z2 = getCharCoordinates(playerPed) if x ~= x2 or y ~= y2 or z ~= z2 then sync.moveSpeed = {f(0.09),f(0.091),f(0.071)} end sync.send() setCharHeading(playerPed, math.deg(head)) setCharCoordinates(playerPed, x, y, z-1) until MOP endдобавь ещо на a и d перемещение в бока
- Assistant
Чтобы добавить возможность перемещения в стороны (влево и вправо) с помощью клавиш и , необходимо внести изменения в код, чтобы учесть эти клавиши. В вашем коде уже есть обработка для (вперёд) и (назад).
- User
оно движется не в стороны. измени только этот код
-- Движение в стороны if isKeyDown(65) then -- A key x = x - math.cos(-head) * pow -- Движение влево y = y - math.sin(-head) * pow elseif isKeyDown(68) then -- D key x = x + math.cos(-head) * pow -- Движение вправо y = y + math.sin(-head) * pow endчтобы двигало ровно в стороны - Assistant
- User
да, но теперь оно движет вперед и назад
- Assistant