Помощь с Lua

Soldik

Новичок
Автор темы
18
1
Доброго времени дня. Я новичок в Lua. Решил написать скрипт для Trinity RP, который перемещает предметы из одной ячейки в другую. Как сделать так, что когда дойдет до 984 текстдрава, скрипт переключился на function gotovo(). Т.е после завершения переноса мне написало в чат "perenes".

Lua:
script_name("tralalelotralala")
script_version("crocodilobombardiro")


function main()
    if not isSampLoaded() or not isSampfuncsLoaded() then return end
    while not isSampAvailable() do wait(100) end
    sampAddChatMessage(string.format("%s %s loaded.", thisScript().name, thisScript().version), 0xFF9900)
    sampRegisterChatCommand('croc',command)
    while true do wait(0)
        
        
        
            
    end
    
    
    
end

function command()
    sampSendChat('/inv')
    peretask()
    
    
end

function peretask()
    array = {1028,1024,1020,1016,1012,1008,1004,1000,996,992,988,984}
    
    for i, value in ipairs(array) do       
        sampSendClickTextdraw(value)
        
    end
    
    
    
    
    

    
end
    
-- showtdid

function gotovo()
    sampAddChatMessage("perenes", 0xFF9900)
end
 
Решение
после цикла вызвать саму функции

Lua:
script_name("tralalelotralala")
script_version("crocodilobombardiro")


function main()
    if not isSampLoaded() or not isSampfuncsLoaded() then return end
    while not isSampAvailable() do wait(100) end
    sampAddChatMessage(string.format("%s %s loaded.", thisScript().name, thisScript().version), 0xFF9900)
    sampRegisterChatCommand('croc',command)
    while true do wait(0)
    end
end

function command()
    sampSendChat('/inv')
    peretask()
    
    
end

function peretask()
    array = {1028,1024,1020,1016,1012,1008,1004,1000,996,992,988,984}
    for i, value in ipairs(array) do       
        sampSendClickTextdraw(value)
        
    end
    gotovo()
end
    
-- showtdid

function gotovo()...

VanoKLR

Известный
965
591
после цикла вызвать саму функции

Lua:
script_name("tralalelotralala")
script_version("crocodilobombardiro")


function main()
    if not isSampLoaded() or not isSampfuncsLoaded() then return end
    while not isSampAvailable() do wait(100) end
    sampAddChatMessage(string.format("%s %s loaded.", thisScript().name, thisScript().version), 0xFF9900)
    sampRegisterChatCommand('croc',command)
    while true do wait(0)
    end
end

function command()
    sampSendChat('/inv')
    peretask()
    
    
end

function peretask()
    array = {1028,1024,1020,1016,1012,1008,1004,1000,996,992,988,984}
    for i, value in ipairs(array) do       
        sampSendClickTextdraw(value)
        
    end
    gotovo()
end
    
-- showtdid

function gotovo()
    sampAddChatMessage("perenes", 0xFF9900)
end
 

Soldik

Новичок
Автор темы
18
1
после цикла вызвать саму функции

Lua:
script_name("tralalelotralala")
script_version("crocodilobombardiro")


function main()
    if not isSampLoaded() or not isSampfuncsLoaded() then return end
    while not isSampAvailable() do wait(100) end
    sampAddChatMessage(string.format("%s %s loaded.", thisScript().name, thisScript().version), 0xFF9900)
    sampRegisterChatCommand('croc',command)
    while true do wait(0)
    end
end

function command()
    sampSendChat('/inv')
    peretask()
   
   
end

function peretask()
    array = {1028,1024,1020,1016,1012,1008,1004,1000,996,992,988,984}
    for i, value in ipairs(array) do      
        sampSendClickTextdraw(value)
       
    end
    gotovo()
end
   
-- showtdid

function gotovo()
    sampAddChatMessage("perenes", 0xFF9900)
end
Он вызывает ее до того, как пройдет sampSendClickTextdraw(value)

после цикла вызвать саму функции

Lua:
script_name("tralalelotralala")
script_version("crocodilobombardiro")


function main()
    if not isSampLoaded() or not isSampfuncsLoaded() then return end
    while not isSampAvailable() do wait(100) end
    sampAddChatMessage(string.format("%s %s loaded.", thisScript().name, thisScript().version), 0xFF9900)
    sampRegisterChatCommand('croc',command)
    while true do wait(0)
    end
end

function command()
    sampSendChat('/inv')
    peretask()
   
   
end

function peretask()
    array = {1028,1024,1020,1016,1012,1008,1004,1000,996,992,988,984}
    for i, value in ipairs(array) do      
        sampSendClickTextdraw(value)
       
    end
    gotovo()
end
   
-- showtdid

function gotovo()
    sampAddChatMessage("perenes", 0xFF9900)
end
Извиняюсь, работает.
 
Последнее редактирование: