Lua [Arizona RP] Информация о собранных ресурсов с территорий гетто.

pulemetov scripts

Участник
Автор темы
21
33
Здаров, написал простенький скриптик, который, наверное, поможет фармилам на аризонке.
Вы сможете понять сколько заработали с территорий гетто после выгрузки.
Скриншотик с игры:
aRMRjx2.jpg

Привозите фуру с респектами на склад > считываются привезенные ресурсы (вирты и бандитские респекты)

Активация: /getinfo
Зависимость: imgui, samp.events, encoding, fAwesome5




Lua:
script_author('Andrey Sinyak')
script_version('29.06.2021')

local dlstatus = require('moonloader').download_status
local ev = require "lib.samp.events"
local imgui = require "imgui"
local encoding = require "encoding"
encoding.default = 'CP1251'
u8 = encoding.UTF8

local active = imgui.ImBool(false)
local sw, sh = getScreenResolution()
local respect_to_warehouse = 0
local money_to_warehouse = 0
local respect_to_hands = 0
local money_to_hands = 0

function main()
    if not isSampLoaded() or not isSampfuncsLoaded() then return end
    while not isSampAvailable() do wait(100) end

    sampRegisterChatCommand('getinfo', function()
    active.v = not active.v
    end)


    _, id = sampGetPlayerIdByCharHandle(PLAYER_PED)
    nick = sampGetPlayerNickname(id)
    imgui.Process = true

    autoupdate("//[[ну тут тип ссылочка на json файл]]", '['..string.upper(thisScript().name)..']: ', "")
    while true do
        wait(0)

    end
end

--FONT

local res, fa = pcall(require, 'fAwesome5')
if not res then
print('{ffffff}Не обнаружена библиотека: fAwesome5! Начинаю его загрузку.')
local url = 'ссылка на либу'
local file_path = getWorkingDirectory() .. '\\lib\\fAwesome5.lua'
downloadUrlToFile(url, file_path)
end

if not doesFileExist('moonloader\\resource\\fonts\\fa-solid-900.ttf') then
  print('{ffffff}Не обнаружен шрифт: fa-solid-900.ttf! Начинаю его загрузку.')
  local url = '//[[ссылочка на файл со шрифтами]]'
  local file_path = getWorkingDirectory() .. '\\resource\\fonts\\fa-solid-900.ttf'
  downloadUrlToFile(url, file_path)
end

local fa_font = nil
local fa_glyph_ranges = imgui.ImGlyphRanges({ fa.min_range, fa.max_range })
function imgui.BeforeDrawFrame()
    if fa_font == nil then
        local font_config = imgui.ImFontConfig() -- to use 'imgui.ImFontConfig.new()' on error
        font_config.MergeMode = true

        fa_font = imgui.GetIO().Fonts:AddFontFromFileTTF('moonloader/resource/fonts/fa-solid-900.ttf', 13.0, font_config, fa_glyph_ranges)
    end
end
--

function imgui.OnDrawFrame()
imgui.ShowCursor = false
if active.v then
  imgui.SetNextWindowSize(imgui.ImVec2(228,220), imgui.Cond.FirstUseEver)
    imgui.SetNextWindowPos(imgui.ImVec2((sw / 1.09),(sh / 2.6)), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
    imgui.Begin(u8'Статистика собранных ресурсов', active ,imgui.WindowFlags.NoResize + imgui.WindowFlags.NoCollapse)
  imgui.Separator()
  imgui.Text(fa.ICON_FA_CALENDAR_ALT..u8' Общая статистика:')
  imgui.Separator()
  imgui.Text(u8'Деньги: '..money_to_hands + money_to_warehouse..' '..fa.ICON_FA_DOLLAR_SIGN)
  imgui.Text(u8'Респекты: '..respect_to_hands + respect_to_warehouse..' '..fa.ICON_FA_COINS)
  imgui.Separator()
  imgui.Text(fa.ICON_FA_WAREHOUSE..u8' Ресурсов на склад организации:')
  imgui.Separator()
  imgui.Text(u8'Деньги: '..money_to_warehouse..' '..fa.ICON_FA_DOLLAR_SIGN)
  imgui.Text(u8'Респекты: '..respect_to_warehouse..' '..fa.ICON_FA_COINS)
  imgui.Separator()
  imgui.Text(fa.ICON_FA_HAND_HOLDING_USD ..u8' Ресурсов на руки:')
  imgui.Separator()
  imgui.Text(u8'Деньги: '..money_to_hands..' '..fa.ICON_FA_DOLLAR_SIGN)
  imgui.Text(u8'Респекты: '..respect_to_hands..' '..fa.ICON_FA_COINS)
  imgui.End()
end
end

function ev.onServerMessage(color, text)
  if text:find(nick) and text:find('сделал объезд') and text:find('бандитские респекты.(%d+)') then
    new_respect_to_warehouse = text:match('бандитские респекты.(%d+)')
    respect_to_warehouse = respect_to_warehouse + new_respect_to_warehouse
  end
  if text:find(nick) and text:find('сделал объезд') and text:find('деньги: $(%d+)') then
    new_money_to_warehouse = text:match('деньги: $(%d+)')
    money_to_warehouse = money_to_warehouse + new_money_to_warehouse
  end

  if text:find('вы заработали') and text:find('бандитских респектов .(%d+).') then
    new_respect_to_hands = text:match('бандитских респектов .(%d+).')
    respect_to_hands = respect_to_hands + new_respect_to_hands
  end
  if text:find('вы заработали') and text:find('деньги: $(%d+)') then
    new_money_to_hands = text:match('деньги: $(%d+)')
    money_to_hands = money_to_hands + new_money_to_hands
  end
end

function autoupdate(json_url, prefix, url)
  local dlstatus = require('moonloader').download_status
  local json = getWorkingDirectory() .. '\\'..thisScript().name..'-version.json'
  if doesFileExist(json) then os.remove(json) end
  downloadUrlToFile(json_url, json,
    function(id, status, p1, p2)
      if status == dlstatus.STATUSEX_ENDDOWNLOAD then
        if doesFileExist(json) then
          local f = io.open(json, 'r')
          if f then
            local info = decodeJson(f:read('*a'))
            updatelink = info.updateurl
            updateversion = info.latest
            f:close()
            os.remove(json)
            if updateversion ~= thisScript().version then
              lua_thread.create(function(prefix)
                local dlstatus = require('moonloader').download_status
                sampAddChatMessage(('{5BDAD8}'..prefix..'{ffffff}Обнаружено обновление. Пытаюсь обновиться c {DA5B5B}'..thisScript().version..'{ffffff} на {DA5B5B}'..updateversion), -1)
                wait(250)
                downloadUrlToFile(updatelink, thisScript().path,
                  function(id3, status1, p13, p23)
                    if status1 == dlstatus.STATUS_DOWNLOADINGDATA then
                      print(string.format('Загружено %d из %d.', p13, p23))
                    elseif status1 == dlstatus.STATUS_ENDDOWNLOADDATA then
                      print('Загрузка обновления завершена.')
                      sampAddChatMessage(('{5BDAD8}'..prefix..'{ffffff}Обновление завершено!'), -1)
                      goupdatestatus = true
                      lua_thread.create(function() wait(500) thisScript():reload() end)
                    end
                    if status1 == dlstatus.STATUSEX_ENDDOWNLOAD then
                      if goupdatestatus == nil then
                        sampAddChatMessage('{5BDAD8}'..prefix..'{ffffff}Обновление прошло неудачно. Запускаю устаревшую версию..', -1)
                        update = false
                      end
                    end
                  end
                )
                end, prefix
              )
            else
              update = false
              sampAddChatMessage('{5BDAD8}'..prefix..' {ffffff}Версия скрипта от {DA5B5B}'..thisScript().version..'{ffffff} числа: Обновление не требуется.', -1)
            end
          end
        else
          sampAddChatMessage('{5BDAD8}'..prefix..'{ffffff} Установлена актуальная версия скрипта от {DA5B5B}'..thisScript().version..' {ffffff}числа. ',-1)
          update = false
        end
      end
    end
  )
  while update ~= false do wait(100) end
end


function apply_custom_style()
  imgui.SwitchContext()
  local style  = imgui.GetStyle()
   colors = style.Colors
   clr    = imgui.Col
  local ImVec4 = imgui.ImVec4
  local ImVec2 = imgui.ImVec2

  style.WindowPadding       = ImVec2(10, 10)
  style.WindowRounding      = 4
  style.ChildWindowRounding = 2
  style.FramePadding        = ImVec2(5, 4)
  style.FrameRounding       = 2
  style.ItemSpacing         = ImVec2(4, 4)
  style.TouchExtraPadding   = ImVec2(0, 0)
  style.IndentSpacing       = 21
  style.ScrollbarSize       = 15
  style.ScrollbarRounding   = 0
  style.GrabMinSize         = 10
  style.GrabRounding        = 1
  style.WindowTitleAlign    = ImVec2(0.5, 0.5)
  style.ButtonTextAlign     = ImVec2(0.5, 0.5)

  colors[clr.Text]                 = ImVec4(1.00, 1.00, 1.00, 1.00)
  colors[clr.TextDisabled]         = ImVec4(0.73, 0.75, 0.74, 1.00)
  colors[clr.WindowBg]             = ImVec4(0.00, 0.00, 0.00, 0.60)
  colors[clr.ChildWindowBg]        = ImVec4(0.00, 0.00, 0.00, 0.00)
  colors[clr.PopupBg]              = ImVec4(0.08, 0.08, 0.08, 0.94)
  colors[clr.Border]               = ImVec4(0.20, 0.20, 0.20, 0.50)
  colors[clr.BorderShadow]         = ImVec4(0.00, 0.00, 0.00, 0.00)
  colors[clr.FrameBg]              = ImVec4(0.71, 0.39, 0.39, 0.54)
  colors[clr.FrameBgHovered]       = ImVec4(0.84, 0.66, 0.66, 0.40)
  colors[clr.FrameBgActive]        = ImVec4(0.84, 0.66, 0.66, 0.67)
  colors[clr.TitleBg]              = ImVec4(0.00, 0.00, 0.00, 0.70)
  colors[clr.TitleBgActive]        = ImVec4(0.00, 0.00, 0.00, 0.85)
  colors[clr.TitleBgCollapsed]     = ImVec4(0.00, 0.00, 0.00, 0.70)
  colors[clr.MenuBarBg]            = ImVec4(0.34, 0.16, 0.16, 1.00)
  colors[clr.ScrollbarBg]          = ImVec4(0.02, 0.02, 0.02, 0.53)
  colors[clr.ScrollbarGrab]        = ImVec4(0.31, 0.31, 0.31, 1.00)
  colors[clr.ScrollbarGrabHovered] = ImVec4(0.41, 0.41, 0.41, 1.00)
  colors[clr.ScrollbarGrabActive]  = ImVec4(0.51, 0.51, 0.51, 1.00)
  colors[clr.ComboBg]              = ImVec4(0.20, 0.20, 0.20, 0.99)
  colors[clr.CheckMark]            = ImVec4(1.00, 1.00, 1.00, 1.00)
  colors[clr.SliderGrab]           = ImVec4(0.71, 0.39, 0.39, 1.00)
  colors[clr.SliderGrabActive]     = ImVec4(0.84, 0.66, 0.66, 1.00)
  colors[clr.Button]               = ImVec4(0.38, 0.21, 0.21, 1.00)
  colors[clr.ButtonHovered]        = ImVec4(0.47, 0.22, 0.22, 0.65)
  colors[clr.ButtonActive]         = ImVec4(0.05, 0.01, 0.01, 0.50)
  colors[clr.Header]               = ImVec4(0.17, 0.84, 0.00, 0.54)
  colors[clr.HeaderHovered]        = ImVec4(0.84, 0.66, 0.66, 0.65)
  colors[clr.HeaderActive]         = ImVec4(0.84, 0.66, 0.66, 0.00)
  colors[clr.Separator]            = ImVec4(0.43, 0.43, 0.50, 0.50)
  colors[clr.SeparatorHovered]     = ImVec4(0.71, 0.39, 0.39, 0.54)
  colors[clr.SeparatorActive]      = ImVec4(0.71, 0.39, 0.39, 0.54)
  colors[clr.ResizeGrip]           = ImVec4(0.71, 0.39, 0.39, 0.54)
  colors[clr.ResizeGripHovered]    = ImVec4(0.84, 0.66, 0.66, 0.66)
  colors[clr.ResizeGripActive]     = ImVec4(0.84, 0.66, 0.66, 0.66)
  colors[clr.CloseButton]          = ImVec4(0.41, 0.41, 0.41, 1.00)
  colors[clr.CloseButtonHovered]   = ImVec4(0.98, 0.39, 0.36, 1.00)
  colors[clr.CloseButtonActive]    = ImVec4(0.98, 0.39, 0.36, 1.00)
  colors[clr.PlotLines]            = ImVec4(0.61, 0.61, 0.61, 1.00)
  colors[clr.PlotLinesHovered]     = ImVec4(1.00, 0.43, 0.35, 1.00)
  colors[clr.PlotHistogram]        = ImVec4(0.90, 0.70, 0.00, 1.00)
  colors[clr.PlotHistogramHovered] = ImVec4(1.00, 0.60, 0.00, 1.00)
  colors[clr.TextSelectedBg]       = ImVec4(0.26, 0.59, 0.98, 0.35)
  colors[clr.ModalWindowDarkening] = ImVec4(0.80, 0.80, 0.80, 0.35)
end
apply_custom_style()
Скрипт имеет автообновление и подкачку библиотек. Использовать на свой страх и риск
 

Вложения

  • Ghetto Territory Helper.luac
    8.5 KB · Просмотры: 41
Последнее редактирование модератором:
  • Нравится
Реакции: rvng

McLore

Известный
559
279
А в чем прикол делать компил и спойлер "кому нужен исходник" не легче не делать компил?
 
  • Нравится
Реакции: Letovv и shitcodes

pulemetov scripts

Участник
Автор темы
21
33
А в чем прикол делать компил и спойлер "кому нужен исходник" не легче не делать компил?
скрипт имеет автообновление, загружен на гитхаб. при загрузки файла .lua гитхаб ломает кодировку, то бишь устанавливает не windows1251, a UTF-8, ну и собственно все русские символы превратятся в закарючку)