Blockland Forums > Modification Help
Making the client respond to the server(TOPIC NAME CHANGED)
<< < (8/10) > >>
Red_Guy:

--- Quote from: Reinforcements on February 15, 2011, 06:45:03 PM ---Look at the pic, thats my console after I started the server. It responded by itself. :/

Oh, and I only have the minimal add-ons enabled(sometimes I have the duplicator enabled). Why does it have a problem with a schedule being around? Maybe it's shy ;)

--- End quote ---
ok its working, and your not one of those with 10,000 addons downloaded.  good!

ok so we have confirmed things are spelled right, and the client talks back.

Next is to try the same thing (with no schedule) with a friend connecting to the server.  If he already has your addon, no need to re-send anything -- it should work.  When he joins you will need to have the console open so you can see how long it takes for the "denied kick" message to show up.  its it 1sec?  10mins?  never? or... what?

If that works - then add stuff back in.  I would reccomend using another function to do the kick, rather than schedulign a delete.  it makes things MUCH easier to debug. so try something like this:

--- Code: ---package requiredAddOn {
   function gameConnection::onClientEnterGame(%this)
    {
      echo("the client entered the game, bro");
      commandToClient(%this, 'AddonCheck');
      schedule(5000, 0, "CheckAddonLoaded", %this);

      return parent::onClientEnterGame(%this);
   }
};

function CheckAddonLoaded(%client)
  {
   echo("checking addonLoaded for " @ %client.getPlayerName() );
   if (%client.hasTheAddonCheck)
     {
      echo("Addon check passed");
      return;
     }

   echo("Addon check FAILED: " @ %client.hasTheAddonCheck);
   %client.delete("You must have <a:apple.com>this add-on</a> to play on this server.");
  }

function serverCmdAddonLoaded(%client)
   {
    echo("DENIED KICK for " @ %client.getPlayerName() );
    %client.hasTheAddonCheck = true;
   }

--- End code ---
note - there may be syntax errors.. this is not tested.
Reinforcements:
Good news, it didn't kick me off the server. :D However, I got 2 different results from testing another player joining through LAN. Sometimes it kicked him, sometimes it didn't :/ I have a pic of one of the tests. I also used your code above for the tests.

Destiny/Zack0Wack0:
The reason DRPG uses connection arguments is because I didn't want the "%1 connected." then the instant "%1 has left the game." messages. Unfortunately, connection arguments are totally "static" at the moment, meaning there is only fixed arguments. If it was a more "dynamic" approach, such as appending arguments to a list which get sent to the server, I would recommend it. Regardless, here's the server side code:

--- Code: --- function GameConnection::onConnectRequest(%this,%a,%b,%c,%d,%e,%f,%g,%h,%i)
{
echo("\n" @ %c SPC "trying to connect.");
if(%f !$= "")
{
%this.hasRTB = 1;
%this.rtbVersion = %f;
}
if(getField(%h,1) $= "DRPG")
{
echo(%c SPC "trying to connect with DRPG v" @ getField(%h,2) @ ".");
if(trim(getField(%h,2)) >= trim($DRPG::ClientVersion))
{
%this.hasDRPG = 1;
%this.drpgVersion = getField(%h,2);
Parent::onConnectRequest(%this,%a,%b,%c,%d,%e,%f,%g,%h,%i);
}
else
{
echo(%C SPC "needs to download a new version of DRPG.");
%this.schedule(0,"delete","You need the latest <a:dl.dropbox.com/u/551734/Add-Ons/Client_DRPG.zip>DRPG Client</a> (v" @ $DRPG::ClientVersion @ " ) to play on this server.");
return;
}
}
else
{
echo(%c SPC "trying to connect without DRPG.");
%this.schedule(0,"delete","You need the latest <a:dl.dropbox.com/u/551734/Add-Ons/Client_DRPG.zip>DRPG Client</a> (v" @ $DRPG::ClientVersion @ " ) to play on this server.");
}
}

--- End code ---
I would only use this method for playing around. If you want your mod to actually be allowed on RTB used the previous post's mentioned method. Probably useless information considering I explained something to you then told you not to use it but I was just showing you the mechanics.
MegaScientifical:

--- Quote from: Reinforcements on February 14, 2011, 09:20:15 AM ---:0

Thank you sir, I'll see if I can get something like this to work.

--- End quote ---

Ma'am*
Reinforcements:
Also, wouldn't this interfere with your code if I used the same variable names for mine?

Parent::onConnectRequest(%this,%a,%b,%c,%d,%e,%f,%g,%h,%i);
Navigation
Message Index
Next page
Previous page

Go to full version