GMOD LUA - 冻结并强制切换到“按键”

(用于 Gmod DarkRP 服务器的代码)

所以我想编辑冻结玩家的 physgun 脚本(在这里找到[https://forums.ulyssesmod.net/index.php?topic=8265.0)](https://forums.ulyssesmod.net/index.php?topic=8265.0%EF%BC%89,使它也在您拿起玩家(当他们破坏或杀死玩家时)时强制他们转移到“按键”。 应该很容易,但是脚本就是不起作用... 有人有什么想法或建议吗?已经尝试将代码放在 autorun 和 server autorun 中。 谢谢!

ps。 第一篇帖子,如果我做错了什么,对不起

function GODMODE( ply, dmginfo) if(ply:GetNWInt(“GOD”) == 1) then
        dmginfo:ScaleDamage(0)
    end

hook.Add(“EntityTakeDamage”, “GODMODE”, GODMODE)
    end

hook.add(“PhysgunDrop”, “ply_physgunfreeze”, function(ply, ent)
    hook.Remove(“PhysgunDrop”, “ulxPlayerDrop”)

    ent._frozen = false if( ent:IsPlayer()) then
        ent.SetMoveType(ply:KeyDown(IN_ATTACK2) and MOVETYPE_NOCLIP or MOVETYPE_WALK)

    if(ply:KeyDown(IN_ATTACK2)) then
        ent:Freeze(true)
        RunCOnsoleCommand( “use”, “keys” )
        ent:SetNWInt(GODMODE, 1)
        ent:DisallowSpawning( not should_unfreeze)
        ulx.setNoDie(ent, not should_unfreeze)
    else
        ent:Freeze(false)
        ent:SetNWInt(GODMODE, 0)
        ent:DisallowSpawning(false)
        ulx.setNoDie(ent, should_unfreeze)

        end
    if SERVER then if not ent:Alive() then
            ent:Spawn()
            self:PlayerSpawn(ent)
            ent:SetPos(ply:GetEyeTrace().HitPos)
        end
    end
    return
end
end)

    hook.Add(“PhysgunPickup”, “ply_frozen”, function(pl, ent)
        if (ent:IsPlayer() )then
            ent._frozen = true
            print( “Entity is a player!” )
            RunConsoleCommand( “use”, “keys”)
        else
            print( “Entity is not a player!” )
            return false
        end
    end)

    function playerdies( ply, weapon, killer ) if(ply._frozen)then
        return false
    else
        return true
    end

hook.Add(“CanPlayerSuicide”, “playerNoDeath”, playerDies)
    end
点赞