• Finding player entity in "CheckPassword" hook
    2 replies, posted
I'm trying to make a script for my local server that doesn't allow a player to join if they're not on my friends list. I was wondering if anyone knew a way to define the connecting player entity in the "CheckPassword" hook. I was planning on using the GetFriendStatus() function but if anyone can suggest a better way of doing it, that would also be great. Any help would be appreciated, thanks.
Well that's how you would do it. However the CheckPassword hook doesn't contain a player entity. You could use their steamID to query the steam server for their friends list without ever having their playerdata. You'd need a steam API key for that. The easier solution is to use a hook that fires at a similar time, but contians a player object. I would recommend either [url]http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index2901.html[/url] or [url]http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/indexc4b1.html[/url] both of those are hooks that are called shortly after a player joins, and contain the player object so that you can run GetFriendStatus() on them.
Ah, thanks. I was hoping I could use "CheckPassword" so it would check the status first thing when a player connected but I guess this will have to do. Thanks for your help! :)
Sorry, you need to Log In to post a reply to this thread.