So what happens if the pokemon is sent to the box?
The code I gave you works only if it's the starter Pokemon, which usually isn't sent to a box. In the case where it's a gift Pokemon that ISNT a starter, you have to use more creativity. Generally, the following would work:
Code:
... \\give the player the Pokemon
countpokemon \\counts the number of Pokemon in your party
subvar LASTRESULT 0x1 \\explained below
copyvar 0x8004 LASTRESULT \\copies LASTRESULT to the variable 0x8004
fadescreen 0x1 \\turns the screen black
special 0x9E \\nickname special
waitstate \\wait till done nicknaming
... \\rest of the code
The reason you subtract one is because of the following: Suppose you have one Pokemon. countpokemon will return the value 0x1. But the Pokemon itself is in the first slot, which has a value of 0x0. Since you gave the player a Pokemon, it'll be at the bottom of the party. The script counts how many Pokemon you have, and subtracts one, giving the slot number of the final Pokemon, or the Pokemon you gave. It then continues as before.
There is a way to nickname a Pokemon sent to a box though. From what I can tell, the givepokemon code actually returns a value to LASTRESULT. LASTRESULT is 0x0 if its in the party, 0x1 if it goes to a box, and 0x2 if there's no room in the party or in a box. If you really want to put this in, it'll add alot more branches to the code (You'll have to do different scripts is the player knows its 'Someone's PC' vs 'Bill's PC', among others), but it can be nicknamed with the following:
Code:
... \\Give the player the Pokemon, check if LASTRESULT is 0x1
fadescreen 0x1
special 0x166
waitstate
... \\The rest of the code
Of course, the simplest way is to just countpokemon before the gift, and refuse to give it if there's more than six in the party.
Edit: If you need to know more, I suggest getting a clean Firered rom and going to map 10.11, which is in Celadon City. The Pokeball on the desk gives the player an Eevee, and has everything you need to know about nicknaming things that are about to go to a box :)