The classic Star Wars: Battlefront II codes are entered as console commands, and two of the most used are:
These are typed into the game's console rather than a menu screen, which means you need to open it during play. On the original PC release that is done with the tilde key. On console versions the access method differs and some editions do not expose a console at all, so check which version you own before hunting for a key that does nothing.
Both codes are single-player only. They have no effect in online matches, and attempting to use anything similar there will not end well. If your interest is the campaign or instant action, they work as advertised and make the game considerably more of a sandbox.