LUA скрипт [GS]Stats of the match

xRATx
Начинающий
Статус
Оффлайн
Регистрация
23 Янв 2019
Сообщения
246
Реакции[?]
29
Поинты[?]
2K
Это просто небольшая статистика для игры. xD. Оправданий в говно коде у меня не будет.
Код:
---------------
local http = require("gamesense/http")
local ffi = require 'ffi'

local file_url = "https://raw.githubusercontent.com/DetroitRes/rect/main/rect.jpg"

local loaded_texture = nil

local function downloads(url)
    http.get(url, function(success, response)
        if not success or response.status ~= 200 then
            return
        end

        local content = response.body

        local success, texture_data = pcall(renderer.load_jpg, content, 52, 52)
        if success and texture_data then
            loaded_texture = texture_data
        end
    end)
end
local function main()
    downloads(file_url)
end

main()



---------------
---------------
local text1 = "❯ ❯ ❯ ❯"
local text2 = "❮ ❮ ❮ ❮"
local lasthit = ""
local lasthitDMG = ""
local lasthitG = ""
local missreason = ""
local hit, miss, killss, Death, KDA, hits, missed, drag, offsetX, offsetY, width, KDS, Head, Body, totalDMG, knifed, zeused, blinkTe, Blick, totalDamage = 0, 0, 0, 0, 0, 0, 0, false, 0, 0, 0, 0, 0, 0, 0, 0, 0, false, 0, 0
---------------
local gamesensemenu   = renderer.load_png(readfile("    "),1,1)
---------------
---------------
Zx = ui.new_slider("config", "Presets", "-1980", -client.screen_size(x), client.screen_size(x), 833, true, nil)
Zy = ui.new_slider("config", "Presets", "-720", -client.screen_size(y), client.screen_size(y), 461, true, nil)
Check = ui.new_checkbox("config", "Presets", "Enable Custom color")
zeus = ui.new_checkbox("config", "Presets", "Screenshot ON zeus/knife")
local firstcolor  = ui.new_color_picker("config", "Presets", "Enable", 0.33, 0.33, 0.4)
local secondcolor  = ui.new_color_picker("config", "Presets", "Enable", 0.33, 0.33, 0.4)

local x = ui.get(Zx)
local y = ui.get(Zy)
---------------



client.set_event_callback("player_connect_full", function(self)
local selfs = entity.get_local_player()
local user = client.userid_to_entindex(self.userid)
    if user == selfs then
        hit, miss, killss, Death, KDA, hits, missed, KDS, Head, Body, totalDMG, knifed, zeused, totalDamage = 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
        print("Статистика Сброшена!")
end
end)
client.set_event_callback("cs_win_panel_match", function()
        hit, miss, killss, Death, KDA, hits, missed, KDS, Head, Body, totalDMG, knifed, zeused, totalDamage = 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
        print("Статистика Сброшена!")
end)
client.set_event_callback("player_death", function(event)
    local local_player = entity.get_local_player()
    local userid = client.userid_to_entindex(event.userid)
    local attacker = client.userid_to_entindex(event.attacker)
    local weapon = entity.get_player_weapon(local_player)
    local weapon_classname = entity.get_classname(weapon)

    if local_player == attacker then
        killss = killss + 1
    end
if local_player == attacker then
    if weapon_classname == "CKnife" then
          knifed = knifed + 1
    end   

    if weapon_classname == "CWeaponTaser" then
          zeused = zeused+ 1
    end
end
    if userid == local_player then
        Death = Death + 1
    end
if local_player == attacker then
    if ui.get(zeus) then
        if weapon_classname == "CKnife" or weapon_classname == "CWeaponTaser" then
        client.exec("screenshot")
    end
    end
    end
end)
---------------
client.set_event_callback("aim_miss", function(ee)
local reason = ee.reason
       missreason = reason
    if reason then
        missed = missed + 1
    end
end)
---------------
local hitgroup_names = {'generic', 'head', 'left arm', 'right arm', 'left leg', 'right leg', 'neck', '?', 'gear'}

local function aim_hit(e)
    local group = hitgroup_names[e.hitgroup + 1] or '?'
    local HP = e.damage
    lasthit = string.format(entity.get_player_name(e.target))
    lasthitDMG = string.format(e.damage, entity.get_prop(e.target, 'm_iHealth'))
    lasthitG = string.format(group)
    if group == "head" then
    Head = Head + 1   
    elseif group == 'chest' or 'stomach' or 'neck' then
    Body = Body + 1
    end
    totalDamage = totalDamage + HP
    totalDMG = totalDMG + HP
    hit = hit + 1
end
client.set_event_callback('aim_hit', aim_hit)


client.set_event_callback("round_start", function()
    totalDMG = 0
end)
client.set_event_callback("paint", function()
    local currentTime = globals.curtime()
    ui.set_visible(Zx, false)
    ui.set_visible(Zy, false)
    local r_m, g_m, b_m, a_m = ui.get(firstcolor)
    local r_m1, g_m1, b_m1, a_m1 = ui.get(secondcolor)
---------------       
    x = ui.get(Zx)
    y = ui.get(Zy)
---------------   
    KDS = math.floor(killss / Death * 10) / 10
    KDA = math.floor(killss + Death)
    local result = math.floor((hit / (hit + missed) * 100) * 10) / 10
    local resultHead = math.floor((Head / (Head + Body) * 100) * 10) / 10
---------------   
    local rect_x = x + 1
    local rect_y = y + 1
    local rect_w = 270
    local rect_h = 175
    local center_x = rect_x + rect_w / 2
    local center_y = rect_y + rect_h / 2
---------------   
    if ui.get(Check) then
    renderer.rectangle(rect_x, rect_y, rect_w, rect_h, r, g, b, a)
    renderer.rectangle(rect_x + 19, rect_y + 18, 230, 135, 23, 23, 23, 255)
    renderer.gradient(rect_x, rect_y, rect_w, 5, 139, 87, r_m, g_m, b_m, a_m, r_m1, g_m1, b_m1, a_m1, true)
    renderer.gradient(rect_x + 19, rect_y + 18, 230, 5, r_m, g_m, b_m, a_m, r_m1, g_m1, b_m1, a_m1, true)
    
    else
    renderer.rectangle(rect_x, rect_y, rect_w, rect_h, 12, 12, 12, 255)
    renderer.texture(loaded_texture, rect_x, rect_y, rect_w, rect_h, 155, 55, 255, 60)
    renderer.rectangle(rect_x + 19, rect_y + 18, 230, 135, 23, 23, 23, 255)
    renderer.gradient(rect_x, rect_y, rect_w, 5, 139, 87, 215, 255, 109, 213, 236, 255, true)
    renderer.gradient(rect_x + 19, rect_y + 18, 230, 5, 139, 87, 215, 255, 109, 213, 236, 255, true)
    end
if Death == 0 then
    if KDA >= 2 or KDA == 2 then
        renderer.text(center_x - 27, rect_y + 5, 0, 255, 0, 255, "ad", 110, "K/D  | " .. KDA)
    else
        renderer.text(center_x - 27, rect_y + 5, 255, 0, 0, 255, "ad", 110, "K/D  | " .. KDA)
    end
else
    if KDS >= 2 or KDS == 2 then
        renderer.text(center_x - 27, rect_y + 5, 0, 255, 0, 255, "ad", 110, "K/D  | " .. KDS)
    else
        renderer.text(center_x - 27, rect_y + 5, 255, 0, 0, 255, "ad", 110, "K/D  | " .. KDS)
    end
end
    renderer.text(rect_x + 3, rect_y + 25, 255, 255, 255, 255, "ad", 110,"      ¬  Kills - " ..  killss)
    renderer.text(rect_x + 159, rect_y + 25, 255, 255, 255, 255, "ad", 110,"      ¬  Knifed - " ..  knifed)
    renderer.text(rect_x + 159, rect_y + 35, 255, 255, 255, 255, "ad", 110,"      ¬  Zeused - " ..  zeused)
    renderer.text(rect_x + 3, rect_y + 35, 255, 255, 255, 255, "ad", 110, "      ¬  Death - " .. Death)
    renderer.gradient(rect_x + 19, rect_y + 48, 230, 5, 0, 0, 0, 255, 0, 0, 0, 255, true)
    renderer.text(rect_x + 3, rect_y + 55, 255, 255, 255, 255, "ad", 110, "      ¬  Hits - " .. hit)
    renderer.text(rect_x + 3, rect_y + 65, 255, 255, 255, 255, "ad", 110, "      ¬  Misses - " .. missed)
    if missreason == "" then
    renderer.text(rect_x + 230, rect_y + 65, 255, 255, 255, 255, "ad", 510, "¬ " .. missreason)
    else
    renderer.text(rect_x + 199, rect_y + 65, 255, 255, 255, 255, "ad", 510, "¬ " .. missreason)
    end
    if result <= 50 then
    renderer.text(rect_x + 3, rect_y + 75, 255, 0, 0, 255, "ad", 110, "      ¬  Hits% - " .. result)
    else
    renderer.text(rect_x + 3, rect_y + 75, 255, 255, 255, 255, "ad", 110, "      ¬  Hits% - " .. result)
    end
    renderer.gradient(rect_x + 19, rect_y + 89, 230, 5, 0, 0, 0, 255, 0, 0, 0, 255, true)
    renderer.text(rect_x + 3, rect_y + 95, 255, 255, 255, 255, "ad", 1110, "      ¬  Head - " .. Head)
    renderer.text(rect_x + 3, rect_y + 105, 255, 255, 255, 255, "ad", 110, "      ¬  Body - " .. Body)
    renderer.text(rect_x + 3, rect_y + 115, 255, 255, 255, 255, "ad", 1132320, "      ¬  DMGR - " .. totalDMG)
    if totalDamage <= 9999 then
    renderer.text(rect_x + 155, rect_y + 115, 255, 255, 255, 255, "ad", 1132320, "      ¬ DMGG - " .. totalDamage )
    else
    renderer.text(rect_x + 150, rect_y + 115, 255, 255, 255, 255, "ad", 1132320, "      ¬ DMGG - " .. totalDamage )
    end
    renderer.gradient(rect_x + 19, rect_y + 128, 230, 5, 0, 0, 0, 255, 0, 0, 0, 255, true)
    renderer.text(rect_x + 3, rect_y + 135, 255, 255, 255, 255, "ad", 1132320, "      ¬  HS% - " .. resultHead)
    renderer.text(center_x + 94, rect_y + 4, 255, 255, 255, 255, "ad", 110, text1)
    renderer.text(center_x - 127, rect_y + 4, 255, 255, 255, 255, "ad", 110, text2)
    renderer.text(rect_x + 3, rect_y + 158, 255, 255, 255, 255, "ad", 110, "¬  Last hit: " .. lasthit)
if lasthitG == "" then
    renderer.text(rect_x + 135, rect_y + 158, 255, 255, 255, 0, "ad", 110, "DMG - " .. lasthitDMG)
    renderer.text(rect_x + 195, rect_y + 158, 255, 255, 255, 0, "ad", 110, "- " .. lasthitG)
    else
    renderer.text(rect_x + 135, rect_y + 158, 255, 255, 255, 255, "ad", 110, "DMG - " .. lasthitDMG .. " | " )
    renderer.text(rect_x + 195, rect_y + 158, 255, 255, 255, 255, "ad", 110, "" .. lasthitG)
end
    renderer.text(rect_x + 155, rect_y + 158, 255, 255, 255, 0, "ad", 110, " | ")
    renderer.texture(renderr, rect_x, rect_y, rect_w, rect_h, 255, 255, 255, 255, "f")
    local current_time = globals.curtime()
if resultHead <=70 then
    if math.fmod(current_time, 1) >= 0.5 then
        renderer.text(rect_x + 92, rect_y + 135, 255, 255, 255, 55, "ad", 1132320, "WARNING: Disable BAIM!")
    else
        renderer.text(rect_x + 92, rect_y + 135, 255, 0, 0, 255, "ad", 1132320, "WARNING: Disable BAIM!")
    end
    end
---------------   
---------------   
    if client.key_state(0x01) then
        local mouse_x, mouse_y = ui.mouse_position()
            if not drag then
                if mouse_in_bounds(mouse_x, mouse_y, rect_x, rect_y, rect_w, rect_h) then
                    drag = true
                    offsetX = mouse_x - x
                    offsetY = mouse_y - y
                end
            else
                x = mouse_x - offsetX
                y = mouse_y - offsetY
                ui.set(Zx, x)
                ui.set(Zy, y)
        end
    else
        drag = false
    end
end)
---------------
---------------
function mouse_in_bounds(mouse_x, mouse_y, rect_x, rect_y, rect_w, rect_h)
    return mouse_x >= rect_x and mouse_x <= rect_x + rect_w and mouse_y >= rect_y and mouse_y <= rect_y + rect_h
end
 

Вложения

Последнее редактирование:
Главный модератор
Главный Модератор
Статус
Оффлайн
Регистрация
1 Фев 2020
Сообщения
1,263
Реакции[?]
451
Поинты[?]
97K
что-то слишком много функций.....

code_language.lua:
local function downloads(url)
    http.get(url, function(success, response)
        if not success or response.status ~= 200 then
            return
        end

        local content = response.body

        local success, texture_data = pcall(renderer.load_jpg, content, 52, 52)
        if success and texture_data then
            loaded_texture = texture_data
        end
    end)
end
local function main()
    downloads(file_url)
end

main()
окак
code_language.lua:
if ui.get(zeus) then
        if weapon_classname == "CKnife" or weapon_classname == "CWeaponTaser" then
        client.exec("screenshot")
    end
действительно классная статистика
 
Сверху Снизу