Yes. Anything that can be done in WHM, can be a function in this script. However your code is wrong. The function should look like this one:
PHP Code:
function addpkg ($host,$user,$accesshash,$usessl,$pkgname,$pkgquota,$pkghasshell,$pkgmaxftp,$maxpop,$pkgmaxlst,$pkgmaxsql,$pkgmaxsub,$pkgmaxpark,$pkgmaxaddon,$pkgcgi,$pkgfrontpage,$pkgbwlimit,$pkgcpmod,$pkgfeaturelist) {
$result = whmreq("/scripts2/addpkg?name=${pkgname}"a=${pkgquota}&hasshell=${pkghasshell}&maxftp=${pkgmaxftp}&maxpop=${pkgmaxpop}&maxlst=${pkgmaxlst}&maxsql=${pkgmaxsql}&maxsub=${pkgmaxsub}&maxpark=${pkgmaxpark}&maxaddon=${pkgmaxaddon}&cgi=${pkgcgi}&frontpage=${pkgfrontpage}&bwlimit=${pkgbwlimit}&cpmod=${pkgcpmod}&featurelist=${pkgfeaturelist}&nohtml=1",$host,$user,$accesshash,$usessl);
if ($cpanelaccterr != "") { return; }
return $result;
}