I think this works on UC servers. Sadly, the player could simply change their internal IP on their router and in their host file, defeating the purpose. There's no real way to block against Relay users, as they'll always have the ability to change packets (including scripts), thus defeating many detection attempts.
Please note that I haven't coded in GS2 for about a year or two, so this code may not work. It's the general idea, however.
PHP Code:
//#CLIENTSIDE
function onPlayerEnters() {
temp.host = resolvehost("loginserver.graalonline.com");
if(temp.host == 127.0.0.1 || temp.host.starts("192.168.") || temp.host.starts("10.0.")) {
//trigger server
}
}
To sway the relay player away, it'd be best to hide this code in a weapon they wouldn't / couldn't block. For example, their display, a door, or something else.