Помогите со скриптом

Ke4less

Участник
Автор темы
62
18
Версия MoonLoader
.026-beta
Решил попробовать написать скрипт на lua и 1-ой задумкой была "Анимированное лого"
В фотошопе сделал свечения и тд.
Изменение лого сделал в бесконечном цикле.
Скрипт немного работает, а потом выдает белый прямоугольник
Скинул архив где скрипт и лого в txd.
P.S. Сервер Sedona

Сам код:
logo.lua:
local q = require 'lib.samp.events'
script_name("Anim Logo 1.0")
script_description('Logo')
local inicfg = require 'inicfg'
local logo = 1
local act = false
if not doesDirectoryExist("moonloader/config") then
    os.execute('md "'..getWorkingDirectory()..'/config"') 
    local f = io.open("moonloader/config", "w")
end
if not doesFileExist("moonloader/config/" .. thisScript().name .. ".ini") then
    local f = io.open("moonloader/config/" .. thisScript().name .. ".ini", "w")
    if f then
        f:write('[main]')
        f:write('\nsedona = 1')
        f:close()
    end
    
end


local sedona = 1


mainIni = inicfg.load(nil,  "moonloader/config/" .. thisScript().name .. ".ini")

sedona = mainIni.main.sedona




if sedona == nil then sedona = 1 end


function main()
    if not isSampfuncsLoaded() or not isSampLoaded() then return end
    while not isSampAvailable() do wait(100) end
    sampRegisterChatCommand('logoreload',function() lua_thread.create(function() s = thisScript() s:reload() end)  end)
    sampAddChatMessage('Anim Logo',-1)
    
    repeat wait(0) until isSampAvailable()
    sampRegisterChatCommand("logo", function() state = not state
        sampAddChatMessage((state and 'Включен' or 'Выключен'), -1)
    end)
    while true do
        wait(2000)
        sprite = loadSprite(tonumber(1))
        wait(50)
        sprite = loadSprite(tonumber(2))
        wait(50)
        sprite = loadSprite(tonumber(3))
        wait(50)
        sprite = loadSprite(tonumber(4))
        wait(50)
        sprite = loadSprite(tonumber(5))
        wait(50)
        sprite = loadSprite(tonumber(4))
        wait(50)
        sprite = loadSprite(tonumber(3))
        wait(50)
        sprite = loadSprite(tonumber(2))
        wait(50)
        sprite = loadSprite(tonumber(6))
        wait(50)
        lua_thread.create(function()
            while sampGetCurrentServerName() == "SA-MP" do wait(0) end
            wait(500)     
                if sampGetCurrentServerName():match("Arizona") then
                    onServer = 'arizona'       
                    act = true
                end
                wait(1000)
 
          
                if onServer == 'arizona' then
                    servername = sampGetCurrentServerName()
                    if servername:find('Sedona') then
                        arizonaServ = 'sedona'
                        IsLoaded = loadTextureDictionary(arizonaServ)
                    end
                    

                end
                
        end)

    lua_thread.create(function()
        while true do
            wait(0)
            
            if sprite ~= nil and act then
                drawSprite(sprite, 589, 20, 76, 38, 255, 255, 255, 255)
            end
        end
    end)   


function q.onShowTextDraw(id, data)

    if data.position.x  > 530 and data.position.y < 26 then
        return false
    end
    
    if sampGetCurrentServerName():match("Arizona") then
        onServer = 'arizona'
        if data.position.y >= 1 and data.position.y < 50 and data.position.x < 603 and data.position.x > 500 then 
            return false
        end
    end
end

function writeServ()
    result = inicfg.save({main = {
        
        sedona         = sedona   

                     }},"moonloader/config/" .. thisScript().name .. ".ini")
end
     end
                                            
                                            if onServer == 'arizona' then
                                                if tonumber(param) >= 1 and tonumber(param) <= 6 then
                                                    if arizonaServ == 'sedona' then sedona = tonumber(param)
                                                        writeServ()
                                                        sampAddChatMessage('Новый номер логотипа для сервера '..arizonaServ..' - '..tonumber(1), -1)
                                                        sprite = loadSprite(tonumber(param))
                                                    end
                                                    
                                                end
                                            end
                                    end

Заранее извиняюсь за кривой код <3
Не бейте
 

Вложения

  • moonloader.7z
    75.3 KB · Просмотры: 6

Ke4less

Участник
Автор темы
62
18
1672967186214.png


Не заработало
 

qdIbp

Автор темы
Проверенный
1,383
1,139
Хз, так ты хотел или нет, но текстура прогрузилась

Lua:
script_name("Anim Logo 1.0")
script_description('Logo')

local logo = 1
local state = false

function main()
    repeat wait(0) until isSampAvailable()
   
    sampAddChatMessage('Anim Logo',-1)
   
    sampRegisterChatCommand('logoreload',function() lua_thread.create(function() s = thisScript() s:reload() end)  end)
    sampRegisterChatCommand("logo", function() state = not state
        sampAddChatMessage((state and 'Включен' or 'Выключен'), -1)
    end)

    while true do wait(0)
        local ip, port = sampGetCurrentServerAddress()
        if ip == '80.66.82.144' and port == 7777 then
            local IsLoaded = loadTextureDictionary('sedona')
            wait(2000)
            sprite = loadSprite(1)
            wait(50)
            sprite = loadSprite(2)
            wait(50)
            sprite = loadSprite(3)
            wait(50)
            sprite = loadSprite(4)
            wait(50)
            sprite = loadSprite(5)
            wait(50)
            sprite = loadSprite(4)
            wait(50)
            sprite = loadSprite(3)
            wait(50)
            sprite = loadSprite(2)
            wait(50)
            sprite = loadSprite(6)
            wait(50)
            if IsLoaded then
                arizonaServ = 'sedona'    
                if sprite ~= nil and state then
                    drawSprite(sprite, 589, 20, 76, 38, 255, 255, 255, 255)
                end
            end
        end
    end
end              

require('lib.samp.events').onShowTextDraw = function(id, data)
    if data.position.x > 530 and data.position.y < 26 then
        return false
    elseif data.position.y >= 1 and data.position.y < 50 and data.position.x < 603 and data.position.x > 500 then
        return false  
    end
end
 
Последнее редактирование:

Ke4less

Участник
Автор темы
62
18
Хз, так ты хотел или нет, но текстура прогрузилась

Lua:
script_name("Anim Logo 1.0")
script_description('Logo')

local logo = 1
local state = false

function main()
    repeat wait(0) until isSampAvailable()
  
    sampAddChatMessage('Anim Logo',-1)
  
    sampRegisterChatCommand('logoreload',function() lua_thread.create(function() s = thisScript() s:reload() end)  end)
    sampRegisterChatCommand("logo", function() state = not state
        sampAddChatMessage((state and 'Включен' or 'Выключен'), -1)
    end)

    while true do wait(0)
        local ip, port = sampGetCurrentServerAddress()
        if ip == '80.66.82.144' and port == 7777 then
            local IsLoaded = loadTextureDictionary('sedona')
            wait(2000)
            sprite = loadSprite(1)
            wait(50)
            sprite = loadSprite(2)
            wait(50)
            sprite = loadSprite(3)
            wait(50)
            sprite = loadSprite(4)
            wait(50)
            sprite = loadSprite(5)
            wait(50)
            sprite = loadSprite(4)
            wait(50)
            sprite = loadSprite(3)
            wait(50)
            sprite = loadSprite(2)
            wait(50)
            sprite = loadSprite(6)
            wait(50)
            if IsLoaded then
                arizonaServ = 'sedona'   
                if sprite ~= nil and state then
                    drawSprite(sprite, 589, 20, 76, 38, 255, 255, 255, 255)
                end
            end
        end
    end
end             

require('lib.samp.events').onShowTextDraw = function(id, data)
    if data.position.x > 530 and data.position.y < 26 then
        return false
    elseif data.position.y >= 1 and data.position.y < 50 and data.position.x < 603 and data.position.x > 500 then
        return false 
    end
end
Не робит(
 
  • Эм
Реакции: qdIbp

Ke4less

Участник
Автор темы
62
18
Жаль тут код скрыт...
Думал попробовать так же сделать
 
  • Грустно
Реакции: qdIbp

qdIbp

Автор темы
Проверенный
1,383
1,139
Жаль тут код скрыт...
Думал попробовать так же сделать
За что отвечают картинки с 2 по 6 в txd?
 

qdIbp

Автор темы
Проверенный
1,383
1,139
xz все робит но эффекта нет а мигал из за лишнего wait

Lua:
script_name("Anim Logo 1.0")
script_description('Logo')

local logo = 1
local state = false
function main()
    repeat wait(0) until isSampAvailable()

    sampAddChatMessage('Anim Logo',-1)
  
    sampRegisterChatCommand('logoreload',function() lua_thread.create(function() s = thisScript() s:reload() end)  end)
    sampRegisterChatCommand("logo", function() state = not state
        sampAddChatMessage((state and 'Включен' or 'Выключен'), -1)
    end)


    local IsLoaded = loadTextureDictionary('sedona')
    for i = 1,6 do
        _G['sprite_'..i] = loadSprite(i)
    end

    while true do wait(0)
        local ip, port = sampGetCurrentServerAddress()
        if ip == '80.66.82.144' and port == 7777 then
            if IsLoaded then
                arizonaServ = 'sedona'   
                if state then
                    drawSprite(_G['sprite_1'], 589, 20, 76, 38, 255, 255, 255, 255)
                    for id = 2,5 do
                        drawSprite(_G['sprite_'..id], 589,20,76,38,255,255,255)
                    end
                    drawSprite(_G['sprite_6'],589,20,76,38,255,255,255)
                end
            end
        end
    end
end             

require('lib.samp.events').onShowTextDraw = function(id, data)
    if data.position.x > 530 and data.position.y < 26 then
        return false
    end
    if data.position.y >= 1 and data.position.y < 50 and data.position.x < 603 and data.position.x > 500 then
        return false 
    end
end