Let me try and explain..
afk = 0;
if(afk == 0)
Here is your first mistake. In torquescript, to reference a variable, you must have either a % or a $ before it. $ means that it is a global variable, here you don't want one, so you want % which is a local variable.
findclientbyname(%client);
This line does nothing. You are calling a function to find a client by the given name. The name you are searching for is something like "25723". Its an object ID, not a name. %client is the client, not the name.
If %client was the name, this line would still do nothing. The function findClientByName returns the client, which you are supposed to set to a variable, something like %client = findClientByName(%name); .
MessageAll(",%client SPC "is AFK");
This line you almost had right. With messageAll, the first parameter uses apostrophes instead of quotation marks ( ' instead of " ). Here you only used one quotation mark, which is a fairly common mistake, you just read it somewhere and rewrote it as it looked.
Again, %client is the object ID, not the name. You want to use %client.name as jes00 stated.
Other than that, you just have logic error. Your code will (or should) set %afk to 0, then check if its 0, which it is, and always will be as it never changes in between. You want to store the variable on the client, so that it isn't lost when the function is finished. Using %client.afk is the easiest way to do this.
function ServerCmdAFK(%client)
{
afk = 0;
if(afk == 0)
{
findclientbyname(%client);
MessageAll(",%client SPC "is AFK");
afk = 1;
}
else if(afk == 1)
{
findclientbyname(%client);
MessageAll(",%client SPC "is no longer AFK");
afk = 0;
}
}