проверка на сервер

roscoewe

Участник
Автор темы
58
19
Версия MoonLoader
.026-beta
как сделать проверку на сервер? типо если это не дрп, скрипт не включался

Lua:
tid = {138, 141, 145, 143, 151, 140, 144, 149, 146, 150, 142, 147, 148, 159, 139, 158, 156, 157, 154, 153, 152, 155}

function main()
    if not isSampfuncsLoaded() or not isSampLoaded() then return end
    while not isSampAvailable() do wait(100) end
    IsLoaded = loadTextureDictionary('logo')
    if not IsLoaded then sampAddChatMessage("Файл txd не был найден(мб его нету?)", -1) return
    elseif IsLoaded then
        lua_thread.create(function()
            while true do
                wait(5000)
                sprite = loadSprite(string.match(sampGetCurrentServerName(), 'Diamond Role Play | (.+) | VOICE'))
                return
            end
        end)
    end
    while true do
        wait(0)
        for key, val in pairs(tid) do sampTextdrawDelete(val) end
        if sprite ~= nil then
            drawSprite(sprite, 589, 20, 57, 57, 255, 255, 255, 255)
        end
    end
 

roscoewe

Участник
Автор темы
58
19
а если много айпишников? перечислять как?
Lua:
-- тут твой код
    if not isSampfuncsLoaded() or not isSampLoaded() then return end
    while not isSampAvailable() do wait(100) end
  
    local ip, port = sampGetCurrentServerAddress()
    if ip ~= "айпишник_сервера" and port ~= "7777" then thisScript():unload() end
    -- тут твой код
 
463
825
Lua:
-- тут твой код
    if not isSampfuncsLoaded() or not isSampLoaded() then return end
    while not isSampAvailable() do wait(100) end
   
    local ip, port = sampGetCurrentServerAddress()
    if ip ~= "айпишник_сервера" and port ~= "7777" then thisScript():unload() end
    -- тут твой код
а по названию сервера что нельзя да
 

koncumone

Известный
337
87
как сделать проверку на сервер? типо если это не дрп, скрипт не включался

Lua:
tid = {138, 141, 145, 143, 151, 140, 144, 149, 146, 150, 142, 147, 148, 159, 139, 158, 156, 157, 154, 153, 152, 155}

function main()
    if not isSampfuncsLoaded() or not isSampLoaded() then return end
    while not isSampAvailable() do wait(100) end
    IsLoaded = loadTextureDictionary('logo')
    if not IsLoaded then sampAddChatMessage("Файл txd не был найден(мб его нету?)", -1) return
    elseif IsLoaded then
        lua_thread.create(function()
            while true do
                wait(5000)
                sprite = loadSprite(string.match(sampGetCurrentServerName(), 'Diamond Role Play | (.+) | VOICE'))
                return
            end
        end)
    end
    while true do
        wait(0)
        for key, val in pairs(tid) do sampTextdrawDelete(val) end
        if sprite ~= nil then
            drawSprite(sprite, 589, 20, 57, 57, 255, 255, 255, 255)
        end
    end
Lua:
    if not isSampLoaded() or not isSampfuncsLoaded() then return end
    while not isSampAvailable() do wait(0) end

    while sampGetCurrentServerName() == "SA-MP" do wait(0) end
    if not sampGetCurrentServerName():lower():match("diamond") then
       thisScript():unload()
        return
    end
 

Thief

Участник
108
12
а по названию сервера что нельзя да
Можно, только ты сам понимаешь чё будет, если на зайти на сервер с подобным названием
С таким отношением можно типа вообще всё идентифицировать по названиям, зачем вообще созданы какие-то уникальные идентификаторы