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

How would you check to see if the player has a certain file/add-on?
Add-on?
Client side mod.

File, as in, in the cache?
Can't be done.

Add-on?
Client side mod.

File, as in, in the cache?
Can't be done.
Well, I know theres a way to do this.


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.

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.

Err....I'm having trouble. Anyone mind helping me with the "server sends a command to the client and client responds" part? Heres what I have

server.cs
Code: [Select]
package checkForAddOn_package
{
 function GameConnection::autoAdminCheck(%this)
{
   %parent = parent::autoAdminCheck(%this);
   %this.checkForAddon = schedule(75,0,kickPlayerFromServerForNotHavingACertainAddOn,%this);
   serverCmdkickPlayerFromServerForNotHavingACertainAddOn(%this);
   
    commandtoClient(%client, stopCheckForAddonAutoKick);
   
   return %parent;
 
}



};
activatePackage(checkForAddOn_package);

function kickPlayerFromServerForNotHavingACertainAddOn(%this)
{
echo("kicking player");
findClientByName(%this.name).delete("You must have <a:http://www.apple.com/>this add-on</a> to play on this server.");
}
client.cs
Code: [Select]
function serverCmdstopCheckForAddonAutoKick(%client)
{
  cancel(%this.checkForAddon);
 
return; 
}

Found this in the DRPG client
Code: [Select]
//---MISC---
$DRPG::Client::Version = 0.17;
deactivatePackage(RTB_Client);
package DRPG_Client
{
function GameConnection::setConnectArgs(%a,%b,%c,%d,%e,%f,%g)
{
Parent::setConnectArgs(%a,%b,%c,%d,%e,%f,%g,"\tDRPG\t" @ $DRPG::Client::Version);
}
};
activatePackage(DRPG_Client);
activatePackage(RTB_Client);

erm... kinda.
first off -- "function serverCmdStuff" never goes into client.cs - it just wont work.

The flow works like this:
client joins
server sends a message to the client asking "do you have my addon?"
client gets the message
client sends a response, "yes your addon is loaded"


if the client does NOT have the addon loaded (or activated).  then this happens
server sends a message to the client asking "do you have my addon?"
client gets the message
client ignores the message
server waits for 2 seconds total
server boots the client


server.cs
Code: [Select]
package checkForAddOn_package
  {
   function GameConnection::autoAdminCheck(%this)
     {
      %parent = parent::autoAdminCheck(%this);

      %this.myAddon = false;
      //wait 2 seconds before booting the player to allow for lag
      %this.checkForAddon = schedule(2000,0,kickPlayerFromServerForNotHavingACertainAddOn,%this);
      commandToClient(%client, 'CheckForMyAddon');

      return %parent;
    }
  };
activatePackage(checkForAddOn_package);

function kickPlayerFromServerForNotHavingACertainAddOn(%this)
  {
   if (%this.myAddon == true)
     return;

   echo("kicking player");
   findClientByName(%this.name).delete("You must have <a:http://www.apple.com/>this add-on</a> to play on this server.");
  }

function serverCmdMyAddonIsLoaded(%client)
   {
    %client.myAddon = true;
   }

client.cs
Code: [Select]
function clientCmdCheckForMyAddon()
  {
   commandToServer('MyAddonIsLoaded');
  }

crappy/unreadable code above.
Code: (server.cs) [Select]
package requiredAddOn {
   function gameConnection::autoAdminCheck(%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::autoAdminCheck(%this);
   }
};
activatePackage(requiredAddOn);

function serverCmdAddOnLoaded(%cl) {
   cancel(%cl.addOnTimeout);
   %cl.addOnLoaded = true;
}

Code: (client.cs) [Select]
function clientCmdAddOnCheck() {
   commandToServer('addOnLoaded');
}
« Last Edit: February 14, 2011, 06:30:24 PM by Bauklotz »

crappy/unreadable code above.
Code: (server.cs) [Select]
package requiredAddOn {
   function gameConnection::autoAdminCheck(%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::autoAdminCheck(%this);
   }
};
activatePackage(requiredAddOn);

function serverCmdAddOnLoaded(%cl) {
   cancel(%cl.addOnTimeout);
   %cl.addOnLoaded = true;
}

Code: (client.cs) [Select]
function clientCmdAddOnCheck() {
   commandToServer('addOnLoaded');
}
The code Red_Guy posted is based off mine. XD

Thanks, I'll try this out...




erm... kinda.
first off -- "function serverCmdStuff" never goes into client.cs - it just wont work.

The flow works like this:
client joins
server sends a message to the client asking "do you have my addon?"
client gets the message
client sends a response, "yes your addon is loaded"


if the client does NOT have the addon loaded (or activated).  then this happens
server sends a message to the client asking "do you have my addon?"
client gets the message
client ignores the message
server waits for 2 seconds total
server boots the client


server.cs
Code: [Select]
package checkForAddOn_package
  {
   function GameConnection::autoAdminCheck(%this)
     {
      %parent = parent::autoAdminCheck(%this);

      %this.myAddon = false;
      //wait 2 seconds before booting the player to allow for lag
      %this.checkForAddon = schedule(2000,0,kickPlayerFromServerForNotHavingACertainAddOn,%this);
      commandToClient(%client, 'CheckForMyAddon');

      return %parent;
    }
  };
activatePackage(checkForAddOn_package);

function kickPlayerFromServerForNotHavingACertainAddOn(%this)
  {
   if (%this.myAddon == true)
     return;

   echo("kicking player");
   findClientByName(%this.name).delete("You must have <a:http://www.apple.com/>this add-on</a> to play on this server.");
  }

function serverCmdMyAddonIsLoaded(%client)
   {
    %client.myAddon = true;
   }

client.cs
Code: [Select]
function clientCmdCheckForMyAddon()
  {
   commandToServer('MyAddonIsLoaded');
  }
Thanks to you too. :)


I appreciate the help guys! :D
« Last Edit: February 15, 2011, 07:45:15 AM by Reinforcements »

Oh noes! Its not working....troubleshooting now....

This should work with LAN right?

EDIT: It was kicking me when I started the server, so I had it check for the host.


Code: [Select]
package requiredAddOn {
   function gameConnection::autoAdminCheck(%this) {
      %this.isHost = (%this.isLocalConnection() || %this.bl_id == getNumKeyID());
  if(%this.isHost == true)
  {
      return parent::autoAdminCheck(%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::autoAdminCheck(%this);
   }
};
activatePackage(requiredAddOn);

function serverCmdaddOnLoaded(%cl) {
   cancel(%cl.addOnTimeout);
   %cl.addOnLoaded = true;
}
« Last Edit: February 15, 2011, 10:01:47 AM by Reinforcements »

Well, can I get a copy of this?

Oh noes! Its not working....troubleshooting now....

This should work with LAN right?

EDIT: It was kicking me when I started the server, so I had it check for the host.

It should work for both lan, SP and internet games, and even if your the host.

Ive seen this before myself - where the client.cs of a mod im working on doesnt get executed. a temporary fix would be to exec client.cs in your server.cs (just make sure you take it out before releasing).
Then you dont need the extra complication (and confusion) of checking for the host.

It should work for both lan, SP and internet games, and even if your the host.

Ive seen this before myself - where the client.cs of a mod im working on doesnt get executed. a temporary fix would be to exec client.cs in your server.cs (just make sure you take it out before releasing).
Then you dont need the extra complication (and confusion) of checking for the host.

If I start a server, it will get to the loading screen and stop. The console says I got kicked.(this was before the "check for host") Also, I've tested this with LAN, my bro joined my server with the "client_checkForAddon". He promptly got kicked, and the message popped up. The message worked great, but he had the "client.cs" and still got kicked. I checked that client.cs executed on startup of blockland. It said it did. :0

ok something isnt working right then...
you should not have to check for the host.

stick some echo() statements in all your functions so you can see whats being called and when.

Try increasing the schedule time to 10 seconds:
schedule(10000,0,kickPlayerFromServerForNotHavingACertainAddOn,%this);

Also try packaging a different function like onClientEnterGame.

ok something isnt working right then...
you should not have to check for the host.

stick some echo() statements in all your functions so you can see whats being called and when.

Try increasing the schedule time to 10 seconds:
schedule(10000,0,kickPlayerFromServerForNotHavingACertainAddOn,%this);

Also try packaging a different function like onClientEnterGame.
lol, I though there wasn't one like that so thats why people used the autoAdminCheck. I shall insert echo()'s and report back to you, sir.