Hands Up Posture

I have this addon called “Animation Editor” that came with PAC3. I was wondering how I would apply a posture animation to a SWEP?

Here’s the code it generated:



RegisterLuaAnimation('Hands Up', {
	FrameData = {
		{
			BoneInfo = {
				['ValveBiped.Bip01_R_UpperArm'] = {
					RU = -80,
					RR = 90
				},
				['ValveBiped.Bip01_R_Forearm'] = {
					RU = 288
				},
				['ValveBiped.Bip01_L_UpperArm'] = {
					RU = -80,
					RR = -90
				},
				['ValveBiped.Bip01_L_Forearm'] = {
					RU = 288
				}
			},
			FrameRate = 1
		}
	},
	Type = TYPE_POSTURE
})


If it’s the animation editor I’m thinking of, you can try doing this:

[lua]
function SWEP:Deploy()
if (SERVER and IsValid(self.Owner)) then
self.Owner:ResetLuaAnimation(“Hands Up”)
end
end

function SWEP:Holster()
if (SERVER and IsValid(self.Owner)) then
self.Owner:StopLuaAnimation(“Hands Up”)
end

return true

end
[/lua]

Well, it plays the animation. But I want it to just show the player with his hands up in the air. The editor shows it the correct way with the player with his hands up.

[editline]27th April 2016[/editline]

I’m editing the DarkRP keys weapon, here’s my code:



AddCSLuaFile()

if SERVER then
    AddCSLuaFile("cl_menu.lua")
    AddCSLuaFile("handsup.lua")
end

if CLIENT then
    SWEP.PrintName = "Keys"
    SWEP.Slot = 1
    SWEP.SlotPos = 1
    SWEP.DrawAmmo = false
    SWEP.DrawCrosshair = false

    include("cl_menu.lua")
    include("handsup.lua")
end

SWEP.Author = "DarkRP Developers"
SWEP.Instructions = "Left click to lock
Right click to unlock
Reload for door settings or animation menu"
SWEP.Contact = ""
SWEP.Purpose = ""
SWEP.IsDarkRPKeys = true

SWEP.WorldModel = ""

SWEP.ViewModelFOV = 62
SWEP.ViewModelFlip = false
SWEP.AnimPrefix  = "rpg"

SWEP.UseHands = true

SWEP.Spawnable = true
SWEP.AdminOnly = true
SWEP.Category = "DarkRP (Utility)"
SWEP.Sound = "doors/door_latch3.wav"
SWEP.Primary.ClipSize = -1
SWEP.Primary.DefaultClip = 0
SWEP.Primary.Automatic = false
SWEP.Primary.Ammo = ""

SWEP.Secondary.ClipSize = -1
SWEP.Secondary.DefaultClip = 0
SWEP.Secondary.Automatic = false
SWEP.Secondary.Ammo = ""

function SWEP:Initialize()
    self:SetHoldType("normal")
end

function SWEP:Deploy()
    --[[if CLIENT or not IsValid(self:GetOwner()) then return true end
    self:GetOwner():DrawWorldModel(false)
    return true]]

    if (SERVER and IsValid(self.Owner)) then
        self.Owner:SetLuaAnimation("freeze")
    end
end

function SWEP:Holster()
    if (SERVER and IsValid(self.Owner)) then
        self.Owner:StopLuaAnimation("freeze")
    end

    return true
end

function SWEP:PreDrawViewModel()
    return true
end

local function lookingAtLockable(ply, ent)
    local eyepos = ply:EyePos()
    return IsValid(ent)             and
        ent:isKeysOwnable()         and
        not ent:getKeysNonOwnable() and
        (
            ent:isDoor()    and eyepos:Distance(ent:GetPos()) < 65
            or
            ent:IsVehicle() and eyepos:Distance(ent:NearestPoint(eyepos)) < 100
        )

end

local function lockUnlockAnimation(ply, snd)
    ply:EmitSound("npc/metropolice/gear" .. math.floor(math.Rand(1,7)) .. ".wav")
    timer.Simple(0.9, function() if IsValid(ply) then ply:EmitSound(snd) end end)

    local RP = RecipientFilter()
    RP:AddAllPlayers()

    umsg.Start("anim_keys", RP)
        umsg.Entity(ply)
        umsg.String("usekeys")
    umsg.End()

    ply:AnimRestartGesture(GESTURE_SLOT_ATTACK_AND_RELOAD, ACT_GMOD_GESTURE_ITEM_PLACE, true)
end

local function doKnock(ply, sound)
    ply:EmitSound(sound, 100, math.random(90, 110))
    umsg.Start("anim_keys")
        umsg.Entity(ply)
        umsg.String("knocking")
    umsg.End()

    ply:AnimRestartGesture(GESTURE_SLOT_ATTACK_AND_RELOAD, ACT_HL2MP_GESTURE_RANGE_ATTACK_FIST, true)
end

function SWEP:PrimaryAttack()
    local trace = self:GetOwner():GetEyeTrace()

    if not lookingAtLockable(self:GetOwner(), trace.Entity) then return end

    self:SetNextPrimaryFire(CurTime() + 0.3)

    if CLIENT then return end

    if self:GetOwner():canKeysLock(trace.Entity) then
        trace.Entity:keysLock() -- Lock the door immediately so it won't annoy people
        lockUnlockAnimation(self:GetOwner(), self.Sound)
    elseif trace.Entity:IsVehicle() then
        DarkRP.notify(self:GetOwner(), 1, 3, DarkRP.getPhrase("do_not_own_ent"))
    else
        doKnock(self:GetOwner(), "physics/wood/wood_crate_impact_hard2.wav")
    end
end

function SWEP:SecondaryAttack()
    local trace = self:GetOwner():GetEyeTrace()

    if not lookingAtLockable(self:GetOwner(), trace.Entity) then return end

    self:SetNextSecondaryFire(CurTime() + 0.3)

    if CLIENT then return end

    if self:GetOwner():canKeysUnlock(trace.Entity) then
        trace.Entity:keysUnLock() -- Unlock the door immediately so it won't annoy people
        lockUnlockAnimation(self:GetOwner(), self.Sound)
    elseif trace.Entity:IsVehicle() then
        DarkRP.notify(self:GetOwner(), 1, 3, DarkRP.getPhrase("do_not_own_ent"))
    else
        doKnock(self:GetOwner(), "physics/wood/wood_crate_impact_hard3.wav")
    end
end

function SWEP:Reload()
    local trace = self:GetOwner():GetEyeTrace()
    if not IsValid(trace.Entity) or (IsValid(trace.Entity) and ((not trace.Entity:isDoor() and not trace.Entity:IsVehicle()) or self.Owner:EyePos():Distance(trace.HitPos) > 200)) then
        --if CLIENT then RunConsoleCommand("_DarkRP_AnimationMenu") end
        return false
    end
    if SERVER then
        umsg.Start("KeysMenu", self:GetOwner())
        umsg.End()
    end
end


then your animation is no “Idle” animation/repeating animation, never did use that editor but is there a option like “steady”? since you mentioned PAC3 editor and I saw a youtube video of it.

No, I don’t see a option similar to “steady.”