may try change
for (set .@i,0; .@i<=$avthana_countusers; set .@i, .@i+1 ) {
if ($avthana_winnerparty$!=$avthana_mapusers$[.@i] && $avthana_winnerparty$!=getpartyname(getcharid(1,$avthana_mapusers$[.@i]))) {
getmapxy(.@mapname$,.@mapx,.@mapy,BL_PC,$avthana_mapusers$[.@i]);
if (.@mapname$=="thana_boss") charcommand "#return "+$avthana_mapusers$[.@i];
}
// Get rid of the data at the same time!
set $avthana_mapusers$[.@i],"";
}
into
for (set .@i, 0; .@i <= $avthana_countusers; set .@i, .@i + 1) {
// party name matched
if ($avthana_winnerparty$ == $avthana_mapusers$[.@i])
continue;
// player not found
if (getmapxy(.@mapname$, .@mapx, .@mapy, BL_PC, $avthana_mapusers$[.@i]))
continue;
// party name matched
if ($avthana_winnerparty$ != getpartyname(getcharid(1, $avthana_mapusers$[.@i]))) {
if (.@mapname$ == "thana_boss")
charcommand "#return "+$avthana_mapusers$[.@i];
}
// Get rid of the data at the same time!
set $avthana_mapusers$[.@i],"";
}