The trading scripts used by the game use assembly language (also called ASM) code to both verify you have selected the right Pokémon for trading and to set which Pokémon will be traded to you. I'm actually in the process of trying to unravel the trading script secrets as well. Until I figured it out you may want to take a look at this tutorial (
https://www.pokecommunity.com/showthread.php?p=9775737). This will allow you to do a kind of trading in the game by letting you take a Pokémon from the players party and showing them another Pokémon which is then inserted into their party. But it does not check for a specific species of Pokémon and instead lets the player trade away any Pokémon they want.