• sequencing players
    5 replies, posted
trying to make an entity that changes your sequence, I tried this but got no success and I dont know why exactly: [CODE] function playersequence(ply) local sequence = ply:LookupSequence("injured3") ply:SetSequence(sequence) end function ENT:Use( activator, caller ) if IsValid( caller ) and caller:IsPlayer() then hook.Add("CalcMainActivity", "playerseq", playersequence) end end [/CODE] I've used CalcMainActivity the way I tought it was best, I placed prints in my custom function to see if it works and it gladly does but it doesnt change my sequence?
CalcMainActivity uses returns to set the sequence: [url]https://github.com/Facepunch/garrysmod/blob/03b82174f0884b60d6c1fa4a9a25e55b500ffb27/garrysmod/gamemodes/base/gamemode/animations.lua#L311[/url]
[QUOTE=code_gs;52789369]CalcMainActivity uses returns to set the sequence: [url]https://github.com/Facepunch/garrysmod/blob/03b82174f0884b60d6c1fa4a9a25e55b500ffb27/garrysmod/gamemodes/base/gamemode/animations.lua#L311[/url][/QUOTE] I dont quite understand what to do now? Do I need to set sequence in the arguement and use the hook to set it ?
You have to return your activity and sequence in the hook if you want to see any changes.
[QUOTE=code_gs;52789419]You have to return your activity and sequence in the hook if you want to see any changes.[/QUOTE] so to my understanding, this is how its supposed to be? [CODE] function ENT:Use( activator, caller ) if IsValid( caller ) and caller:IsPlayer() then hook.Add("CalcMainActivity", "playerseq", function(ply, seq) local caller = ply local seq = ply:LookupSequence("injured3") return ply:SetSequence(seq) end) end end [/CODE]
No, you are just returning the SetSequence call, which returns nothing. You should be returning the activity enum and sequence number - you shouldn't be calling SetSequence at all. [editline]17th October 2017[/editline] You'll also have to check if the provided player is the caller (if (ply == caller) then). Lastly, you'll probably have to network it to the local client in question so they see the changes locally.
Sorry, you need to Log In to post a reply to this thread.