It would require a few functions.
Think of other add-ons that you may reference. This is useful in almost any coding project. I'll give a few examples:
-The disguise kit
The disguise kit un-disguises you when you attack while disguised. The same method should be easily applicable to cloaks.
-Invisibility watches set
Cloaking, durr
You'll need to package Function serverCmdLight(%client) for the light thing. Do something like this:
package CloakPackage
{
function ServerCmdLight(%client)
{
if(isObject(%client.player) && %client.player.getDataBlock().uiName == "Cloakable Player)
{
if(%client.player.isCloaked)
%client.player.unCloak();
else
%client.player.Cloak();
}
else
{
return parent::serverCmdLight(%client);
}
}
};
activatePackage(CloakPackage);
Obviously you'll need to edit that to fit whatever you're doing, but hopefully you get the basic idea.