I found a solution. Even though the author may have forgotten about this post, I'll show you the solution:
Okay, here's the code, but what's going on here?
Well, first you need to get the player's uuid, because there is no information whether the server is offline or online. On offline...