function serverCmdUnUseTool(%client)
{
%player = %client.player;
%player.lastUsedTool = %player.currTool;
Parent::serverCmdUnUseTool(%client);
}
There you go, when the player presses Q to hide their inventory, a variable is assigned to their player with the last tool used.