Как сделать, чтобы скрипт не работал на других серверах

Сheesecake

Участник
Автор темы
60
2
Версия MoonLoader
Другое
Как сделать так, что бы скрипт не работах на других серверах, т.е был привязан только к определеному серверу.
Если заходишь на другой сервер: Уведомляет, мол этот скрипт только для тратата РП. К примеру
 
Решение
Lua:
function main()
    repeat wait(100) until isSampAvailable()
    repeat wait(0) until sampGetCurrentServerName() ~= 'SA-MP'
    repeat
        wait(0)
        for id = 0, 2303 do
            if sampTextdrawIsExists(id) and sampTextdrawGetString(id):find('Samp%-Rp.Ru') then
                samp_rp = true
            end
        end
    until samp_rp ~= nil
    server = sampGetCurrentServerName():gsub('|', '')
    server = (server:find('02') and 'Two' or (server:find('Revolution') and 'Revolution' or (server:find('Legacy') and 'Legacy' or (server:find('Classic') and 'Classic' or ''))))
    if server == '' then thisScript():unload() end
    wait(-1)
end
Вот пример для срп
Нахера так сложно и не практично? Ему нужно чтобы...

Gorskin

🖕
Проверенный
1,353
1,203
Lua:
function main()
    repeat wait(100) until isSampAvailable()
    repeat wait(0) until sampGetCurrentServerName() ~= 'SA-MP'
    repeat
        wait(0)
        for id = 0, 2303 do
            if sampTextdrawIsExists(id) and sampTextdrawGetString(id):find('Samp%-Rp.Ru') then
                samp_rp = true
            end
        end
    until samp_rp ~= nil
    server = sampGetCurrentServerName():gsub('|', '')
    server = (server:find('02') and 'Two' or (server:find('Revolution') and 'Revolution' or (server:find('Legacy') and 'Legacy' or (server:find('Classic') and 'Classic' or ''))))
    if server == '' then thisScript():unload() end
    wait(-1)
end
Вот пример для срп
 

Tema05

Известный
1,513
480
Lua:
function main()
    repeat wait(100) until isSampAvailable()
    repeat wait(0) until sampGetCurrentServerName() ~= 'SA-MP'
    repeat
        wait(0)
        for id = 0, 2303 do
            if sampTextdrawIsExists(id) and sampTextdrawGetString(id):find('Samp%-Rp.Ru') then
                samp_rp = true
            end
        end
    until samp_rp ~= nil
    server = sampGetCurrentServerName():gsub('|', '')
    server = (server:find('02') and 'Two' or (server:find('Revolution') and 'Revolution' or (server:find('Legacy') and 'Legacy' or (server:find('Classic') and 'Classic' or ''))))
    if server == '' then thisScript():unload() end
    wait(-1)
end
Вот пример для срп
Нахера так сложно и не практично? Ему нужно чтобы работало только на 1, а не на всех кроме этого.
Lua:
local ip, port = sampGetCurrentServerAddress()
if not (ip == '185.169.134.3' and port == 7777 or ip == '185.169.134.4' and port == 7777) then
    thisScript:unload()--скрипт выгрузится если ты не на серверах ip которых указаны выше.
end
 

Сheesecake

Участник
Автор темы
60
2
Нахера так сложно и не практично? Ему нужно чтобы работало только на 1, а не на всех кроме этого.
Lua:
local ip, port = sampGetCurrentServerAddress()
if not (ip == '185.169.134.3' and port == 7777 or ip == '185.169.134.4' and port == 7777) then
    thisScript:unload()--скрипт выгрузится если ты не на серверах ip которых указаны выше.
end
это в беск. цикл кидать?
 

chapo

tg/inst: @moujeek
Всефорумный модератор
9,090
12,118
это в беск. цикл кидать?
если я не ошибаюсь, то да. так как если кидать не в цикл, то можно будет обойти эту привязку скриптом, который будет подключать тебя к другому серву.