View Single Post
Author Message
spumer
Senior Member
Join Date: Aug 2011
Old 12-12-2015 , 08:59   [L4D2] ConnectHook
Reply With Quote #1

This extension provides a OnClientPreConnect forward (similar to CBaseServer's, and Connect).

Unlike the Connect extension this version supports Left 4 Dead 2 game, but no SteamID validation (engine restrictions).

Unlike the CBaseServer extension this version provides more clear interface to reject clients.

PHP Code:
/**
 * @brief Called very early in the client connect process
 *
 * @param name          Client's name.
 * @param password      Connection password (or the most recently used one).
 * @param ip            Client's IP address.
 * @param steamID       Client's SteamId.  (This is before authentication so it is not guaranteed.)
 * @param rejectReason  Client's connection reject reason. Will be used only if returned action is Plugin_Handled or above.
 */
forward Action:OnClientPreConnect(const String:name[], const String:password[], const String:ip[], const String:steamID[], String:rejectReason[255]); 
You also can use standard "presets" of kick reasons. For example, restrict any connections to the server:

PHP Code:
public Action:OnClientPreConnect(const String:name[], const String:password[], const String:ip[], const String:steamID[], String:rejectReason[255])
{
        
PrintToServer("Name=%s, password=%s, IP=%s, steamID=%s"namepasswordipsteamID);
        
FormatEx(rejectReasonsizeof(rejectReason), "%s""#Valve_Reject_Server_Full");
        return 
Plugin_Stop;

Full example you can see in scripting/test_onclientpreconnect.sp
Attached Files
File Type: gz ConnectHook.tar.gz (15.5 KB, 1002 views)
File Type: so connecthook.ext.2.l4d2.so (56.0 KB, 501 views)
__________________

Last edited by spumer; 12-12-2015 at 09:00.
spumer is offline