if(sub != 0)
void choice(int s) // Choice from GMMenu, Itemmenu or Makemenu received{ // This routine is changed by Magius(CHE) to add Rank_system!	int main, sub,loopexit=0;	char sect[512];	int i;	char lscomm[512],lsnum[512];  // Magius(CHE) for Rank-System	Script *script;	P_CHAR pc_currchar = currchar[s];		main=(buffer[s][5]<<8)+buffer[s][6];	sub=(buffer[s][7]<<8)+buffer[s][8];	    //clConsole.send("main:%i sub:%i \n",main,sub);	// if ((main!=0) && (sub==0)) clConsole.send("add menu (gm menu) closed- including its submenus\n");	if ( main >= 8000 && main <= 8100 )	{		cGuildStone* pStone = dynamic_cast<cGuildStone*>(FindItemBySerial(pc_currchar->guildstone));		if ( pStone != NULL )			pStone->GumpChoice(s,main,sub);	}		if( (main&0xFF00)==0xFF00)	{		if (im_choice(s, main, sub)==0) return;	}	if (main>1246 && main<1255)	{		Skills->DoPotion(s, main-1246, sub, FindItemBySerial(calcserial(addid1[s], addid2[s], addid3[s], addid4[s])));		return;	}	else if (main<ITEMMENUOFFSET) // GM Menus	{//		openscript("menus.scp");		sprintf(sect, "GMMENU %i", main);		script = i_scripts[menus_script];	}	else if ((main>=5256) && (main<8192)) // Tracking fix 12-30-98	{//		openscript("items.scp");		sprintf(sect, "ITEMMENU %i", main-2042);//256);		script = i_scripts[items_script];	}	else if(main>=ITEMMENUOFFSET && main<MAKEMENUOFFSET)	{//		openscript("items.scp");		sprintf(sect, "ITEMMENU %i", main-ITEMMENUOFFSET);		script = i_scripts[items_script];	}	else if(main>=MAKEMENUOFFSET && main<TRACKINGMENUOFFSET)	{//		openscript("create.scp");		sprintf(sect, "MAKEMENU %i", main-MAKEMENUOFFSET);		script = i_scripts[create_script];	}// PolyMorph spell menu (scriptable) by AntiChrist (9/99)	else if(main>=POLYMORPHMENUOFFSET && main<POLYMORPHMENUOFFSET+50)	{		Magic->Polymorph(s,POLYMORPHMENUOFFSET,sub);		return;	}	else // Tracking	{		if((main-TRACKINGMENUOFFSET)>=TRACKINGMENUOFFSET+1&&(main-TRACKINGMENUOFFSET)<=TRACKINGMENUOFFSET+3)		{			if(!sub) return;			if(!Skills->CheckSkill(currchar[s], TRACKING, 0, 1000))			{				sysmessage(s,"You fail your attempt at tracking.");				return;			}			Skills->TrackingMenu(s,sub-1);		}//		openscript("tracking.scp");		sprintf(sect, "TRACKINGMENU %i", main-TRACKINGMENUOFFSET);		script = i_scripts[tracking_script];	}	script->Open();	if (!script->find(sect))	{		closescript();		if (n_scripts[custom_npc_script][0]!=0)		{			openscript(n_scripts[custom_npc_script]);			if (!i_scripts[custom_npc_script]->find(sect))			{				closescript(); //AntiChrist				return;			}		}		if (n_scripts[custom_item_script][0]!=0)		{			openscript(n_scripts[custom_item_script]);			if (!i_scripts[custom_item_script]->find(sect))			{				closescript(); //AntiChrist				return;			}		} else return;	}	script->NextLine();//	read1();	i=0;	script->NextLineSplitted();//	read2(); // Moved by Magius(CHE) for Rank System	loopexit=0;	do	{		if (script1[0]!='}')		{			i++;			if (main>=MAKEMENUOFFSET && main<TRACKINGMENUOFFSET)			{				script->NextLineSplitted();				itemmake[s].needs=str2num(script2);								script->NextLineSplitted();				itemmake[s].minskill=str2num(script2);				itemmake[s].maxskill=itemmake[s].minskill*SrvParams->skillLevel();				// clConsole.send("needs %i, has %i\nskillneed %i, skillhas %i\n",itemmake[s].need,itemmake[s].has,itemmake[s].minskill,pc_currchar->skill[pc_currchar->making]);				// Duke: we must count with the same criteria as in MakeMenu() !				if (    itemmake[s].has<itemmake[s].needs					|| (itemmake[s].has2 && itemmake[s].has2<itemmake[s].needs)					|| (pc_currchar->skill[pc_currchar->making] < itemmake[s].minskill))					i--;    // skip this item			}			script->NextLineSplitted();			strcpy(lscomm,script1);			strcpy(lsnum,script2);			itemmake[s].number=str2num(script2);			script->NextLineSplitted();			if (!strcmp((char*)script1,"RANK"))			{				gettokennum((char*)script2, 0);				itemmake[s].minrank=str2num(gettokenstr);				gettokennum((char*)script2, 1);				itemmake[s].maxrank=str2num(gettokenstr);				script->NextLineSplitted();		// found a rank line, so read one more			} else			{ // Set maximum rank if the item is not ranked!				itemmake[s].minrank=itemmake[s].maxrank=10;			}			if (SrvParams->rank_system()==0)			{				itemmake[s].minrank=itemmake[s].maxrank=10;			}						if (i==sub)			{				script->Close();				scriptcommand(s, ( char*)lscomm,( char*)lsnum);				if (itemmake[s].maxskill<200) itemmake[s].maxskill=200;			}		}	}	while ((script1[0]!='}')&&(i!=sub) && (++loopexit < MAXLOOPS));	if (i!=sub) script->Close();}