For unlimited ammo in Star Wars Battlefront 2, the code is a directional sequence: press Up, Down, Left, Down, Down, Left, Down, Down, Left, Down, Down, Down, Left, Right.
Input it correctly during play and you'll keep firing without running dry. Just remember that cheat codes typically only work in single-player or offline modes, not in online multiplayer.