Помощь в изменении скриптов

FYP

Известный
Автор темы
Администратор
1,757
5,684
Здесь вы можете попросить других пользователей внести какие-то небольшие изменения в скрипт, например, изменить активацию.
Для вопросов по программированию и разработке на форуме есть отдельная категория Разработка.

Рекомендации:
  1. Не просите о редактировании .asi, .sf, .luac, .dll, .exe и прочих файлов, не поддающихся простой декомпиляции. Скрипты формата .ahk (AutoHotKey), .lua (Lua/MoonLoader) и .cs (CLEO) легко поддаются изменению.
  2. Сообщения по типу "спасибо, помог" по правилам форума считаются флудом и скорее всего будут удалены. Если вам помогли, вы можете нажать кнопку Мне нравится под ответом - это даст понять, что ответ верный.
  3. За злонамеренное распространение вредоносного ПО - перманентный бан. Имейте это в виду.
Удаление копирайтов является нарушением авторских прав, если автор не дал на это своего разрешения. Правила BlastHack запрещают нарушать авторские права, поэтому если вам нужно их убрать - обращайтесь к автору.
 
Последнее редактирование:

congic

Активный
255
81
Cекунду.


Держи

reconnect:
local mq = require("samp.events")

function main()
    -- ну тут свой код и так понятно.

    while true do
        wait(0)

        -- тут тоже твое если надо

    end
end

function mq.onServerMessage()
    if text:find('Server closed the connection.') then reconnect(10000) end
end


А, стоп, тебе на раксамп или просто на обычный самп?
обычный самп с использованием библиотеки мунбот
 

lightmetal

Участник
23
2
Подскажите почему в чекбоксе не включается/выключается скрипт. Отметил код который отвечает за это и который должен включать/выключаться(111-146). Делал включение/выключение скрипта по первому чекбоксу,всё работала. Начал делать второй по такому же принципу, он не включается(постоянно выключен)
Код:
require 'moonloader'
local imgui = require 'mimgui'
local ffi = require 'ffi'
local inicfg = require "inicfg"
local dlstatus = require('moonloader').download_status
local sampev = require('lib.samp.events')
local fa = require 'faIcons'
local fonts = renderCreateFont("Arial", 9, 5)
local encoding = require 'encoding'
encoding.default = 'CP1251'
local u8 = encoding.UTF8
local new = imgui.new


local tab = 1
local WinState = imgui.new.bool()
local active_script = imgui.new.bool()
local active_scriptuval = imgui.new.bool()

local words = {'псж','psj','увал','увольте'}
local font = renderCreateFont('TimesNewRoman', 12, 5)
local st = {
    nick = '',
    bool = false,
    timer = -1,
    id = -1,
}

function imgui.Link(link, text) -- link
    text = text or link
    local tSize = imgui.CalcTextSize(text)
    local p = imgui.GetCursorScreenPos()
    local DL = imgui.GetWindowDrawList()
    local col = { 0xFFFF7700, 0xFFFF9900 }
    if imgui.InvisibleButton("##" .. link, tSize) then os.execute("explorer " .. link) end
    local color = imgui.IsItemHovered() and col[1] or col[2]
    DL:AddText(p, color, text)
    DL:AddLine(imgui.ImVec2(p.x, p.y + tSize.y), imgui.ImVec2(p.x + tSize.x, p.y + tSize.y), color)
end

imgui.OnFrame(function() return WinState[0] end, function(player)
    imgui.SetNextWindowPos(imgui.ImVec2(500, 500), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
    imgui.SetNextWindowSize(imgui.ImVec2(700, 420), imgui.Cond.Always)
    imgui.Begin(u8'Пример', WinState, imgui.WindowFlags.NoResize)
 
    imgui.BeginChild('##left', imgui.ImVec2(160, 365), true)
    for numberTab, nameTab in pairs({'Основное','Настройки','Инфа', 'Тест', 'Тест2',  'Тест3'}) do
        if imgui.Button(u8(nameTab), imgui.ImVec2(148,55)) then
            tab = numberTab
        end
    end
    imgui.EndChild()
    imgui.SameLine()
     imgui.SetCursorPos(imgui.ImVec2(170, 30))
     if imgui.BeginChild('right'..tab, imgui.ImVec2(510, 365), true) then
        -- Содержимое вкладок
        if tab == 1 then
        imgui.Checkbox(u8'Быстрый инвайт', active_script)
        imgui.Checkbox(u8'Быстрое увольнение', active_scriptuval)
        end
    end


    if tab == 2 then
        imgui.Text(u8'Текущая тема: '..colorList[colorListNumber[0]+1])
        if imgui.Combo(u8'Темы',colorListNumber,colorListBuffer, #colorList) then
            theme[colorListNumber[0]+1].change()
        end
    end

    if tab == 3 then
        imgui.Text(u8'Скрипт создан для упрощения игры в гетто или на каптах')
        imgui.Link("https://vk.com",u8'vk')
    end
    imgui.End()
end)



function main()
    if not isSampLoaded() or not isSampfuncsLoaded() then return end
    while not isSampAvailable() do wait(100) end
    sampRegisterChatCommand('ghelperr', function() WinState[0] = not WinState[0] end)
    while true do
        if active_script[0] then
            if wasKeyPressed(0x31) and not sampIsChatInputActive() and not sampIsDialogActive() then
                local result, ped = getCharPlayerIsTargeting(PLAYER_HANDLE)
                if result then
                    _, id = sampGetPlayerIdByCharHandle(ped)
                    sampSendChat('/me передал бандану')
                    wait(1000)
                    sampSendChat('/givecbook '..id..' 100')
                    wait(100)
                    sampSendChat('/invite '..id)
                    setVirtualKeyDown(13, true)
                    wait(100)
                    setVirtualKeyDown(13, false)
                    if accept and t:find("(%S+)_(%S+) принял ваше предложение вступить к вам в организацию.") then
                        sampSendChat("/giverank "..id.." 6")
                        accept = false
                    end
                end
                    accept = true
                end
            end
            wait(0)
        end
        return 1
    end
 
    function uval()
        while true do
            if active_scriptuval[0] then
            if st.bool and st.timer ~= -1 then
                timer = os.clock()-st.timer
                renderFontDrawText(font,'Нажми Y чтоб уволить '..st.nick..' или N чтоб не увольнять\nВремени на раздумья 6 сек, прошло: '..tostring(os.date("!*t", timer).sec), 500, 500, 0xFFFFFFFF)
                if timer > 5 or wasKeyPressed(0x59) or wasKeyPressed(0x4E) then
                    if wasKeyPressed(0x59) then
                        sampSendChat('/uninvite '..st.id..' ПСЖ')
                    end
                    st.bool = false
                    st.timer = -1
                end
            end
        end
    end
    wait(0)
end
    function sampev.onServerMessage(color, text)
        for k, v in pairs(words) do
            local nick, msg = text:match('(.+) говорит: (.+)')
            if nick and msg:find(v) then
                st.nick = nick
                st.id = sampGetPlayerIdByNickname(nick:gsub(' ','_'))
                st.bool = true
                st.timer = os.clock()
            end
        end
    end
    function sampGetPlayerIdByNickname(nick)
        local _, myid = sampGetPlayerIdByCharHandle(playerPed)
        if tostring(nick:gsub('%[%d+%]','')) == sampGetPlayerNickname(myid):gsub('%[%d+%]','') then return myid end
        for i = 0, sampGetMaxPlayerId() do
            if sampIsPlayerConnected(i) and sampGetPlayerNickname(i):gsub('%[%d+%]','') == nick then return i end
        end
    end

Нужно вот этот код
Код:
   function uval()
            while true do wait(0)
                if st.bool and st.timer ~= -1 then
                    timer = os.clock()-st.timer
                    renderFontDrawText(font,'Нажми Y чтоб уволить '..st.nick..' или N чтоб не увольнять\nВремени на раздумья 6 сек, прошло: '..tostring(os.date("!*t", timer).sec), 500, 500, 0xFFFFFFFF)
                    if timer > 5 or wasKeyPressed(0x59) or wasKeyPressed(0x4E) then
                        if wasKeyPressed(0x59) then
                            sampSendChat('/uninvite '..st.id..' ПСЖ')
                        end
                        st.bool = false
                        st.timer = -1
                    end
                end
            end
        end
    end
        function sampev.onServerMessage(color, text)
            for k, v in pairs(words) do
                local nick, id, msg = text:match('%[F%] (.+)%[(%d+)%]: (.+)')
                if nick and id and msg:find(v) then
                    st.nick = nick
                    st.id = id
                    st.bool = true
                    st.timer = os.clock()
                end
            end
        end

засунуть во второй чекбокс. Что бы при включение/выключение чекбокса с ним же включался или выключался скрипт выше.
Код:
imgui.Checkbox(u8'Быстрое увольнение', active_scriptUVAL)