скрипт не работает, че делать

egorglebov

Участник
Автор темы
50
4
Версия MoonLoader
.026-beta
хелп, писал спектатор для рашки, и скрипт крашнулся
1:
local sampev = require 'lib.samp.events'

local ad = {"46.174.53.214:7777", "62.122.214.40:7777", "46.174.53.218:7777"}
local ur = {"/report", "/rep", "/mm", "/mn"}

local tag = "Invizible for Russia-RP"
local url = "urltofile"
local aut = "Show Doc"
local main_color_while = 0xFFFFFF

function sampev.onSendCommand(command)
    if command == ur then
        sampAddChatMessage("Да зачем?", -1)
    end
end

function main()
    repeat wait(0) until isSampAvailable()
        sampRegisterChatCommand('clop', function()
            while true do
                wait(0)
                if sampGetCurrentServerAddress(ad) then
                    local sampgetonfoot = isCharOnFoot(PLAYER_PED)
                    if sampgetonfoot then
                        onfootinvizble = not onfootinvizble
                        if onfootinvizble then
                            sampAddChatMessage('On', -1)
                        end
                        if not onfootinvizble then
                            sampAddChatMessage('Don', -1)
                        end
                    else
                        sampAddChatMessage('Из машины БЫСТРО вышел!' -1)
                    end
                else
                    sampAddChatMessage('может ты и чудик, но скрипт сделан для другого сервера!')
                end
            end
            return false
        end

        function sampev.onSendPlayerSync(data)
            if onfootinvizble then
                local sync = samp_create_sync_data('spectator')
                sync.position = data.position
                sync.send()
                return false
            end
        end

         function samp_create_sync_data(sync_type, copy_from_player)
    local ffi = require 'ffi'
    local sampfuncs = require 'sampfuncs'
    -- from SAMP.Lua
    local raknet = require 'samp.raknet'
    --require 'samp.synchronization'

    copy_from_player = copy_from_player or true
    local sync_traits = {
        player = {'PlayerSyncData', raknet.PACKET.PLAYER_SYNC, sampStorePlayerOnfootData},
        vehicle = {'VehicleSyncData', raknet.PACKET.VEHICLE_SYNC, sampStorePlayerIncarData},
        passenger = {'PassengerSyncData', raknet.PACKET.PASSENGER_SYNC, sampStorePlayerPassengerData},
        aim = {'AimSyncData', raknet.PACKET.AIM_SYNC, sampStorePlayerAimData},
        trailer = {'TrailerSyncData', raknet.PACKET.TRAILER_SYNC, sampStorePlayerTrailerData},
        unoccupied = {'UnoccupiedSyncData', raknet.PACKET.UNOCCUPIED_SYNC, nil},
        bullet = {'BulletSyncData', raknet.PACKET.BULLET_SYNC, nil},
        spectator = {'SpectatorSyncData', raknet.PACKET.SPECTATOR_SYNC, nil}
    }
    local sync_info = sync_traits[sync_type]
    local data_type = 'struct ' .. sync_info[1]
    local data = ffi.new(data_type, {})
    local raw_data_ptr = tonumber(ffi.cast('uintptr_t', ffi.new(data_type .. '*', data)))
    -- copy player's sync data to the allocated memory
    if copy_from_player then
        local copy_func = sync_info[3]
        if copy_func then
            local _, player_id
            if copy_from_player == true then
                _, player_id = sampGetPlayerIdByCharHandle(PLAYER_PED)
            else
                player_id = tonumber(copy_from_player)
            end
            copy_func(player_id, raw_data_ptr)
        end
    end
    -- function to send packet
    local func_send = function()
        local bs = raknetNewBitStream()
        raknetBitStreamWriteInt8(bs, sync_info[2])
        raknetBitStreamWriteBuffer(bs, raw_data_ptr, ffi.sizeof(data))
        raknetSendBitStreamEx(bs, sampfuncs.HIGH_PRIORITY, sampfuncs.UNRELIABLE_SEQUENCED, 1)
        raknetDeleteBitStream(bs)
    end
    -- metatable to access sync data and 'send' function
    local mt = {
        __index = function(t, index)
            return data[index]
        end,
        __newindex = function(t, index, value)
            data[index] = value
        end
    }
    return setmetatable({send = func_send}, mt)
end
 

YarikVL

Известный
Проверенный
4,750
1,815
хелп, писал спектатор для рашки, и скрипт крашнулся
1:
local sampev = require 'lib.samp.events'

local ad = {"46.174.53.214:7777", "62.122.214.40:7777", "46.174.53.218:7777"}
local ur = {"/report", "/rep", "/mm", "/mn"}

local tag = "Invizible for Russia-RP"
local url = "urltofile"
local aut = "Show Doc"
local main_color_while = 0xFFFFFF

function sampev.onSendCommand(command)
    if command == ur then
        sampAddChatMessage("Да зачем?", -1)
    end
end

function main()
    repeat wait(0) until isSampAvailable()
        sampRegisterChatCommand('clop', function()
            while true do
                wait(0)
                if sampGetCurrentServerAddress(ad) then
                    local sampgetonfoot = isCharOnFoot(PLAYER_PED)
                    if sampgetonfoot then
                        onfootinvizble = not onfootinvizble
                        if onfootinvizble then
                            sampAddChatMessage('On', -1)
                        end
                        if not onfootinvizble then
                            sampAddChatMessage('Don', -1)
                        end
                    else
                        sampAddChatMessage('Из машины БЫСТРО вышел!' -1)
                    end
                else
                    sampAddChatMessage('может ты и чудик, но скрипт сделан для другого сервера!')
                end
            end
            return false
        end

        function sampev.onSendPlayerSync(data)
            if onfootinvizble then
                local sync = samp_create_sync_data('spectator')
                sync.position = data.position
                sync.send()
                return false
            end
        end

         function samp_create_sync_data(sync_type, copy_from_player)
    local ffi = require 'ffi'
    local sampfuncs = require 'sampfuncs'
    -- from SAMP.Lua
    local raknet = require 'samp.raknet'
    --require 'samp.synchronization'

    copy_from_player = copy_from_player or true
    local sync_traits = {
        player = {'PlayerSyncData', raknet.PACKET.PLAYER_SYNC, sampStorePlayerOnfootData},
        vehicle = {'VehicleSyncData', raknet.PACKET.VEHICLE_SYNC, sampStorePlayerIncarData},
        passenger = {'PassengerSyncData', raknet.PACKET.PASSENGER_SYNC, sampStorePlayerPassengerData},
        aim = {'AimSyncData', raknet.PACKET.AIM_SYNC, sampStorePlayerAimData},
        trailer = {'TrailerSyncData', raknet.PACKET.TRAILER_SYNC, sampStorePlayerTrailerData},
        unoccupied = {'UnoccupiedSyncData', raknet.PACKET.UNOCCUPIED_SYNC, nil},
        bullet = {'BulletSyncData', raknet.PACKET.BULLET_SYNC, nil},
        spectator = {'SpectatorSyncData', raknet.PACKET.SPECTATOR_SYNC, nil}
    }
    local sync_info = sync_traits[sync_type]
    local data_type = 'struct ' .. sync_info[1]
    local data = ffi.new(data_type, {})
    local raw_data_ptr = tonumber(ffi.cast('uintptr_t', ffi.new(data_type .. '*', data)))
    -- copy player's sync data to the allocated memory
    if copy_from_player then
        local copy_func = sync_info[3]
        if copy_func then
            local _, player_id
            if copy_from_player == true then
                _, player_id = sampGetPlayerIdByCharHandle(PLAYER_PED)
            else
                player_id = tonumber(copy_from_player)
            end
            copy_func(player_id, raw_data_ptr)
        end
    end
    -- function to send packet
    local func_send = function()
        local bs = raknetNewBitStream()
        raknetBitStreamWriteInt8(bs, sync_info[2])
        raknetBitStreamWriteBuffer(bs, raw_data_ptr, ffi.sizeof(data))
        raknetSendBitStreamEx(bs, sampfuncs.HIGH_PRIORITY, sampfuncs.UNRELIABLE_SEQUENCED, 1)
        raknetDeleteBitStream(bs)
    end
    -- metatable to access sync data and 'send' function
    local mt = {
        __index = function(t, index)
            return data[index]
        end,
        __newindex = function(t, index, value)
            data[index] = value
        end
    }
    return setmetatable({send = func_send}, mt)
end
Табуляция хромает, код принципе весь в main не будет работать, ошибка на ошибке. Посмотри лучше ютуб канал The Champ Guess, а потом пиши читы
Lua:
local sampev = require 'lib.samp.events'

local ad = {"46.174.53.214:7777", "62.122.214.40:7777", "46.174.53.218:7777"}
local ur = {"/report", "/rep", "/mm", "/mn"}

local tag = "Invizible for Russia-RP"
local url = "urltofile"
local aut = "Show Doc"
local main_color_while = 0xFFFFFF

function sampev.onSendCommand(command)
    if command == ur then
        sampAddChatMessage("Да зачем?", -1)
    end
end

function main()
    while not isSampAvailable() do wait(0) end
    sampRegisterChatCommand('clop', function()
        onfootinvizble = not onfootinvizble
    end)
    while true do
        wait(0)
        if sampGetCurrentServerAddress(ad) then
            local sampgetonfoot = isCharOnFoot(PLAYER_PED)
            if not sampgetonfoot then
                sampAddChatMessage('Из машины БЫСТРО вышел!' -1)
            end
        else
            sampAddChatMessage('может ты и чудик, но скрипт сделан для другого сервера!')
            thisScript():unload()
        end
    end
end
function sampev.onSendPlayerSync(data)
    if onfootinvizble then
        local sync = samp_create_sync_data('spectator')
        sync.position = data.position
        sync.send()
        return false
    end
end

function samp_create_sync_data(sync_type, copy_from_player)
    local ffi = require 'ffi'
    local sampfuncs = require 'sampfuncs'
    -- from SAMP.Lua
    local raknet = require 'samp.raknet'
    --require 'samp.synchronization'

    copy_from_player = copy_from_player or true
    local sync_traits = {
        player = {'PlayerSyncData', raknet.PACKET.PLAYER_SYNC, sampStorePlayerOnfootData},
        vehicle = {'VehicleSyncData', raknet.PACKET.VEHICLE_SYNC, sampStorePlayerIncarData},
        passenger = {'PassengerSyncData', raknet.PACKET.PASSENGER_SYNC, sampStorePlayerPassengerData},
        aim = {'AimSyncData', raknet.PACKET.AIM_SYNC, sampStorePlayerAimData},
        trailer = {'TrailerSyncData', raknet.PACKET.TRAILER_SYNC, sampStorePlayerTrailerData},
        unoccupied = {'UnoccupiedSyncData', raknet.PACKET.UNOCCUPIED_SYNC, nil},
        bullet = {'BulletSyncData', raknet.PACKET.BULLET_SYNC, nil},
        spectator = {'SpectatorSyncData', raknet.PACKET.SPECTATOR_SYNC, nil}
    }
    local sync_info = sync_traits[sync_type]
    local data_type = 'struct ' .. sync_info[1]
    local data = ffi.new(data_type, {})
    local raw_data_ptr = tonumber(ffi.cast('uintptr_t', ffi.new(data_type .. '*', data)))
    -- copy player's sync data to the allocated memory
    if copy_from_player then
        local copy_func = sync_info[3]
        if copy_func then
            local _, player_id
            if copy_from_player == true then
                _, player_id = sampGetPlayerIdByCharHandle(PLAYER_PED)
            else
                player_id = tonumber(copy_from_player)
            end
            copy_func(player_id, raw_data_ptr)
        end
    end
    -- function to send packet
    local func_send = function()
        local bs = raknetNewBitStream()
        raknetBitStreamWriteInt8(bs, sync_info[2])
        raknetBitStreamWriteBuffer(bs, raw_data_ptr, ffi.sizeof(data))
        raknetSendBitStreamEx(bs, sampfuncs.HIGH_PRIORITY, sampfuncs.UNRELIABLE_SEQUENCED, 1)
        raknetDeleteBitStream(bs)
    end
    -- metatable to access sync data and 'send' function
    local mt = {
        __index = function(t, index)
            return data[index]
        end,
        __newindex = function(t, index, value)
            data[index] = value
        end
    }
    return setmetatable({send = func_send}, mt)
end
 
  • Нравится
Реакции: sat0ry