Hello. When a person talks to one of the NPCs on the server, they will say a message, which will also be printed into the chat with correct formatting (e.g Merchant: Hello, how can I help you?) and after a few seconds a shop will open up.
This is the code I have to do this:
if ( tr.Hit and tr.HitNonWorld and tr.Entity:GetClass() == "npc_monk" ) then umsg.Start("ShopNPCUsed", ply) umsg.End() timer.Simple( 3, function(ply) umsg.Start("MerchantShop", ply) umsg.End() end, ply)
local ply = LocalPlayer() local function NPCShopMenu(ply) surface.PlaySound( "vo/coast/odessa/nlo_cub_hello.wav" ) chat.AddText(Color(255,255,128), "Merchant: ",Color(255,255,255), "Ah! Hello. I'll be right with you." ) end usermessage.Hook("ShopNPCUsed", NPCShopMenu)
The problem is: the sound that is played, the text that is printed into the chatbox, and the shop are seen for all players. I want it to only work for the person who talked to the NPC in the first place.
Any help is GREATLY appreciated.