The issue is that the value that you read from nvault is the same value that you write to nvault. Therefore, you are never updating the value stored in nvault. So, you need to update g_last_used[id] before you write the value to nvault.
Also, players are only guaranteed to have a valid SteamID after client_authorized() so you need to use client_authorized() instead of client_putinserver().