Just use the interface for creating new permissions, and use something along the lines of:
Code:
$visitor = XenForo_Visitor::getInstance();
if ($visitor->hasPermission('permission_group_id', 'permission_id')
{
// Do something if they have permission
}
That will work in most cases, otherwise you'll want to use
Code:
$userModel = $this->getModelFromCache('XenForo_Model_User');
$user = $userModel->getUserById($userId);
$user['permission'] = @unserialize($user['global_permission_cache']);
if (XenForo_Permission::hasPermission($user['permissions'], 'permission_group_id', 'permission_id'))
{
// Do something if they have permission
}