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

No, that will not work
Sorry, i made a mistake.
Here:

Client:
Code: [Select]
function clientCmdHasMyAddon()
{
    commandToServer('HasAddon');
}
Server:
Code: [Select]
function serverCmdHasAddon(%client)
{
    %client.hasClient = true;
}
Then you could do a if-else and such.

Here:

Client:
Code: [Select]
function clientCmdHasMyAddon()
{
    commandToServer('HasAddon');
}
Server:
Code: [Select]
function serverCmdHasAddon(%client)
{
    %client.hasClient = true;
}
Then you could do a if-else and such.
Your way seems a lot more simple but does it work?

Yes, I've used it before. it works 100%.
just put this into autoAdminCheck or onConnectRequest (depending if you want no join/leave message or not):
Code: [Select]
commandToClient(%client, '', 'HasMyAddon');
if(%client.hasClient == true)
{
    doThis();
}
else
{
    doThat();
}
UBEREDIT: whut now Headcrab.
« Last Edit: October 31, 2011, 04:55:23 PM by Ipquarx »

As in this?
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.");
   }
}
Add schedule(3000,0,checkVersion,%client); to the bottom of the preexisting autoAdminCheck package, there's no need for another package.
%client.summoning will be a bool value, not a version number. 1 if the client has the add-on, undefined if they don't

Ok, I don't completely understand.
When you release the first client, set the version variables on the client and server to equal 1.
When you release the second client, change the version variables to 2, and add 1 to the compatible versions variables, if you want them to be able to use the old version.
When you release the third client, change the version variables to 3, and add 2 to the compatible versions variables (seperated by a tab, \t) if you want them to be able to use the old version

Your way seems a lot more simple but does it work?
It's simpler because it doesn't allow for version checks like the previously posted code does. You wouldn't be able to automatically disconnect the client and give them a download link.

UBEREDIT: whut now Headcrab.
Due to latency, your code will always run doThat()
This is why I said to use a schedule, to allow the client time to respond.
« Last Edit: October 31, 2011, 05:54:26 PM by Headcrab Zombie »

I would allow at least three seconds before deciding the client doesn't have the mod.

Client:
Code: [Select]
function clientCmdHasMyAddon()
{
    commandToServer('HasAddon', $curversion);
}
Server:
Code: [Select]
function serverCmdHasAddon(%client, %version)
{
    if(%version == $modversioncurrent)
        %client.hasClient = true;
    else
        %client.hasClient = false;
}
And then you can add in the schedule.
This will check for the version number.

My code tells you if the client has or doesn't have the mod. Here's a simpler version with the extra stuff removed:

Server:
Code: [Select]
package Slayer_Dependencies_GameConnection
{
function GameConnection::autoAdminCheck(%client)
{
//tell the client that Slayer is enabled
commandToClient(%client,'Slayer_Handshake',$Slayer::Server::Version);

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

function serverCmdSlayer_Handshake(%client,%version)
{
%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)
{
//****************The client does not have the mod!******************
//The client also doesn't have the mod if they don't call this serverCmd
return;
}
}

//********************The client has the mod!**************************
%client.slayer = 1;
}

Client:
Code: [Select]
function clientCmdSlayer_Handshake(%version)
{
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);
}

client code does not need to be that complicated.
just do the command with the current version.
if it doesnt match, then return.

What if you have an updated client but there are other client versions that work as well?