try this... (haven't tested it so I dunno if it will work but I assume it will/ it should work)
NPC Code:
//KJL's Example
if(created)
setshape 1,Width (in tiles)*16,Height (in tiles)*16;
if(playertouchsme&&(strequals(#g,GuildName)||this.open==1))
setlevel2 level,x,y;
if(playerchats&&strequals(#g,GuildName){
if(strequals(#c,Open Castle))
this.open=1;
elseif(strequals(#c,Close Castle)))
this.open=0;
}