Kind of reminds me of Armada by Ernest Cline.
Zack Lightman glances out his classroom window and spots a UFO. The ship he’s staring at is straight out of the video game he plays every night, a hugely popular online air combat simulator called Armada, in which gamers protect Earth from alien invaders. He is fairly skilled at the game, having placed in the top ten among millions of users, however in real life, he is just a high school senior with a reputation of having a short fuse and getting into trouble.
He works part-time at a video game shop where his boss Ray surprises him with a fancy new controller for Armada as an early graduation gift. He tries it out on one of the new special missions on Armada that involves attacking the home planet of the aliens but the Earth team fails.
Some time later a shuttlecraft with the Earth Defense Alliance (EDA) logo lands. Ray is one of the passengers, and he invites Zack to join him to a top-secret military facility in Nebraska.
There, he learns the EDA is real, that there are actually aliens from Europa planning to invade the planet with ships as shown in the Armada game, and that the EDA had been using Armada to train soldiers to pilot drone ships to protect Earth from the Europans and to identify which gamers would be best for the task.