• On PhysgunPickup for a certain entity.
    3 replies, posted
ok, before i start i would like to let all of you know that i am a very very beginner coder and i dont know much. But i had set up a function for physgunpickup and used the physgunpickup hook.add but i realised shortly after that the function would be called whenever anyone tried to physgun anything rather than just the entity which i wanted it to be called on. I was wondering how i could set it up so that the function would only run when a plyer physgunned a certain entity rather than everything. i know this is probably a simple fix but as i said, Im only a beginner coder in lua. Thanks in advance [CODE]function physgunned(ply, moneyevent) PrintMessage( HUD_PRINTCENTER, "The Case has been physgunned by " ..ply:Nick()..". Removing Case") ents.FindByClass( "moneyevent" )[1]:Remove(moneyevent) BroadcastLua("surface.PlaySound(\"sound/moneyevent/hitsound.wav\")") end hook.Add("PhysgunPickup", "whenpickedup", physgunned)[/CODE]
Just add an If statement to check if it's the entity you want the code to run on when picked up.
can you please explain how i would do so?
[CODE] if ( !moneyevent:GetClass() == "moneyevent") then return end -- This checks if the entity is moneyevent if it not it does not run the code below it. [/CODE] Place this underneath the line containing the function deceleration.
Sorry, you need to Log In to post a reply to this thread.