Quick question about server-side playersay initiating client-side panel

I need to create a server-side playersay, and did, with the following code:



hook.Add("PlayerSay","help",function( ply, bind )
	local bind = string.lower( bind )
	if bind == "!help"
		// call client-side menu
	end
end)


What’s the best way to call the menu from client-side Help()

You could use OnPlayerChat instead to directly do it clientside. Otherwise, you’ll have to use the net library.

Completely forgot about the OnPlayerChat hook. Thanks, works well :slight_smile:
(I forgot how to give the thanks rates, but yeah, thanks)

[editline]22nd August 2015[/editline]

It appears when I type it, it shows up for everyone, and not just me.

and the concommand exists client-side as
concommand.Add(“showhelp”, Help)

[editline]22nd August 2015[/editline]

I added the following and it appears to work:



if bind == "!help" and ply == LocalPlayer() then


Yes the clientside hook makes it show up for everyone, thats why you SHOULD use the netlibrary instead of the hook with the “hacky bypass”.

I think I’d rather use the netlib approach, but what data would I store? I’m use to using netlib’s with actual data stored and not to call just a server-side concommand

OnPlayerChat is not a hacky bypass at all, it just gets called whenever any player chats, even if it’s not LocalPlayer(), which is why it triggered for everyone. All you had to do was to only open the help menu on the client where the guy chatting is LocalPlayer().

Thanks for the input. I guess my issue here is, I want to ensure I’m using the proper and secure method of doing something, and that I am not leaving exploits or anything available for someone to take advantage of. As well as whichever method is less resource intense.

Purely client sided would be the least resource intensive. As to most secure, that’d be through net messages. Just use the PlayerSay hook serverside, then send a net message to the client sending that chat. And on the clients, have the panel appear in the net.Receive function. But since this can’t really be exploited (just opening a help menu?), you’d be better off doing it client side.

Though even using net messages is not secure if you got sensitive stuff that can be exploited in the panel (like god mode or admin control). The only way to be really secure is to have all of these buttons send a message to the server which then checks if you are an admin.

Thanks zet, I appreciate the explaination. Helps out a lot.