Author Topic: Checking If A Client Does Not Have A Add On  (Read 1840 times)

How do you check if a client does not have an add on and do things if they do not have it?

This would be the code your looking for...although I believe it requires something else otherwise it would cause Authentication Errors when trying to host.
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:brianhosting.net/BLAD/uploads/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:brianhosting.net/BLAD/uploads/Client_DRPG.zip>DRPG Client</a> (v" @ $DRPG::ClientVersion @ " ) to play on this server.");
                }
        }


And every single different add-on that uses this method breaks every other one. And RTB, half the time.

use gameconnection::autoadmincheck instead

use gameconnection::autoadmincheck instead

But the client sends no information during that.

But the client sends no information during that.
using onconnectrequest can break things

using onconnectrequest can break things

yes

But there is no communication between the server and the client during the admin check.  I guess you could give the client a clientcmd that sent the info to the server, but I always found pinging responses to be not ideal.

yes

But there is no communication between the server and the client during the admin check.  I guess you could give the client a clientcmd that sent the info to the server, but I always found pinging responses to be not ideal.
Pinging probably isn't that great an option, but it's probably one of the best options.

Fairly easy to do, as well.

Server:
Code: [Select]
package Slayer_Dependencies_GameConnection
{
function GameConnection::autoAdminCheck(%client)
{
%client.isHost = (%client.isLocalConnection() || %client.getBLID() == getNumKeyID());

//snip

//tell the client that Slayer is enabled
commandToClient(%client,'Slayer_Handshake',$Slayer::Server::Version);

//snip

return parent::autoAdminCheck(%client);
}
};
activatePackage(Slayer_Dependencies_GameConnection);

function serverCmdSlayer_Handshake(%client,%version)
{
if(%client.isSpamming())
return;

%client.slayerVersion = %version;
if(%version !$= $Slayer::Server::Version)
{
for(%i=0; %i < getFieldCount($Slayer::Server::CompatibleVersions); %i++)
{
if(getField($Slayer::Server::CompatibleVersions,%i) $= %version)
{
%noReturn = 1;
break;
}
}
if(!%noReturn)
return;
}

%client.slayer = 1;

//snip
}

Client:
Code: [Select]
function clientCmdSlayer_Handshake(%version)
{
slyrClientDebug(1,"Handshake Recieved","Server has Version" SPC %version @ ". Responding...");

if(%version !$= $Slayer::Client::Version)
{
for(%i=0; %i < getFieldCount($Slayer::Client::CompatibleVersions); %i++)
{
%f = getField($Slayer::Client::CompatibleVersions,%i);
if(%f $= %version)
{
%clVersion = %f;
break;
}
}
}

if(%clVersion $= "")
%clVersion = $Slayer::Client::Version;

commandToServer('Slayer_Handshake',%clVersion);
}

That should be pretty easy to adapt to your own mod.

Server:
-Code-

Client:
-Code-

That should be pretty easy to adapt to your own mod.
Would this work?
Server:
Code: [Select]
package Summoning_Dependencies_GameConnection
{
function GameConnection::autoAdminCheck(%client)
{
%client.isHost = (%client.isLocalConnection() || %client.getBLID() == getNumKeyID());

//snip

//tell the client that Server_Summoning is enabled
commandToClient(%client,'Summoning_Handshake',$Summoning::Server::Version);

//snip

return parent::autoAdminCheck(%client);
}
};
activatePackage(Summoning_Dependencies_GameConnection);


function serverCmdSummoning_Handshake(%client,%version)
{
if(%client.isSpamming())
return;

%client.summoningVersion = %version;
if(%version !$= $Summoning::Server::Version)
{
for(%i=0; %i < getFieldCount($Summoning::Server::CompatibleVersions); %i++)
{
if(getField($Summoning::Server::CompatibleVersions,%i) $= %version)
{
%noReturn = 1;
break;
}
}
if(!%noReturn)
return;
}

%client.summoning = 1;

//snip
}

Client:
Code: [Select]
function clientCmdSummoning_Handshake(%version)
{
summoningClientDebug(1,"Handshake Recieved","Server has Version" SPC %version @ ". Responding...");

if(%version !$= $Summoning::Client::Version)
{
for(%i=0; %i < getFieldCount($Summoning::Client::CompatibleVersions); %i++)
{
%f = getField($Summoning::Client::CompatibleVersions,%i);
if(%f $= %version)
{
%clVersion = %f;
break;
}
}
}

if(%clVersion $= "")
%clVersion = $Summoning::Client::Version;

commandToServer('Summoning_Handshake',%clVersion);
}

Yes, but remove this:
Code: [Select]
if(%client.isSpamming())
return;
It's not a default function.

Also, you'll need to define these at the beginning of your script:
Code: [Select]
server: $Summoning::Server::Version, $Summoning::Server::CompatibleVersions
client: $Summoning::Client::Version, $Summoning::Client::CompatibleVersions

Yes, but remove this:
Code: [Select]
if(%client.isSpamming())
return;
It's not a default function.
Done.
Also, you'll need to define these at the beginning of your script:
Code: [Select]
server: $Summoning::Server::Version, $Summoning::Server::CompatibleVersions
client: $Summoning::Client::Version, $Summoning::Client::CompatibleVersions
What should I define them as?

Also where is the part that does things if they do not have the add on?
« Last Edit: October 31, 2011, 06:48:45 AM by jes00 »

Make a clientcmd in the client addon, and then have it check if that clientcmd returns true or something like that when they join, and then it can do something.
Example:

Client:
Code: [Select]
function clientCmdHasMyAddon()
{
    return true;
}

Server:
Code: [Select]
if(commandToClient(%client, '', "HasMyAddon") == true)
{
    dothis();
}
else
{
    dothat();
}
« Last Edit: October 31, 2011, 01:08:15 PM by Ipquarx »

snip
No, that will not work


Done.What should I define them as?
Number, string, whatever you want. Just make sure that whenever you release a new version of the client, that it matches with the server's versions, and that the versions are listed in the CompatibleVersions variables

Also where is the part that does things if they do not have the add on?
You'll need to add a schedule in ::autoAdminCheck that calls another function, which checks the value of %client.summoning
« Last Edit: October 31, 2011, 02:18:25 PM by Headcrab Zombie »

You'll need to add a schedule in ::autoAdminCheck that calls another function, which checks the value of %client.summoning
As in this?
Code: [Select]
function gameConnection::autoAdminCheck(%client)
{
checkVersion(%client);
return parent::autoAdminCheck(%client);
}

function checkVersion(%client);
{
if(%client.summoning <= VERSION NUMBER)
{
%client.delete("You have version " @ %client.summoning @ " of the Summoning Client, you need a new one.");
}
}
Number, string, whatever you want. Just make sure that whenever you release a new version of the client, that it matches with the server's versions, and that the versions are listed in the CompatibleVersions variables
Ok, I don't completely understand.