That will work fine assuming ibestPlayerT and ibestplayerCT contain valid/connected player ID's on the applicable team. If this is the case, you do not even need to check their team since this has already been established. Another recommendation is to use charsmax( xPlayerNameT/CT ) instead of 31.
Better off showing actual code so we can provide the best method.