Blockland Forums > Modification Help
GameConnection::onConnectRequest script fails authentication.
Nexus:
I made a whitelist mod, which works exactly like what you are trying to do. Sadly, the reason you cannot do an onconnectrequest is because the client does not yet exist at this point. I got mine to work by making it go off of the auto-admin check, but it will display a "blahblah connected" and "blahblah has left the game" message if you make the delete in a schedule, which is the safest way to go. There may be other functions you can use that are called before, but the only one that I found may cause your server to break if the client is deleted at that point.
Edit: here
--- Code: ---if(isFile("Add-Ons/System_ReturnToBlockland/server.cs")){
if(!$RTB::RTBR_ServerControl_Hook) exec("Add-Ons/System_ReturnToBlockland/RTBR_ServerControl_Hook.cs");
RTB_registerPref("White List", "White List", "$Pref::Server::WL", "string 512", "Server_WhiteList", "", 0, 0);
RTB_registerPref("Enabled", "White List", "Pref::Server::WLE", "bool", "Server_WhiteList", 0, 0, 0);
}
function serverCmdpurge(%c){
if(%c.isSuperAdmin && $Pref::Server::WLE){
messageAll("", %c.name @" \c6has purged the server!");
for(%a=0; %a<clientGroup.getCount(); %a++){
if(!onWL(%s = clientGroup.getObject(%a))) %s.schedule(0, "delete","You need to be on the Whitelist to play on this server!");
}
}
}
function onWL(%s){
for(%a=0; %a<getWordCount($Pref::Server::WL); %a++){
if(getWord($Pref::Server::WL, %a) $= %s) return 1;
}
return 0;
}
package WL{
function GameConnection::autoAdminCheck(%c){
if($Pref::Server::WLE){
if(onWL(%c.bl_id)) Parent::autoAdminCheck(%c);
else{
echo("\n" @ %c.name SPC "is not on white list!");
%c.schedule(0, "delete","You need to be on the Whitelist to play on this server!");
}
}else Parent::autoAdminCheck(%c);
}
};activatePackage(WL);
--- End code ---
Ipquarx:
okay, so your saying its not possible to have my mod skip the blah connected and blah disconnected messages from the server? because i recently uploaded it to rtb, and it was failed because of just that.
Nexus:
--- Quote from: Ipquarx on April 30, 2011, 03:45:27 PM ---okay, so your saying its not possible to have my mod skip the blah connected and blah disconnected messages from the server? because i recently uploaded it to rtb, and it was failed because of just that.
--- End quote ---
If you really need it not to have those messages, I would suggest a trace(1); to find a suitable replacement function for yourself.
ZSNO:
onConnectRequest blocked, use autoAdminCheck
Ipquarx:
--- Quote from: ZSNO on April 30, 2011, 06:25:19 PM ---onConnectRequest blocked
--- End quote ---
huh?
--- Quote from: ZSNO on April 30, 2011, 06:25:19 PM ---use autoAdminCheck
--- End quote ---
i already said that my mod was failed because i used autoadmincheck. if i want it uploaded to rtb (which i do) i need to have it in a diffrent function.