CS 压枪文件框架

欢迎来到Concealer的博客 / 2023-05-07 / 原文

==反对外挂,仅为好奇,框架提供只为学习==

local currentRecoilIndex = 1
local currentShotFired = 0
local isInScope = false

-- Recoil patterns for various weapons
local recoilPatterns = {
    ["ak47"] = { },
    ["m4a1"] = { },
    ["famas"] = { },
    ["galilar"] = { },
    ["ump45"] = { },
    ["mp7"] = { },
    ["mp9"] = { },
    ["bizon"] = { },
    ["mac10"] = { },
    ["p90"] = { },
    ["sg556"] = { },
    ["aug"] = { },
    ["ssg08"] = { },
    ["awp"] = { },
    ["g3sg1"] = { },
    ["scar20"] = { },
    ["deagle"] = { },
    ["elite"] = { },
    ["fiveseven"] = { },
    ["glock"] = { },
    ["p250"] = { },
    ["tec9"] = { },
    ["cz75a"] = { },
    ["usp_silencer"] = { },
    ["hkp2000"] = { },
    ["p2000"] = { },
    ["revolver"] = { }
}

-- Get current weapon and set its recoil pattern
local function setCurrentWeapon()
    currentWeapon = entities.GetLocalPlayer():GetWeaponName()
    currentRecoilIndex = 1
    currentShotFired = 0
    
    if recoilPatterns[currentWeapon] ~= nil then
        gui.SetValue("rbot.accuracy.weapon."..currentWeapon..".recoil.min", recoilPatterns[currentWeapon][currentRecoilIndex])
        gui.SetValue("rbot.accuracy.weapon."..currentWeapon..".recoil.max", recoilPatterns[currentWeapon][currentRecoilIndex])
    end
end

-- Callback function for player firing
local function onShotFired(event)
    if event:GetName() == "weapon_fire" and entities.GetByUserID(event:GetInt("userid")):GetIndex() == entities.GetLocalPlayer():GetIndex() then
        currentShotFired = currentShotFired + 1
        if currentShotFired == 1 and recoilPatterns[currentWeapon] ~= nil then
            currentRecoilIndex = 1
            gui.SetValue("rbot.accuracy.weapon."..currentWeapon..".recoil.min", recoilPatterns[currentWeapon][currentRecoilIndex])
            gui.SetValue("rbot.accuracy.weapon."..currentWeapon..".recoil.max", recoilPatterns[currentWeapon][currentRecoilIndex])
        end
    end
end

-- Callback function for player switching weapons
local function onWeaponSwitch(event)
    if event:GetName() == "item_equip" and entities.GetByUserID(event:GetInt("userid")):GetIndex() == entities.GetLocalPlayer():GetIndex() then
        setCurrentWeapon()
    end
end

-- Callback function for player using scope
local function onPlayerUseScope(event)
    if event:GetName() == "player_spawned" and entities.GetLocalPlayer():GetPropEntity("m_hActiveWeapon"):GetWeaponID() == 40 then
        isInScope = true
    elseif event:GetName() == "player_spawned" and entities.GetLocalPlayer():GetPropEntity("m_hActiveWeapon"):GetWeaponID() ~= 40 then
        isInScope = false
    elseif event:GetName() == "player_hurt" and entities.GetByUserID(event:GetInt("userid")):GetIndex() == entities.GetLocalPlayer():GetIndex() then
        isInScope = false
    end```
如有感兴趣的小伙伴可以深入研究~