Hello,
First let me address your initial findings. The reason for the check to see if a player is online is because when a player is online, their data has already been loaded from the database and stored in memory to be used by the game-server. In other words, the data inside the database isn't actively used while a player is in-game; the data inside a database only exists to keep record of player data while a player is offline. When a player logs off, the data inside the database is overwritten with the player's updated data. That said, removing the logged in check will result in player's not being rewarded for voting while in-game because those accredited rewards are overwritten when the player logs out with the player's updated data.
For example, when a player logs in, their data is loaded from the database. Let's say this player had 0 nx credit. When the player logs in, we expect this player to have 0 nx credits. Let's assume this player didn't gain any nx credits in-game while logged in. If this player votes, your script gives the player his/her rewards by updating the accounts table with +8000 nx credits. When the player logs out, the value for nx credits the player had in-game will overwrite the newly gained +8000 nx credit. This is why values are being reverted.
Now let's address what you can do to allow players to vote while logged in. There are two ways you can achieve this: through the use of a (1) socket or (2) worker. (1) With a socket, when you receive a response from GTOP100, you can notify your server to give the player the rewards in-game. This is the method I recommend as players shouldn't have to wait for their rewards. The other method was through a (2) worker. When a player votes, you can have the website insert a record into a table in the database; let's call this column 'pending_vote_rewards'. This table will contain the records of all the players who have voted, but have not received their rewards. On the server end, write a (2) worker that checks 'pending_vote_rewards' on an interval. When a record exists, if the player is still logged in, give them the rewards. If the player has logged out, add it to their character record directly.
Hope this helps!