yeah... using whitelist by steamID's or set random sv_password to server are easier.
Or you let player connect to inside server, then you give him time to accomplish PIN code, or something.
- There is one trick, what SoureMod admin system use, for password access.
Player command: setinfo <key> <value>
Example:
- Before player connect to "match server", he need set PIN code first, in his console.
Code:
setinfo special_password bv070
- Now when player make connect to server, you can check player info in early state
PHP Code:
public bool OnClientConnect(int client, char[] rejectmsg, int maxlen)
{
char PIN[10];
GetClientInfo(client, "special_password", PIN, sizeof(PIN));
PrintToServer("PIN %s", PIN);
return true; // when you want player get in server, return as true!
}
To block player connecting to server, return bool OnClientConnect as false.
You can also re-format rejectmsg disconnect message.
- This plugin create keyvalue file in ...addons/sourcemod/data/matchpincodes.txt, if file missing.
- File have four random "matchID" entry, in each entry it have ten random "PIN" codes.
- Once plugin is loaded, it pick random matchID entry, and check those PIN codes only.
You can re-check PIN codes with command sm_test, from server console.
- Plugin check player key info "special_password"
PHP Code:
KeyValues kv;
public void OnPluginStart()
{
char path[PLATFORM_MAX_PATH];
BuildPath(Path_SM, path, sizeof(path), "data/MatchPINCodes.txt");
if(!IsRightPIN)
{
char matchID[10];
kv.GetSectionName(matchID, sizeof(matchID))
Format(rejectmsg, maxlen, "MATCH ID: %s\nWrong PIN code: %s\nSet given PIN code in console, before connect to server.\nsetinfo special_password ****\n\n", matchID, PIN);
return false;
}
return true;
}
Hello and thanks a lot for your example here.
Let me first clarify why sv_password won't do. Well we are already using sv_password but running multiple game instances on the same server is a bit hard to administer, and what I would like to do is simply send a pincode to the player, have him enter that, and if validated - let in to the server. Therefore my initial idea was to show an input field or a dialog in the client for the player to enter this pincode in.
Hope this clarifies it a bit