global function MenuCallbacks_Init void function MenuCallbacks_Init() { AddClientCommandCallback( "LeaveMatch", ClientCommandCallback_LeaveMatch ) } bool function ClientCommandCallback_LeaveMatch( entity player, array args ) { thread WritePersistenceAndLeave( player ) return true } void function WritePersistenceAndLeave( entity player ) { // write player persistence before we leave, since leaving player might load local lobby before server writes persistence, so they won't get newest // not super essential, but a nice qol thing NSEarlyWritePlayerPersistenceForLeave( player ) while ( NSIsWritingPlayerPersistence() ) WaitFrame() // this is a custom concommand which can be called on clients, it causes them to leave and doesn't have issues if they're host ClientCommand( player, "ns_leave_to_lobby" ) }