Blockland Forums > Modification Help
Making the client respond to the server(TOPIC NAME CHANGED)
<< < (5/10) > >>
Reinforcements:
Found this in the DRPG client

--- Code: ---//---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);
--- End code ---
Red_Guy:
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: ---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;
   }

--- End code ---

client.cs

--- Code: ---function clientCmdCheckForMyAddon()
  {
   commandToServer('MyAddonIsLoaded');
  }

--- End code ---
Bauklotz:
crappy/unreadable code above.

--- Code: (server.cs) ---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;
}

--- End code ---


--- Code: (client.cs) ---function clientCmdAddOnCheck() {
   commandToServer('addOnLoaded');
}

--- End code ---
Reinforcements:

--- Quote from: Bauklotz on February 14, 2011, 06:27:57 PM ---crappy/unreadable code above.

--- Code: (server.cs) ---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;
}

--- End code ---


--- Code: (client.cs) ---function clientCmdAddOnCheck() {
   commandToServer('addOnLoaded');
}

--- End code ---

--- End quote ---
The code Red_Guy posted is based off mine. XD

Thanks, I'll try this out...





--- Quote from: Red_Guy on February 14, 2011, 06:12:06 PM ---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: ---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;
   }

--- End code ---

client.cs

--- Code: ---function clientCmdCheckForMyAddon()
  {
   commandToServer('MyAddonIsLoaded');
  }

--- End code ---

--- End quote ---
Thanks to you too. :)


I appreciate the help guys! :D
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: ---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;
}
--- End code ---
Navigation
Message Index
Next page
Previous page

Go to full version