Помогите найти проблему в коде

HanzoPonPon

Новичок
Автор темы
6
1
Версия MoonLoader
Другое
Почему-то трейсер обрывается на 142-160 метрах, хотя в коде расстояние 400 метров, пробовал менять прорисовку, не помогает, еще заметил что обрывается как раз на видимости радара, через худ эдитор увеличивал его видимость, тож не помогает, вообще не знаю в чем дело. Код будет ниже, знающие люди, помогите пожалуйста🙏
1699069794066.png

Lua:
script_name('By Yarick')
script_version('v1.1')
script_author('vk-ne skazhu')
local sp = require('lib.samp.events')
local status = false
local ogPresent = 0
local cheatcode = "PL" -- Читкод
font = renderCreateFont("Century Gothic", 9, 5)
local globalX, globalY, globalZ
local t
local distErr = false
local presentIcon = {}
local timer = 500 -- Задержка
local reverse = {}
local iter = 1
local num = 1
local presentIds = {}
local presentCoords = {}
function main()
    repeat wait(0) until isSampAvailable()
    sampRegisterChatCommand('present', function()
        status = not status
        if status then
            sampAddChatMessage("{00FF00}[Cyka]Скрипт включён.", -1)
        else
            sampAddChatMessage("{00FF00}[Cyka]Скрипт выключен.", -1)
        end
    end)
    while true do wait(0)
    if status then
    local px, py, pz = getCharCoordinates(PLAYER_PED)
    for i = 1, num do
        if presentIds[i] ~= 0 and presentIds[i] ~= nil then
            if isPointOnScreen(presentCoords[i].x, presentCoords[i].y, presentCoords[i].z, 3.0) then
            xp, yp, zp = getCharCoordinates(PLAYER_PED)
            x1, y2 = convert3DCoordsToScreen(presentCoords[i].x, presentCoords[i].y, presentCoords[i].z)
            p3, p4 = convert3DCoordsToScreen(xp, yp, zp)
            distance = string.format("%.0f", getDistanceBetweenCoords3d(presentCoords[i].x, presentCoords[i].y, presentCoords[i].z, xp, yp, zp))
            renderDrawLine(x1, y2, p3, p4, 1.1, 0xFFFFE700)
            renderFontDrawText(font, "{FFE700}Тыква ["..distance.."]", x1, y2, -1)
            end
        end
    end
    if testCheat(cheatcode) then     
        lua_thread.create(tpToCords)
    end
    end
    end
    wait(-1)
end
function sp.onCreatePickup(id,model,pickupType,pos)   
    if pickupType == 19 and id ~= ogPresent then
        ogPresent = id
        presentIds[num] = id
        presentCoords[num] = pos
        distanceToPresent(pos.x, pos.y, pos.z)
    end
end
function sp.onDestroyPickup(id)
for i = 1, num do
    if id == presentIds[i] then
    presentIds[i] = 0
    presentCoords[i] = 0
    removeBlip(presentIcon[i])
    presentIcon[i] = 0
    ogPresent = 0
    for j = i, num - 1 do
        presentIds[j] = presentIds[j + 1]
        presentCoords[j] = presentCoords[j + 1]
        presentIcon[j] = presentIcon[j + 1]
    end
    num = num - 1
    end
end


end
function distanceToPresent(x, y, z)
    if status then
    local px, py, pz = getCharCoordinates(PLAYER_PED)
    local distance = math.floor(getDistanceBetweenCoords3d(x,y,z,px,py,pz))
    sampAddChatMessage("{00FF00}[PresentFinder]Был найден подарок в {FFFF00}"..distance.. "{00FF00} метрах от вас."..cheatcode.. " для телепорта к нему.", -1)   
    presentIcon[num] = addSpriteBlipForCoord(x, y, z, 56)
    num = num + 1
    end
end
function tpToCords()   
    local x1, y1, z1 = getCharCoordinates(PLAYER_PED)
    local minDist = 400
    local minCoord = 1
    for i = 1, num do
    if presentIds[i] ~= 0 and presentIds[i] ~= nil then
        distanceCheck = math.floor(getDistanceBetweenCoords3d(presentCoords[i].x, presentCoords[i].y, presentCoords[i].z, x1, y1, z1))
        if distanceCheck < minDist then
            minDist = distanceCheck
            minCoord = i
        end
    end
    end
    if minDist ~= 400 then
    sampAddChatMessage("{00FF00}[PresentFinder]Начинаем телепорт.", -1)
    local x2, y2, z2
    x2 = presentCoords[minCoord].x
    y2 = presentCoords[minCoord].y
    z2 = presentCoords[minCoord].z
    distErr = false
    while x1 ~= x2 and y1 ~= y2 and z1 ~= z2 do
    local distance = math.floor(getDistanceBetweenCoords3d(x1,y1,z1,x2,y2,z2))
    if distance < 50 then
    setCharCoordinates(PLAYER_PED,x2,y2,z2)
    reverse[iter] = x1
    reverse[iter + 1] = y1
    reverse[iter + 2] = z1
    iter = iter + 3
    wait(timer)
    break
    elseif distance > 393 then
    sampAddChatMessage("{00FF00}[PresentFinder]Телепорт невозможен. Дистанция больше 393м.", -1)
    distErr = true
    break
    
    elseif distance == 50 then
    t = distance / 25
    
    elseif distance <= 99 and distance > 50 then
    t = distance / 50   
    
    elseif distance <= 148 and distance > 99  then
    t = distance / 99   
    
    elseif distance <= 197 and distance > 148 then
    t = distance / 148
    
    elseif distance <= 246 and distance > 197 then
    t = distance / 197
    
    elseif distance <= 295 and distance > 246 then
    t = distance / 246
    
    elseif distance <= 344 and distance > 295 then
    t = distance / 295
    
    else
    t = distance / 344
    end
    
    t = 1 -(1 / t)
    reverse[iter] = x1
    reverse[iter + 1] = y1
    reverse[iter + 2] = z1
    iter = iter + 3
    x1 = (x2 - x1) * t + x1
    y1 = (y2 - y1) * t + y1
    z1 = (z2 - z1) * t + z1
    setCharCoordinates(PLAYER_PED,x1,y1,z1)
    wait(timer)
    end
    if not distErr then
    iter = iter - 3
    coordsReverse()      --
    end
    else
        sampAddChatMessage("{00FF00}[PresentFinder]Нет подарков поблизости.", -1)
    end
end
function coordsReverse()
    while true do
    local curX, curY, curZ
    curX = reverse[iter]
    curY = reverse[iter + 1]
    curZ = reverse[iter + 2]
    if(curX == reverse[1] and curY == reverse[2] and curZ == reverse[3]) then
        setCharCoordinates(PLAYER_PED,curX,curY,curZ)
        reverse[iter + 1] = 0
        reverse[iter + 2] = 0
        reverse[iter ] = 0
        break
    elseif(iter <= 0) then
        break
    end
    reverse[iter + 1] = 0
    reverse[iter + 2] = 0
    reverse[iter ] = 0
    iter = iter - 3
    setCharCoordinates(PLAYER_PED,curX,curY,curZ)
    wait(timer)
    end
    iter = 1
end
 
  • Ха-ха
Реакции: genius.company

genius.company

Известный
599
272
Почему-то трейсер обрывается на 142-160 метрах, хотя в коде расстояние 400 метров, пробовал менять прорисовку, не помогает, еще заметил что обрывается как раз на видимости радара, через худ эдитор увеличивал его видимость, тож не помогает, вообще не знаю в чем дело. Код будет ниже, знающие люди, помогите пожалуйста🙏
Посмотреть вложение 220066
Lua:
script_name('By Yarick')
script_version('v1.1')
script_author('vk-ne skazhu')
local sp = require('lib.samp.events')
local status = false
local ogPresent = 0
local cheatcode = "PL" -- Читкод
font = renderCreateFont("Century Gothic", 9, 5)
local globalX, globalY, globalZ
local t
local distErr = false
local presentIcon = {}
local timer = 500 -- Задержка
local reverse = {}
local iter = 1
local num = 1
local presentIds = {}
local presentCoords = {}
function main()
    repeat wait(0) until isSampAvailable()
    sampRegisterChatCommand('present', function()
        status = not status
        if status then
            sampAddChatMessage("{00FF00}[Cyka]Скрипт включён.", -1)
        else
            sampAddChatMessage("{00FF00}[Cyka]Скрипт выключен.", -1)
        end
    end)
    while true do wait(0)
    if status then
    local px, py, pz = getCharCoordinates(PLAYER_PED)
    for i = 1, num do
        if presentIds[i] ~= 0 and presentIds[i] ~= nil then
            if isPointOnScreen(presentCoords[i].x, presentCoords[i].y, presentCoords[i].z, 3.0) then
            xp, yp, zp = getCharCoordinates(PLAYER_PED)
            x1, y2 = convert3DCoordsToScreen(presentCoords[i].x, presentCoords[i].y, presentCoords[i].z)
            p3, p4 = convert3DCoordsToScreen(xp, yp, zp)
            distance = string.format("%.0f", getDistanceBetweenCoords3d(presentCoords[i].x, presentCoords[i].y, presentCoords[i].z, xp, yp, zp))
            renderDrawLine(x1, y2, p3, p4, 1.1, 0xFFFFE700)
            renderFontDrawText(font, "{FFE700}Тыква ["..distance.."]", x1, y2, -1)
            end
        end
    end
    if testCheat(cheatcode) then    
        lua_thread.create(tpToCords)
    end
    end
    end
    wait(-1)
end
function sp.onCreatePickup(id,model,pickupType,pos)  
    if pickupType == 19 and id ~= ogPresent then
        ogPresent = id
        presentIds[num] = id
        presentCoords[num] = pos
        distanceToPresent(pos.x, pos.y, pos.z)
    end
end
function sp.onDestroyPickup(id)
for i = 1, num do
    if id == presentIds[i] then
    presentIds[i] = 0
    presentCoords[i] = 0
    removeBlip(presentIcon[i])
    presentIcon[i] = 0
    ogPresent = 0
    for j = i, num - 1 do
        presentIds[j] = presentIds[j + 1]
        presentCoords[j] = presentCoords[j + 1]
        presentIcon[j] = presentIcon[j + 1]
    end
    num = num - 1
    end
end


end
function distanceToPresent(x, y, z)
    if status then
    local px, py, pz = getCharCoordinates(PLAYER_PED)
    local distance = math.floor(getDistanceBetweenCoords3d(x,y,z,px,py,pz))
    sampAddChatMessage("{00FF00}[PresentFinder]Был найден подарок в {FFFF00}"..distance.. "{00FF00} метрах от вас."..cheatcode.. " для телепорта к нему.", -1)  
    presentIcon[num] = addSpriteBlipForCoord(x, y, z, 56)
    num = num + 1
    end
end
function tpToCords()  
    local x1, y1, z1 = getCharCoordinates(PLAYER_PED)
    local minDist = 400
    local minCoord = 1
    for i = 1, num do
    if presentIds[i] ~= 0 and presentIds[i] ~= nil then
        distanceCheck = math.floor(getDistanceBetweenCoords3d(presentCoords[i].x, presentCoords[i].y, presentCoords[i].z, x1, y1, z1))
        if distanceCheck < minDist then
            minDist = distanceCheck
            minCoord = i
        end
    end
    end
    if minDist ~= 400 then
    sampAddChatMessage("{00FF00}[PresentFinder]Начинаем телепорт.", -1)
    local x2, y2, z2
    x2 = presentCoords[minCoord].x
    y2 = presentCoords[minCoord].y
    z2 = presentCoords[minCoord].z
    distErr = false
    while x1 ~= x2 and y1 ~= y2 and z1 ~= z2 do
    local distance = math.floor(getDistanceBetweenCoords3d(x1,y1,z1,x2,y2,z2))
    if distance < 50 then
    setCharCoordinates(PLAYER_PED,x2,y2,z2)
    reverse[iter] = x1
    reverse[iter + 1] = y1
    reverse[iter + 2] = z1
    iter = iter + 3
    wait(timer)
    break
    elseif distance > 393 then
    sampAddChatMessage("{00FF00}[PresentFinder]Телепорт невозможен. Дистанция больше 393м.", -1)
    distErr = true
    break
   
    elseif distance == 50 then
    t = distance / 25
   
    elseif distance <= 99 and distance > 50 then
    t = distance / 50  
   
    elseif distance <= 148 and distance > 99  then
    t = distance / 99  
   
    elseif distance <= 197 and distance > 148 then
    t = distance / 148
   
    elseif distance <= 246 and distance > 197 then
    t = distance / 197
   
    elseif distance <= 295 and distance > 246 then
    t = distance / 246
   
    elseif distance <= 344 and distance > 295 then
    t = distance / 295
   
    else
    t = distance / 344
    end
   
    t = 1 -(1 / t)
    reverse[iter] = x1
    reverse[iter + 1] = y1
    reverse[iter + 2] = z1
    iter = iter + 3
    x1 = (x2 - x1) * t + x1
    y1 = (y2 - y1) * t + y1
    z1 = (z2 - z1) * t + z1
    setCharCoordinates(PLAYER_PED,x1,y1,z1)
    wait(timer)
    end
    if not distErr then
    iter = iter - 3
    coordsReverse()      --
    end
    else
        sampAddChatMessage("{00FF00}[PresentFinder]Нет подарков поблизости.", -1)
    end
end
function coordsReverse()
    while true do
    local curX, curY, curZ
    curX = reverse[iter]
    curY = reverse[iter + 1]
    curZ = reverse[iter + 2]
    if(curX == reverse[1] and curY == reverse[2] and curZ == reverse[3]) then
        setCharCoordinates(PLAYER_PED,curX,curY,curZ)
        reverse[iter + 1] = 0
        reverse[iter + 2] = 0
        reverse[iter ] = 0
        break
    elseif(iter <= 0) then
        break
    end
    reverse[iter + 1] = 0
    reverse[iter + 2] = 0
    reverse[iter ] = 0
    iter = iter - 3
    setCharCoordinates(PLAYER_PED,curX,curY,curZ)
    wait(timer)
    end
    iter = 1
end
Century Gothic. Кто то уже фанатеет
 
  • Нравится
Реакции: HanzoPonPon

HanzoPonPon

Новичок
Автор темы
6
1
Последнее редактирование:
  • Грустно
Реакции: percheklii