Hi, I am a C++ programmer and I am still learning Hercules scripting so my answer will probably be wrong, but I would try something like this.
if( bg_countlogin(sd,false) > 0 && battle_config.bg_double_login && #trusted == 0)
{
sprintf(output,"You cannot join %s queue. Double Login detected.", qd->queue_name);
clif_displaymessage(sd->fd,output);
return 0;
}