Author Topic: Check if client has file  (Read 3221 times)

I know its possible but how would you make it so that when the client joins it checks to see if the client has a file (Example: Client_RPG.zip) and if the client does let him connect and if not have him disconnect and tell the client where to download the file. Great example of this in action is DRPG. Thank you!

One of the main ways is to create a client command in the addon that the server calls, and it will have the client send back a command to confirm they've received it. This is called a "handshake."

One of the main ways is to create a client command in the addon that the server calls, and it will have the client send back a command to confirm they've received it. This is called a "handshake."
Heres an example on how to do it

Client
Code: [Select]
function clientCmdClTestHandshake()
{
   commandToServer('TestHandshake');
}
Server
Code: [Select]
function doTestHandshake(%client)
{
   commandToClient(%client,'ClTestHandshake');
}
function serverCmdTestHandshake(%client,%num)
{
   echo("Client has add-on");
}


Is there a way to check and see if the server has received the handshake?

Is there a way to check and see if the server has received the handshake?
thats what serverCmdTestHandshake does...

Sorry, I mean't how to check if it doesn't receive the handshake

Sorry, I mean't how to check if it doesn't receive the handshake
Code: [Select]
function doTestHandshake(%client)
{
   %client.testHandShakeSched = schedule(5000,0,testHandShakeFail,%client);
   commandToClient(%client,'ClTestHandshake');
}
function testHandShakeFail(%client)
{
  cancel(%client.testHandShakeSched);
  echo("Client does not have add-on");
}
function serverCmdTestHandshake(%client)
{
   cancel(%client.testHandShakeSched);
   echo("Client has add-on");
}
you could do something like this, if the client doesn't respond within 5 seconds with a handshake it will be assumed they don't have the addon

That is exactly what I needed to know! Thanks!

Note that the client can easily modify your client add-on, and in worst case, just copy the handshake code and delete everything else.

Examples of a simple handshake, it has a little secure.

Client-Sided

function clientCmdHS_Recieve()
{
   commandToServer('HS_SuccessfulRecieve',"YourCodeHere"); //If you want it to be a little more secured you can just put a code for them
}

function clientCmdHS_onSuccess()
{
   if(!$HS::Successful)
   {
      $HS::Successful = 1;
      echo("Handshake - Successful");
   }
}


Server-Sided


function GameConnection::HS_TestClient(%this)
{
   if(!%this.HS_Client)
   {
      commandToClient(%this,'HS_Recieve');
      %this.HS_TestClientSch = %this.schedule(1000,HS_TestClient2);
      echo("Handshake - Checking " @ %this.getPlayerName());
   }
}

function GameConnection::HS_TestClient2(%this)
{
   if(%this.HS_Client)
   {
      %this.chatMessage("\c6You have the client. Enjoy!");
      echo("Handshake - " @ %this.getPlayerName() @ " has the client.");
   }
   else
   {
      %this.chatMessage("\c6You do not have the client. Please get the client.");
      echo("Handshake - " @ %this.getPlayerName() @ " does not have the client.");
   }
}

function serverCmdHS_SuccessfulRecieve(%this,%code)
{
   if(%code $= "YourCodeHere" && !%this.HS_Client)
   {
      cancel(%this.HS_TestClientSch);
      %this.HS_Client = 1; //Make sure they can't keep doing this
      commandToClient(%this,'HS_onSuccess');
   }
}


This can be used with GameConnection::AutoAdminCheck(%client).
« Last Edit: January 18, 2014, 11:45:00 PM by Advanced Bot »

Examples of a simple handshake, it has a little secure.

Client-Sided

function clientCmdHS_Recieve()
{
   commandToServer('HS_SuccessfulRecieve',"YourCodeHere"); //If you want it to be a little more secured you can just put a code for them
}

function clientCmdHS_onSuccess()
{
   if(!$HS::Successful)
   {
      $HS::Successful = 1;
      echo("Handshake - Successful");
   }
}


Server-Sided


function GameConnection::HS_TestClient(%this)
{
   if(!%this.HS_Client)
   {
      commandToClient(%this,'HS_Recieve');
      %this.HS_TestClientSch = %this.schedule(1000,HS_TestClient2);
      echo("Handshake - Checking " @ %this.getPlayerName());
   }
}

function GameConnection::HS_TestClient2(%this)
{
   if(%this.HS_Client)
   {
      %this.chatMessage("\c6You have the client. Enjoy!");
      echo("Handshake - " @ %this.getPlayerName() @ " has the client.");
   }
   else
   {
      %this.chatMessage("\c6You do not have the client. Please get the client.");
      echo("Handshake - " @ %this.getPlayerName() @ " does not have the client.");
   }
}

function serverCmdHS_SuccessfulRecieve(%this,%code)
{
   if(%code $= "YourCodeHere" && !%this.HS_Client)
   {
      cancel(%this.HS_TestClientSch);
      %this.HS_Client = 1; //Make sure they can't keep doing this
      commandToClient(%this,'HS_onSuccess');
   }
}


This can be used with GameConnection::AutoAdminCheck(%client).
where's the secure
all i see is open source code
i see no secure

where's the secure
all i see is open source code
i see no secure
There is a password.. I call it secure ;-;

There is a password.. I call it secure ;-;
I fail to see how that is supposed to be 'secure'

and in worst case, just copy the handshake code and delete everything else.
That's their own fault. They aren't doing anything but hurting themselves by doing that.

In order for it to be 'secure' it has to be closed source or very difficult to trace.

The latter is more easily obtained.