is there a way to hook something if u use on a npc , i mean like if i click e on the npc it will hook a command , how do i make that?
//thanks
[lua]
hook.Add( "PlayerUse", "FindNPC", function( ply )
local AimE = ply:GetEyeTraceNoCursor().Entity
local trace = ply:GetEyeTrace()
if AimE:IsNPC() and trace.HitPos:Distance(ply:GetShootPos()) <= 75 then
-- Do shit
end
end)
[/lua]
:)
[QUOTE=blown25;21860098]but i want a specific npc not everyone D'=[/QUOTE]
Wich npc?
I mean like.. for example "npc_barney".
Leave it as Dragge put it. You don't need to edit the unique name. Just where he put 'Do shit'
Eh, Ninjad.
[QUOTE=Dragge;21860126]Wich npc?
I mean like.. for exmaple "npc_barney".[/QUOTE]
kleiner
[lua]hook.Add( "PlayerUse", "FindNPC", function( ply )
local AimE = ply:GetEyeTraceNoCursor().Entity
local trace = ply:GetEyeTrace()
if AimE:IsNPC() and trace.HitPos:Distance(ply:GetShootPos()) <= 75 then
if Aime:GetClass()=="npc_kleiner" then
-- Do shiiiit
end
end
end)
[/lua]
[QUOTE=Dragge;21860217][lua]hook.Add( "PlayerUse", "FindNPC", function( ply )
local AimE = ply:GetEyeTraceNoCursor().Entity
local trace = ply:GetEyeTrace()
if AimE:IsNPC() and trace.HitPos:Distance(ply:GetShootPos()) <= 75 then
if Aime:GetClass()=="npc_kleiner" then
-- Do shiiiit
end
end
end)
[/lua][/QUOTE]
thank you :)
Sorry, you need to Log In to post a reply to this thread.