Author Topic: Making the client respond to the server(TOPIC NAME CHANGED)  (Read 4270 times)

This is being called
Code: [Select]
function clientCmdAddOnCheck() {
   commandToServer('AddonLoaded');
   echo("responded");
}
But THIS one isn't. :O
Code: [Select]
function serverCmdAddonLoaded(%client) {
   echo("DENIED KICK, YEAH!");
   cancel(%client.addOnTimeout);
   %client.hasTheAddonCheck = true;
}


heres the server.cs
Code: [Select]
package requiredAddOn {
   function gameConnection::onClientEnterGame(%this) {
    //%this.isHost = (%this.isLocalConnection() || %this.bl_id == getNumKeyID());
//if(%this.isHost == true)
//{
    //     return parent::onClientEnterGame(%this);
//}
      commandToClient(%this, 'AddonCheck');
      %this.addOnTimeout = %this.schedule((%this.getPing() * 2) + 100, delete, "You must have <a:apple.com>this add-on</a> to play on this server.");
      return parent::onClientEnterGame(%this);
      echo("the client entered the game, bro");
   }
};
activatePackage(requiredAddOn);

function serverCmdAddonLoaded(%client) {
   echo("DENIED KICK, YEAH!");
   cancel(%client.addOnTimeout);
   %client.hasTheAddonCheck = true;
}
Client.cs:
Code: [Select]
function clientCmdAddOnCheck() {
   commandToServer('AddonLoaded');
   echo("responded");
}

ok - try this version:

Code: [Select]
   function gameConnection::onClientEnterGame(%this)
    {
      echo("the client entered the game, bro");
      commandToClient(%this, 'AddonCheck');
      // no schedule for now
      // schedule( .............

      return parent::onClientEnterGame(%this);
   }

run and see what happens.
does the response from the client EVER show up?

you can also have your friend type: commandToServer('AddonLoaded');
directly into his console.  then watch what you get back
also do the same on your donsole.  both should get your message back.

if that fails to respond, then chances are you have an addon thats interfearing with your own mod, so disable EVERYTHING else and retry.

I can remove all other code in your add-on apart from whatever kind of "update" function you have. There really is no way to enforce this and sending schedules every second won't improve it at all.

I can remove all other code in your add-on apart from whatever kind of "update" function you have. There really is no way to enforce this and sending schedules every second won't improve it at all.
Not really sure what you mean by that.

ok - try this version:

Code: [Select]
   function gameConnection::onClientEnterGame(%this)
    {
      echo("the client entered the game, bro");
      commandToClient(%this, 'AddonCheck');
      // no schedule for now
      // schedule( .............

      return parent::onClientEnterGame(%this);
   }

run and see what happens.
does the response from the client EVER show up?

you can also have your friend type: commandToServer('AddonLoaded');
directly into his console.  then watch what you get back
also do the same on your donsole.  both should get your message back.

if that fails to respond, then chances are you have an addon thats interfearing with your own mod, so disable EVERYTHING else and retry.
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 ;)

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 ;)
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: [Select]
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;
   }
note - there may be syntax errors.. this is not tested.

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.


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: [Select]
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.");
}
}
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.

:0

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

Ma'am*

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);
« Last Edit: February 16, 2011, 11:12:17 PM by Reinforcements »

Not really sure what you mean by that.
You should not be forcing people to download an entire scripted add-on to check for the existence of two sound files.

You should not be forcing people to download an entire scripted add-on to check for the existence of two sound files.
Well, I may have an upcoming project that may require a lot of custom content.

And besides, if they don't like it. They can just leave and go to a different server.
« Last Edit: February 16, 2011, 01:41:43 PM by Reinforcements »

And on another note...
-snip-

No what? I don't get what you're saying here.


That uses a client-sided mod. The server sends a command to the client, and the client-sided mod answers. If the server doesn't get a answer, kickness.
:0

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

Ma'am*
« Last Edit: February 16, 2011, 04:58:01 PM by MegaScientifical »