RakSamp | Помогите пофиксить код

kickflip228

Участник
Автор темы
83
5
Версия MoonLoader
Другое
function sampev.onSendSpawn() runRoute(chap) print('Убегаю со спавна!') local chapaaa = true newTask(function() wait(5000) local pickup_id, distance = nil, math.huge local position = vector3d(getPosition()) for id, data in pairs(getAllPickups()) do if getDistanceBetweenCoords3d(position, distance.position) < distance then pickup_id, distance = id, getDistanceBetweenCoords3d(position, distance.position) end end if pickup_id and chapaaa then sendPickedUpPickup(pickup_id) print("Teleport") chapaaa = false end return pickup_id and true or false end) end:
function sampev.onSendSpawn()
    runRoute(chap)
    print('Убегаю со спавна!')
    local chapaaa = true
newTask(function()
    wait(5000)
    local pickup_id, distance = nil, math.huge
    local position = vector3d(getPosition())
    for id, data in pairs(getAllPickups()) do
        if getDistanceBetweenCoords3d(position, distance.position) < distance then
            pickup_id, distance = id, getDistanceBetweenCoords3d(position, distance.position)
        end
    end
    if pickup_id and chapaaa then
        sendPickedUpPickup(pickup_id)
        print("Teleport")
        chapaaa = false
    end
    return pickup_id and true or false
    end)
end


1671281208998.png
 

kickflip228

Участник
Автор темы
83
5
фулл скрипт дай
Lua:
--         + Onfoot sync record/replay system
--        + Incar sync record/replay system.
--         + Moonloader lua script for this shit to record sync in compatible file format (.rt)
--
--
--    Author: Shamanije
--    URL: https://blast.hk/members/163165/
--    Version: 1.2.1

local sampev = require("samp.events")
require("addon")

local vector3d = require('vector3d')

local autosebatsa = true
local rep = fa
local rep = false
local loop = false
local packet, veh = {}, {}
local counter = 0

local bitstream = {
    onfoot = bitStream.new(),
    incar = bitStream.new(),
    aim = bitStream.new()
}

function onRunCommand(cmd)
    if cmd:find('!play') or cmd:find('!stop') or cmd:find('!loop') then
        runRoute(cmd)
        return false
    end
end

local SfBEG = {
    "!play latestRM"
}

local LVbeg = {
    "!play latestRM"
}


math.randomseed(os.time())
local LVbegg = LVbeg[math.random(1, #LVbeg)]

math.randomseed(os.time())
local chap = SfBEG[math.random(1, #SfBEG)]

local chapaaa = false

function sampev.onSendSpawn()
    runRoute(chap)
    print('Убегаю со спавна!')
    local chapaaa = true
newTask(function()
    wait(5000)
    local pickup_id, distance = nil, math.huge
    local position = vector3d(getPosition())
    for id, data in pairs(getAllPickups()) do
        if getDistanceBetweenCoords3d(position, distance.position) < distance then
            pickup_id, distance = id, getDistanceBetweenCoords3d(position, distance.position)
        end
    end
    if pickup_id and chapaaa then
        sendPickedUpPickup(pickup_id)
        print("Teleport")
        chapaaa = false
    end
    return pickup_id and true or false
    end)
end


function getDistanceBetweenCoords3d(point1, point2)
    return math.sqrt((point2.x - point1.x) ^ 2 + (point2.y - point1.y) ^ 2 + (point2.z - point1.z) ^ 2)
end

function sampev.onSendVehicleSync(data)
    if rep then return false end
end

function sampev.onSendPlayerSync(data)
    if rep then return false end
end

function sampev.onVehicleStreamIn(vehid, data)
    veh[vehid] = data.health
end

newTask(function()
    while true do
        check_update()
        wait(50)
    end
end)

function check_update()
    if rep then
        local ok = fillBitStream(getVehicle() ~= 0 and 2 or 1)
        if ok then
            if getVehicle() ~= 0 then bitstream.incar:sendPacket() else bitstream.onfoot:sendPacket() end
            setPosition(packet[counter].x, packet[counter].y, packet[counter].z)
            counter = counter + 1
            if counter%20 == 0 then
                local aok = fillBitStream(3)
                if aok then
                    bitstream.aim:sendPacket()
                else
                    err()
                end
            end
        else
            err()
        end
                    
        bitstream.onfoot:reset()
        bitstream.incar:reset()
        bitstream.aim:reset()
                    
        if counter == #packet then
            if not loop then
                rep = false
                setPosition(packet[counter].x, packet[counter].y, packet[counter].z)
                setQuaternion(packet[counter].qw, packet[counter].qx, packet[counter].qy, packet[counter].qz)
                packet = {}
            end
            counter = 1
        end
    end
end

local print = function(arg) return print('[Route Player]: '..arg) end

function err()
    rep = false
    packet = {}
    counter = 1
    print('an error has occured while writing data')
end

function fillBitStream(mode)
    if mode == 2 then
        local bs = bitstream.incar
        bs:writeUInt8(packet[counter].packetId)
        bs:writeUInt16(getVehicle())
        bs:writeUInt16(packet[counter].lr)
        bs:writeUInt16(packet[counter].ud)
        bs:writeUInt16(packet[counter].keys)
        bs:writeFloat(packet[counter].qw)
        bs:writeFloat(packet[counter].qx)
        bs:writeFloat(packet[counter].qy)
        bs:writeFloat(packet[counter].qz)
        bs:writeFloat(packet[counter].x)
        bs:writeFloat(packet[counter].y)
        bs:writeFloat(packet[counter].z)
        bs:writeFloat(packet[counter].sx)
        bs:writeFloat(packet[counter].sy)
        bs:writeFloat(packet[counter].sz)
        bs:writeFloat(veh[getVehicle()])
        bs:writeUInt8(getHealth())
        bs:writeUInt8(getArmour())
        bs:writeUInt8(0)
        bs:writeUInt8(0)
        bs:writeUInt8(packet[counter].gear)
        bs:writeUInt16(0)
        bs:writeFloat(0)
        bs:writeFloat(0)
        
    elseif mode == 1 then       
        local bs = bitstream.onfoot
        bs:writeUInt8(packet[counter].packetId)
        bs:writeUInt16(packet[counter].lr)
        bs:writeUInt16(packet[counter].ud)
        bs:writeUInt16(packet[counter].keys)
        bs:writeFloat(packet[counter].x)
        bs:writeFloat(packet[counter].y)
        bs:writeFloat(packet[counter].z)
        bs:writeFloat(packet[counter].qw)
        bs:writeFloat(packet[counter].qx)
        bs:writeFloat(packet[counter].qy)
        bs:writeFloat(packet[counter].qz)
        bs:writeUInt8(getHealth())
        bs:writeUInt8(getArmour())
        bs:writeUInt8(0)
        bs:writeUInt8(packet[counter].sa)
        bs:writeFloat(packet[counter].sx)
        bs:writeFloat(packet[counter].sy)
        bs:writeFloat(packet[counter].sz)
        bs:writeFloat(0)
        bs:writeFloat(0)
        bs:writeFloat(0)
        bs:writeUInt16(0)
        bs:writeUInt16(packet[counter].anim)
        bs:writeUInt16(packet[counter].flags)
        
    elseif mode == 3 then
        local bs = bitstream.aim
        bs:writeUInt8(203)
        bs:writeUInt8(packet[counter].mode)
        bs:writeFloat(packet[counter].cx)
        bs:writeFloat(packet[counter].cy)
        bs:writeFloat(packet[counter].cz)
        bs:writeFloat(packet[counter].px)
        bs:writeFloat(packet[counter].py)
        bs:writeFloat(packet[counter].pz)
        bs:writeFloat(packet[counter].az)
        bs:writeUInt8(packet[counter].zoom)
        bs:writeUInt8(packet[counter].wstate)
        bs:writeUInt8(packet[counter].unk)
        
    else return false end
    return true
end

function runRoute(act)
    if act:find('!play .*') then
        packet = loadIni(getPath()..'routes\\'..act:match('!play (.*)')..'.rt')
        if packet then
            print('playing route "'..act:match('!play (.*)')..'". total length: '..#packet)
            counter = 1
            rep = true
            loop = false
        else
            print('route doesnt exist')
        end
    elseif act:find('!loop') then
        if rep then loop = not loop; print(loop and 'looping current route' or 'loop off') else print('not playing any route') end
    elseif act:find('!stop') then
        if counter > 1 then rep = not rep else print('not playing any route') end
        if not rep then setQuaternion(packet[counter].qw, packet[counter].qx, packet[counter].qy, packet[counter].qz) end
        print(rep and 'playing resumed' or 'stopped on packet: '.. counter)
    end
end

function loadIni(fileName)
    local file = io.open(fileName, 'r')
    if file then
        local data = {}
        local section
        for line in file:lines() do
            local tempSection = line:match('^%[([^%[%]]+)%]$')
            if tempSection then
                section = tonumber(tempSection) and tonumber(tempSection) or tempSection
                data[section] = data[section] or {}
            end
            local param, value = line:match('^([%w|_]+)%s-=%s-(.+)$')
            if param and value ~= nil then
                if tonumber(value) then
                    value = tonumber(value)
                elseif value == 'true' then
                    value = true
                elseif value == 'false' then
                    value = false
                end
                if tonumber(param) then
                    param = tonumber(param)
                end
                data[section][param] = value
            end
        end
        file:close()
        return data
    end
    return false
end
 

Dimiano

Потрачен
74
71
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
Lua:
-- pickup_id, distance = id, getDistanceBetweenCoords3d(position, distance.position)
-- замени на 
pickup_id, distance = id, getDistanceBetweenCoords3d(position, data.position)