Hey dear readers,
first of all my code:
SWEP.PrintName = "Hologram Placer"
SWEP.Author = "Sodaki"
SWEP.Purpose = "Good Thing"
SWEP.Instructions = "Left Click to Clone"
SWEP.Category = "MyShitness"
SWEP.Base = "weapon_base"
SWEP.Slot = 3
SWEP.SlotPos = 5
SWEP.DrawAmmo = false
SWEP.DrawCrosshair = true
SWEP.ViewModel = "models/weapons/c_toolgun.mdl"
SWEP.WorldModel = "models/weapons/w_toolgun.mdl"
SWEP.AnimPrefix = "python"
SWEP.HoldType = "pistol"
SWEP.Spawnable = true
SWEP.AdminSpawnable = false
function SWEP:PrimaryAttack()
if IsValid(holo) then return end
local ply = self.Owner
local pmodel = ply:GetModel()
local pyaw = ply:GetPoseParameter("aim_yaw")
local ppitch = ply:GetPoseParameter("aim_pitch")
local panim = ply:GetSequence()
local pvel = ply:GetVelocity()
--this is not important--
holo = ents.Create("prop_dynamic")
holo:SetModel(pmodel)
holo:SetColor(Color(0, 161, 255, 230))
holo:SetRenderMode(RENDERMODE_TRANSALPHA)
holo:SetPoseParameter("aim_yaw", pyaw)
holo:SetPoseParameter("aim_pitch", ppitch)
holo:SetVelocity(pvel)
holo.Opened = true
holo:SetPos(ply:GetPos())
holo:SetAngles(ply:EyeAngles())
end
function SWEP:Think()
if IsValid(holo) then
if ( holo.Opened ) then
timer.Simple(1, function()
holo:ResetSequence( "taunt_muscle_base" )
end)
holo.Opened = false
else
holo.Opened = true
end
end
end
you can see what i trying to make.. but the copying of the self.Owner movement is not important anymore. I need to get it working that the spawned entity use the "taunt_muscle_base" sequence to make it possible to dance.. it works.. but i try to make this sequence repatable this means it never stops to dance.. so sequence is over he run it again.. but it dont loop the current sequence.
What shall i do to make it looping?
thanks alot
You could try using holo:SequenceDuration( ) to set your timer that resets the sequence. The SequenceDuration( ) function returns the length of the sequence, but needs to be called after the sequence is started. So you could start the sequence, use SequenceDuration( ) to set a timer, then reset it after that period.
As per the Wiki, Entity/SequenceDuration will give you a desired sequence if you pass the sequence ID to it, so that is a lot easier.
Alternatively, if you are doing this in a think hook instead of a timer, just use Entity/GetCycle and check if it is 1. If it is, reset it back to 0 with Entity/SetCycle
this is kinda usefull i replace the swep with a entity and use a think hook now for k,v in pairs ents.GetAll()) and search for each ent with the variable syncdance = true
thanks alot king
Here the code
AddCSLuaFile("cl_init.lua")
AddCSLuaFile("shared.lua")
include( "shared.lua" )
function ENT:SpawnFunction( ply, tr, class )
local pmodel = ply:GetModel()
if ( !tr.Hit ) then return end
local pos = tr.HitPos + tr.HitNormal * 4
local ent = ents.Create( "dancer_ent" )
ent:SetPos( pos )
ent:SetModel( pmodel )
ent:SetColor(Color(0, 161, 255, 230))
ent:SetRenderMode(RENDERMODE_TRANSALPHA)
ent:Spawn()
ent:Activate()
return ent
end
function ENT:Initialize()
self:PhysicsInit( SOLID_VPHYSICS )
self:SetMoveType( MOVETYPE_VPHYSICS )
self:SetSolid( SOLID_VPHYSICS )
self:SetSequence("taunt_muscle_base")
self:SetPlaybackRate(1)
self:SetCycle(.5)
local phys = self.Entity:GetPhysicsObject()
end
function ENT:Think()
self:NextThink(CurTime());
if self:GetCycle() == 1 then
self:SetCycle(.5)
end
return true;
end
sadly that the anim looks so broken when its on cycle 1 (so finished anim) he loops but it looks like a cut if he restarts the animation cuz the sequence dont have a nice begin and end moving..
Sorry, you need to Log In to post a reply to this thread.