How can you tell if a player uses an npc?

What would be the best way to make a hook just like “ENT:Use()”? Apparently it won’t work with npcs and I need a way around. This is what I have below, is there any better way?

[lua]
function UseShopKeeper(pl, ent)
if !IsValid(ent) then return end
if !ent.ShopKeeper then return end
if ent.Used then return end

ent.Used = true
umsg.Start("ShopKeeperUsed", pl)
	umsg.Short(ent.KeeperNumber || 0)
umsg.End()

end
hook.Add(“PlayerUse”, “ShopKeeperUse”, UseShopKeeper)
[/lua]

Side question, does it check both the conditions or stop when the one it is on is true? I don’t want to have it like this and then error out on the second condition because the entity isn’t valid.
[lua]
if !IsValid(ent) || !ent.ShopKeeper then return end
[/lua]

Roleplay Gamemode.

[lua]
Roleplay.StoreNPC = { }

function Roleplay.AddNPC( model, pos, ang, hookedname )
table.insert( Roleplay.StoreNPC, { Model = model, Pos = pos, Ang = ang, Menu = hookedname } )
end


– The Following is to let the npcs hit the ground and then freeze them
– Disables Inter-actions player(S) and npc(S)

RunConsoleCommand(‘ai_disable’, ‘0’);
RunConsoleCommand(‘ai_disabled’, ‘0’);
RunConsoleCommand(‘ai_ignoreplayers’, ‘1’);
timer.Simple(10, RunConsoleCommand, ‘ai_disable’, ‘1’)
timer.Simple(10, RunConsoleCommand, ‘ai_disabled’, ‘1’)
timer.Simple(1, RunConsoleCommand, ‘ai_ignoreplayers’, ‘1’)

Roleplay.AddNPC( “models/Humans/group01/male_07.mdl”, Vector( -1583, -623, -131 ), Angle( 0, 90, 0 ), “Roleplay_ANMenu” )
Roleplay.AddNPC( “models/Humans/NYPD/npc.mdl”, Vector( -1743, -451, -131 ), Angle( 0, -0, 0 ), “Roleplay_JoinPolice” )
Roleplay.AddNPC( “models/humans/group01/fire_02.mdl”, Vector( -1743, -535, -131 ), Angle( 0, -0, 0 ), “Roleplay_JoinFire” )
Roleplay.AddNPC( “models/humans/group01/clo7_04.mdl”, Vector( -1743, -590, -131 ), Angle( 0, -0, 0 ), “Roleplay_JoinMedic” )
Roleplay.AddNPC( “models/Humans/group01/male_01.mdl”, Vector( -1672, -623, -131 ), Angle( 0, 90, 0 ), “Roleplay_BankTeller” )
Roleplay.AddNPC( “models/gman_high.mdl”, Vector( -1064.260254, 2032.624390, -131.968750 ), Angle( 0, 45, 0 ), “Roleplay_DrugDealer” )

function Roleplay.SetupNPC( )

for k, v in pairs( Roleplay.StoreNPC ) do
	
	local NPC = ents.Create( "npc_citizen" )

	NPC:SetPos( v.Pos + Vector( 0, 0, 0 ) )
	NPC:SetAngles( v.Ang )

	NPC:Spawn( )
	NPC:Activate( )

	NPC:SetModel( v.Model )
	
	NPC:SetMoveType( MOVETYPE_NONE )

	NPC.Menu = v.Menu
	
	print( "Spawned a NPC, Model = " .. v.Model .. ", Pos = " .. tostring( v.Pos ) .. ", Ang = " .. tostring( v.Ang ) .. ", and his menu is " .. v.Menu )

end

end

function Roleplay.NPCUse( pl, key )

if ( key == IN_USE ) then

	local tr = util.QuickTrace( pl:GetShootPos( ), pl:GetAimVector( ) * 84, pl )
	
	if ( ValidEntity( tr.Entity ) && tr.Entity.Menu ) then
	
		umsg.Start( tr.Entity.Menu, pl )
		umsg.End( )
		
	end
	
end

end

hook.Add( “InitPostEntity”, “Roleplay_SetupStores”, Roleplay.SetupNPC )
hook.Add( “KeyPress”, “Roleplay_NPCUse”, Roleplay.NPCUse )
[/lua]

Brought to you by Annoyed Tree’s Roleplay Game mode.

If you meant an SNPC then this is what you need :
[lua]function ENT:Initialize()

self:SetUseType( SIMPLE_USE )

end

function ENT:AcceptInput( Name, Activator, Caller )

if( Name == "Use" ) then

end

end[/lua]