Помогите с диалогами

Ricardo_Miloss

Участник
Автор темы
40
3
Версия MoonLoader
.026-beta
Lua:
function samp.onServerMessage(color, text)
   lua_thread.create(function()
   wait(0)
   text = text:gsub("{......}", "")
   for k,v in ipairs(t) do
      if text:find(v) then
         local id, msg = text:match(".+%[(%d+)%] говорит: (.+)")
         if msg == v then
            local result, ped = sampGetCharHandleBySampPlayerId(id)
            if result then
               local m = {getCharCoordinates(1)}
               local p = {getCharCoordinates(ped)}
               if getDistanceBetweenCoords3d(m[1], m[2], m[3], p[1], p[2], p[3]) < 5 then
                  sampSendChat("/faminvite "..id)
                  break
               end
            end
         end
      end
    end
      end)
    if text:find('%[Ошибка%] {FFFFFF}Произошла ошибка, игрок состоит в другой семье!') then
        lua_thread.create(function()
        wait(500)
        sampCloseCurrentDialogWithButton(0)
        sampSendChat('/b Выйдите из семьи и повторно напишите "инвайт"')
   end)
end
end

Нужно сделать чтобы если у человека меньше 3 уровня скрипт делал вот так
Вот иды диалогов
  1. Семья | id диалога - 156
  2. Панель управления семьей | id диалога - 161
  3. Выберите игрока | id диалога - 162
    Но если я ввожу команду /fammenu, то могу спокойно использовать его
 
Последнее редактирование:
Решение
И пол года не прошло

code:
function samp.onServerMessage(color, text)
   lua_thread.create(function()
   wait(0)
   text = text:gsub("{......}", "")
   for k,v in ipairs(t) do
      if text:find(v) then
         local id, msg = text:match(".+%[(%d+)%] говорит: (.+)")
         if msg == v then
            local result, ped = sampGetCharHandleBySampPlayerId(id)
            if result then
                    local m = {getCharCoordinates(1)}
                    local p = {getCharCoordinates(ped)}
                    if getDistanceBetweenCoords3d(m[1], m[2], m[3], p[1], p[2], p[3]) < 5 then
                        if sampGetPlayerScore(id) < 3 then
                            inviting = true...

siwage

Активный
188
65
И пол года не прошло

code:
function samp.onServerMessage(color, text)
   lua_thread.create(function()
   wait(0)
   text = text:gsub("{......}", "")
   for k,v in ipairs(t) do
      if text:find(v) then
         local id, msg = text:match(".+%[(%d+)%] говорит: (.+)")
         if msg == v then
            local result, ped = sampGetCharHandleBySampPlayerId(id)
            if result then
                    local m = {getCharCoordinates(1)}
                    local p = {getCharCoordinates(ped)}
                    if getDistanceBetweenCoords3d(m[1], m[2], m[3], p[1], p[2], p[3]) < 5 then
                        if sampGetPlayerScore(id) < 3 then
                            inviting = true
                            sampSendChat("/faminvite "..id)
                        else
                            sampSendChat("/faminvite "..id)
                        end
                    break
               end
            end
         end
      end
    end
end)
        if text:find('%[Ошибка%] {FFFFFF}Произошла ошибка, игрок состоит в другой семье!') then
            lua_thread.create(function()
            wait(500)
            sampCloseCurrentDialogWithButton(0)
            sampSendChat('/b Выйдите из семьи и повторно напишите "инвайт"')
       end)
    end
end

    
function samp.onShowDialog(id, style, title, button1, button2, text)
    if inviting then
      if id == 156 then
         sampSendDialogResponse(id, 1,0,nil)
         return false
      end
      if id == 161 then
         sampSendDialogResponse(id, 1,0,nil)
         return false
      end
      if id == 162 then
         sampSendDialogResponse(id, 1,0,nil)
         inviting = false
         return false
      end
   end
end