• Get Keypress on caller of entity
    6 replies, posted
I've been trying to make an jetpack ent whole day and still got error after some fail attempt First I tried to add hook in the use function, it work but the hook got override everytime so only 1 ply can use it Then I move it out but I can't figure it out how to pass the caller var to other function [code]if SERVER then function ENT:Initialize() self:SetModel("models/thrusters/jetpack.mdl") self:PhysicsInit(SOLID_VPHYSICS) self:SetMoveType(MOVETYPE_VPHYSICS) self:SetSolid(SOLID_VPHYSICS) local phys = self:GetPhysicsObject() if phys:IsValid() then phys:Wake() end self:SetUseType(SIMPLE_USE) end function ENT:Use(caller) caller:SetVar("jetpack", true) end hook.Add("Move", "A_Name", function(caller) if caller:GetVar("jetpack", false) == true and caller:KeyPressed(IN_USE) then caller:SetVelocity(caller:EyeAngles():Forward() * -20) end end) else function ENT:Draw() self:DrawModel() end end[/code]
It's not getting overriden.. [img]http://puu.sh/t6Mrr/2f1faf9345.png[/img]
[QUOTE=Netheous;51605202]It's not getting overriden.. [img]http://puu.sh/t6Mrr/2f1faf9345.png[/img][/QUOTE] But then why it just work on 1 ply
[QUOTE=Moat;51605321]You're not changing the hook identifier, so it just replaces the existing one.[/QUOTE] So then what am I supposed to do to make this work random name for hook? I'm so confused
hook.Add just does hook.GetTable["Event"]["Identifier"] = func() If you keep adding "Identifier", then you obviously will keep overwriting that, in last thread, someone already gave you a solution, but this is the worst way to think the situation In my opinion, i would create the hook and check if player has a condition than creating the same hook every time
[QUOTE=gonzalolog;51605393]hook.Add just does hook.GetTable["Event"]["Identifier"] = func() If you keep adding "Identifier", then you obviously will keep doing that, in last thread, someone already gave you a solution, but this is the worst way to think the situation In my opinion, i would create the hook and check if player has a condition than creating the same hook every time[/QUOTE] But then you will create the same hook identifier and it will replace the before again [editline]31st December 2016[/editline] Offtopic but happy new year guys Maybe not at your country but we just pass 00:00
Sorry, you need to Log In to post a reply to this thread.