The main problem is that your using the wrong arguments for commandtoclient:
commandtoclient(%target,'cleval(consolefunction);');
should be
commandtoclient(%target,'cleval','consolefunction');
But most importantly, using this script presents an extreme security vulnerability; any add-on released with this will be fail-binned, crap-on'd, the works.