• Our software update is now concluded. You will need to reset your password to log in. In order to do this, you will have to click "Log in" in the top right corner and then "Forgot your password?".
  • Forum moderator applications are now open! Click here for details.
  • Welcome to PokéCommunity! Register now and join one of the best fan communities on the 'net to talk Pokémon and more! We are not affiliated with The Pokémon Company or Nintendo.

[Essentials Tutorial] Basic Mystery Gift Tutorial

|Maximus|

I'm back~
836
Posts
16
Years
  • Age 28
  • Seen Sep 10, 2010
Okay, so I have actually decided to make my first tutorial. This tutorial is going to be how to create a Basic Mystery Gift Person Dude Thingy :P

Okay, so I am going to break this up into steps.

1) Checking for a File

So first you want to create a Conditional Branch with this line of script.

Code:
@> [COLOR="Blue"]Conditional Branch: Script: FileTest.exist?("Arceus.pkmn")[/COLOR]
   @>
  : [COLOR="Blue"]Else[/COLOR]
   @>
  :[COLOR="Blue"] Branch End[/COLOR]
@>

Basically, it checks if you have "Arceus.pkmn" inside of your game folder. View the video inside of my signature for how to create custom files.

2) Adding the Effect

So, what happens if you do have the file? Easy, we can add the Arceus.

Code:
@> [COLOR="Blue"]Conditional Branch: Script: FileTest.exist?("Arceus.pkmn")[/COLOR]
   @> Text: You have the Mystery Gift.
   @> [COLOR="Blue"]Conditional Branch: Script: Kernel.pbAddPokemon(PBSpecies::ARCEUS,80)[/COLOR]
      @> [COLOR="Red"]Self Switch: A = ON[/COLOR]
      @>
  : [COLOR="Blue"]Else[/COLOR]
   @>
  :[COLOR="Blue"] Branch End[/COLOR]
@>
  : [COLOR="Blue"]Else[/COLOR]
   @>
  :[COLOR="Blue"] Branch End[/COLOR]
@>

3)What if you don't have it?

Well, thats easy. Just add whatever you want under 'else'


Code:
@> [COLOR="Blue"]Conditional Branch: Script: FileTest.exist?("Arceus.pkmn")[/COLOR]
   @> Text: You have the Mystery Gift.
   @> [COLOR="Blue"]Conditional Branch: Script: Kernel.pbAddPokemon(PBSpecies::ARCEUS,80)[/COLOR]
      @> [COLOR="Red"]Self Switch: A = ON[/COLOR]
      @>
  : [COLOR="Blue"]Else[/COLOR]
   @>
  :[COLOR="Blue"] Branch End[/COLOR]
@>
  : [COLOR="Blue"]Else[/COLOR]
   @> Text: The Gift is not for everyone.
   @>
  :[COLOR="Blue"] Branch End[/COLOR]
@>

Well, that's my tutorial I hope you enjoyed it, and found it useful! Check out the video in the spoiler in my signature because that is where you will find out how to convert TXT files into .PKMN files.

PHEW, that's a lot of typing!
 

Klofkac

He's back!
336
Posts
14
Years
I always wondered how to check file existing. And now I know it!
I have question: How I check, what's in that file written?
 

Poeman

Banned
755
Posts
15
Years
  • Age 29
  • Seen Nov 1, 2012
I have done something like this before except it read data from a website after downloading it, much better because that way you can set events on the website :D
Maybe we could implement my method into Sparkling Yellow?
 

darkerarceus

Advanced RM2K3-er
342
Posts
15
Years
Well I have viewed the video in your siganture 2 weeks ago and the point is wouldn't it be easy to just make the file Arceus.pkmn and errrr... Cheat?
 

|Maximus|

I'm back~
836
Posts
16
Years
  • Age 28
  • Seen Sep 10, 2010
Well I have viewed the video in your siganture 2 weeks ago and the point is wouldn't it be easy to just make the file Arceus.pkmn and errrr... Cheat?

Well, people could-- Well I suppose -- I got nothing. Yeah, I guess that's true. Maybe, people could create a file that nobody else would think of. Like in example instead of "Arceus.pkmn" put "Crayon.pkmn" I don't know I was looking at a box of crayons when I typed this :P
 

davidthefat

I Love C++
437
Posts
14
Years
  • Age 30
  • Seen Mar 3, 2012
Ok heres my Idea, Im assuming this is obtainable through the game. You can have a entry in the database for a boolean (true, false) check if true, if true, check ID (When the mystery gift is obtained, the server generates random numbers and stores it as the ID and the client gets the ID and writes it in the file) and compared both IDs, if the same, allow it to take effect, if not, disable mystery gift forever, but that wont allow multiple accounts or sharing accounts...
 
2,048
Posts
16
Years
  • Age 31
  • Seen Sep 7, 2023
Naming it something random isn't a good idea; security through obscurity isn't really security at all. It would take a single person to decrypt the game data, check the filenames needed, and post them on a forum, to completely ruin the whole thing.

The best way to do it is to implement everything on the server. The game doesn't do any checking whatsoever; instead, it pulls data off a website and creates a Pokémon from that.

That way, you can add new gifts after the game has been published, and make sure players can't cheat (short of hacking the site where it's stored). You could even add the code to a fixed forum post (the first post in the thread), and have the game read from that.

I'm probably going to make a tutorial for my method, and more :P
 
521
Posts
15
Years
  • Seen Sep 11, 2013
Naming it something random isn't a good idea; security through obscurity isn't really security at all. It would take a single person to decrypt the game data, check the filenames needed, and post them on a forum, to completely ruin the whole thing.

The best way to do it is to implement everything on the server. The game doesn't do any checking whatsoever; instead, it pulls data off a website and creates a Pokémon from that.

That way, you can add new gifts after the game has been published, and make sure players can't cheat (short of hacking the site where it's stored). You could even add the code to a fixed forum post (the first post in the thread), and have the game read from that.

I'm probably going to make a tutorial for my method, and more :P

Whether you remember or not, about a half year ago you greatly helped me write a mystery gift event that read text from my website.
I knew pretty much nothing about scripting then and you helped me along.

It is still the only real feature in my game but with all of these tutorials, I guess that I will have to make something new.
 

Nyu~♥!

Pokémon Opal Producer
478
Posts
14
Years
Naming it something random isn't a good idea; security through obscurity isn't really security at all. It would take a single person to decrypt the game data, check the filenames needed, and post them on a forum, to completely ruin the whole thing.

The best way to do it is to implement everything on the server. The game doesn't do any checking whatsoever; instead, it pulls data off a website and creates a Pokémon from that.

That way, you can add new gifts after the game has been published, and make sure players can't cheat (short of hacking the site where it's stored). You could even add the code to a fixed forum post (the first post in the thread), and have the game read from that.

I'm probably going to make a tutorial for my method, and more :P

Yeah, that'd be better. Though, I was thinking a different way before seeing this:
The player gets a secret code from the games site, which they can then enter into a certain computer. (of course, this code would be something totally unpredictable, like fhyd80292 or watev, lol) By doing this the player can pick up a certain item from a little map I created called the Delivery Office.
They would then activate it, by using it in a certain area, or using the item in it's own specialty(like the flutes playing) to start an event.


..but, I totally suck at scripting such items. :/ And I don't know anything about inputting text. |o
 

|Maximus|

I'm back~
836
Posts
16
Years
  • Age 28
  • Seen Sep 10, 2010
Yeah, that'd be better. Though, I was thinking a different way before seeing this:
The player gets a secret code from the games site, which they can then enter into a certain computer. (of course, this code would be something totally unpredictable, like fhyd80292 or watev, lol) By doing this the player can pick up a certain item from a little map I created called the Delivery Office.
They would then activate it, by using it in a certain area, or using the item in it's own specialty(like the flutes playing) to start an event.


..but, I totally suck at scripting such items. :/ And I don't know anything about inputting text. |o

By inputting text you could probably modify the name input method a little bit. And store the value of the "name" into a variable. Kind of like how it is done with the Rival's name input. But instead of having "Rival's Name?" put something like "Gift Code?" or something I don't know.
 

darkerarceus

Advanced RM2K3-er
342
Posts
15
Years
Still about your inputting ideas couldn't you TELL someone the code?
Server Based could be good but it would take a good amount of scripting to do.
 
2,048
Posts
16
Years
  • Age 31
  • Seen Sep 7, 2023
Yeah, that'd be better. Though, I was thinking a different way before seeing this:
The player gets a secret code from the games site, which they can then enter into a certain computer. (of course, this code would be something totally unpredictable, like fhyd80292 or watev, lol) By doing this the player can pick up a certain item from a little map I created called the Delivery Office.
They would then activate it, by using it in a certain area, or using the item in it's own specialty(like the flutes playing) to start an event.


..but, I totally suck at scripting such items. :/ And I don't know anything about inputting text. |o
That way, you'd still have to store the codes in an event in-game (you have to use a conditional branch somewhere); it would be easy to find them and cheat.
Still about your inputting ideas couldn't you TELL someone the code?
Server Based could be good but it would take a good amount of scripting to do.
Come on, it's not that hard to search through the scripts. In the Essentials intro event, there's a pbTrainerName script call which opens the text entry screen. Searching for 'pbTrainerName' in the scripts, and then seeing what methods are called within it, gets you this script:
Code:
trname=pbEnterText("Your name?",0,7)
This is obviously the text entry method. It appears to return the entered text, which here is assigned to the trname variable. Now you need to know what the arguments mean. Searching for 'def pbEnterText' gets you this:
Code:
def pbEnterText(helptext,minlength,maxlength,initialText="")
So, the first argument is the help text (could be "Enter the password."), the second is the minimum length (for example, if the password is 8 letters long, it would be 8), the third is the maximum length (same as before), and the last is the starting text (this should probably be left blank).
RMXP's variables are stored in the $game_variables array. So to store the password in, say, variable 100, you'd use:
Code:
$game_variables[100]=pbEnterText(_INTL("Enter the password"),8,8)
Then, you could use a conditional branch to check the password. However, doing it through events is convoluted; a script for this would be better. For example:
Code:
def getPassword
  password=pbEnterText(_INTL("Enter the password"),8,8
  case password
  when "khdsggad"
    Kernel.pbMessage(_INTL("Correct password!"))
    Kernel.pbReceiveItem(PBItems::MEMBERSPASS)
  when "adhosdgf"
    Kernel.pbMessage(_INTL("Correct password!"))
    Kernel.pbReceiveItem(PBItems::OAKSLETTER)
  else
    Kernel.pbMessage(_INTL("Incorrect password..."))
  end
end

Server-based isn't difficult with Essentials' features; for example, the pbDownloadToString method is perfect for this. Using regular expression matching, you can even post the code directly in a thread.
 
2,048
Posts
16
Years
  • Age 31
  • Seen Sep 7, 2023
Isn't the point of Mystery Gift that it allows events to be made public?
A server-based system would be better anyway, as a password system can be easily abused...
 

Nyu~♥!

Pokémon Opal Producer
478
Posts
14
Years
I get your point but the problem is that you can easily tell someone else the password.

Isn't the point of Mystery Gift that it allows events to be made public?
A server-based system would be better anyway, as a password system can be easily abused...

erm.. yea..
but anyway, Wichu has a great point that totally kills my idea. D:
So.. does anyone know anything about a server based system? :/

That way, you'd still have to store the codes in an event in-game (you have to use a conditional branch somewhere); it would be easy to find them and cheat.

Come on, it's not that hard to search through the scripts. In the Essentials intro event, there's a pbTrainerName script call which opens the text entry screen. Searching for 'pbTrainerName' in the scripts, and then seeing what methods are called within it, gets you this script:
Code:
trname=pbEnterText("Your name?",0,7)
This is obviously the text entry method. It appears to return the entered text, which here is assigned to the trname variable. Now you need to know what the arguments mean. Searching for 'def pbEnterText' gets you this:
Code:
def pbEnterText(helptext,minlength,maxlength,initialText="")
So, the first argument is the help text (could be "Enter the password."), the second is the minimum length (for example, if the password is 8 letters long, it would be 8), the third is the maximum length (same as before), and the last is the starting text (this should probably be left blank).
RMXP's variables are stored in the $game_variables array. So to store the password in, say, variable 100, you'd use:
Code:
$game_variables[100]=pbEnterText(_INTL("Enter the password"),8,8)
Then, you could use a conditional branch to check the password. However, doing it through events is convoluted; a script for this would be better. For example:
Code:
def getPassword
  password=pbEnterText(_INTL("Enter the password"),8,8
  case password
  when "khdsggad"
    Kernel.pbMessage(_INTL("Correct password!"))
    Kernel.pbReceiveItem(PBItems::MEMBERSPASS)
  when "adhosdgf"
    Kernel.pbMessage(_INTL("Correct password!"))
    Kernel.pbReceiveItem(PBItems::OAKSLETTER)
  else
    Kernel.pbMessage(_INTL("Incorrect password..."))
  end
end
Server-based isn't difficult with Essentials' features; for example, the pbDownloadToString method is perfect for this. Using regular expression matching, you can even post the code directly in a thread.

great script ideas right there. I'll need to try it until i figure out the server method.
 
Last edited:

Gigatom~

Pokemon Ruthenium Creator ~
117
Posts
14
Years
  • Age 28
  • Seen May 25, 2012
Nice, I'm using it.
Now i'm making a mystery gift with Giratina ;)
Thank you for this.

Gigatom~
 
Back
Top