[RakSamp] пишет, что такой команды нету

.matteo

Участник
Автор темы
38
2
Версия MoonLoader
Другое
1688770402933.png




Lua:
require 'addon'
local sampev = require 'libs.samp.events'
function sampev.onSendSpawn()
    time = os.time()
    newTask(function()
        if getBotInterior() == 0 then
        wait(5000)
            print('start')
            wait(5000)
            runCommand('!play bot')
            end
            end)
            end


мне нужно, чтобы он запустил маршрут из папки routes

для этого у меня есть скрипт route player
 
Последнее редактирование:
Решение
Посмотреть вложение 207270



Lua:
require 'addon'
local sampev = require 'libs.samp.events'
function sampev.onSendSpawn()
    time = os.time()
    newTask(function()
        if getBotInterior() == 0 then
        wait(5000)
            print('start')
            wait(5000)
            runCommand('!play bot')
            end
            end)
            end


мне нужно, чтобы он запустил маршрут из папки routes

для этого у меня есть скрипт route player

Попробуй так


Lua:
require 'addon'
local sampev = require 'libs.samp.events'
function sampev.onSendSpawn()
    time = os.time()
    newTask(function()
        if getBotInterior() == 0 then
        wait(5000)
            print('start')
            wait(5000)...

Silence Scripts

Участник
25
3
Посмотреть вложение 207270



Lua:
require 'addon'
local sampev = require 'libs.samp.events'
function sampev.onSendSpawn()
    time = os.time()
    newTask(function()
        if getBotInterior() == 0 then
        wait(5000)
            print('start')
            wait(5000)
            runCommand('!play bot')
            end
            end)
            end


мне нужно, чтобы он запустил маршрут из папки routes

для этого у меня есть скрипт route player

Попробуй так


Lua:
require 'addon'
local sampev = require 'libs.samp.events'
function sampev.onSendSpawn()
    time = os.time()
    newTask(function()
        if getBotInterior() == 0 then
        wait(5000)
            print('start')
            wait(5000)
            runRoute('!play bot')
        end
    end)
end


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

function sampev.onSendVehicleSync(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(getBotVehicle() ~= 0 and 2 or 1)
        if ok then
            if getBotVehicle() ~= 0 then bitstream.incar:sendPacket() else bitstream.onfoot:sendPacket() end
            setBotPosition(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
                setBotPosition(packet[counter].x, packet[counter].y, packet[counter].z)
                setBotQuaternion(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(getBotVehicle())
        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[getBotVehicle()])
        bs:writeUInt8(getBotHealth())
        bs:writeUInt8(getBotArmor())
        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(getBotHealth())
        bs:writeUInt8(getBotArmor())
        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 setBotQuaternion(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