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", name, password, ip, steamID);
FormatEx(rejectReason, sizeof(rejectReason), "%s", "#Valve_Reject_Server_Full");
return Plugin_Stop;
}
Full example you can see in
scripting/test_onclientpreconnect.sp