• 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.

Password Gift

FlipelyFlip

Arr teh Pirate
44
Posts
12
Years
PasswordGift v1.0
by FlipelyFlip


heyey,
I know there are some scripts out there doing the same like mine, but with mine you have a lot more power! You can set Items and Pokemons as gifts. It's easy used and you don't need a lot of scripting knowledge to use this snippet.

What does this Snippet do?
this little snippet allows you to create a Password Gift part.
You enter a password and if the password is correct, you will
gain a pre-defined item.

How to use it?
To call the script you have only use the call-script event code
and enter this:

Scene_PasswordGift.new(minlength, maxlength)

minlength = minimum of letters or symbols to enter (by default it's 1)
maxlength = maximum of letters or symbols to enter (by default it's 8)

How to setup?
To setup a password, it's important that you know, that you have to
put a PBItems:: before the item name or a PBSpecies:: before a pokemon name!
All items and Pokemons you will find in your PBS folder.

How to setup a Item-Password:

"password" => [PBItems::Item_Name, Switch_ID, pokemon=false]

"password" = "Password" which you have to choose. Don't forget this friends: ""
PBItems::Item_Name = Sets the Item
Switch_ID = Switch ID if you want. to set this password to nil for endless use.
pokemon=false = Items are no pokemons, so this is set to false. It's very important that this is set to false for items (Causes Errors)

How to setup a Pokemon-Password:


"password" => [PBSpecies::Pokemon_Name, Switch_ID, pokemon=true, Level]
"password" = "Password" which you have to choose. Don't forget this friends: ""
PBSpecies::Pokemon_Name = Sets the Pokemon
Switch_ID = Switch ID if you want. to set this password to nil for endless use.
pokemon=true = defines if it's a pokemon or not. So you're setting up a pokemon, this has to be true!
Level = Level of the pokemon when gained!

The Script itself
Spoiler:

Planed Features:

  • amount of use. Means: You can use the password for the potion 3 times but the password for a Mew only once.
  • if you have some ideas just say (:
that's all you have to know in this snippet (:
I hope you like it^^"

~Flip
 
Last edited:

Ho-oh 112

Advance Scripter
311
Posts
13
Years
  • Age 28
  • Seen Mar 8, 2014
Well, this is great as a starter but, for some better scripts you should atleast let people "compile" items/pokemon/eggs without needing pre-defined passwords(a password generator)
 

Pharetra

zzzz
451
Posts
12
Years
  • Age 27
  • Seen Nov 23, 2021
Seems like a great script to me, I have yet to test it but this definitely looks promising. Really like the idea of passwords by the way. I do have a suggestion, how about adding Online support? I'd like to be able to add gifts after my game has been released.
 
10,673
Posts
14
Years
  • Age 30
  • Seen Dec 30, 2023
This is pretty awesome to be frank. I would like to see online support a bit later, this would be really useful for events and so on. Good work!
 
276
Posts
16
Years
Well, this is great as a starter but, for some better scripts you should atleast let people "compile" items/pokemon/eggs without needing pre-defined passwords(a password generator)

That's a really good idea and i think it is possible. First you need a key so no one will able to fake it:
Code:
$SecretKey = "some crazy text"
Encrypt method will be something like this:
Code:
def Encrypt(pokemon,switch)
   return  Zlib::Inflate.inflate(Zlib::Inflate.inflate(pokemon+"|"+switch)+$SecretKey)
end
And Decrypt mothod
Code:
def Decrypt(pass)
  arg = (Zlib::Deflate.deflate(Zlib::Deflate.deflate(pass).gsub($SecretKey, ""))).split("|")
  @pokemon = arg[0]
  @switch = arg[1]
  #Do something
end
 

Ho-oh 112

Advance Scripter
311
Posts
13
Years
  • Age 28
  • Seen Mar 8, 2014
That's a really good idea and i think it is possible. First you need a key so no one will able to fake it:
Code:
$SecretKey = "some crazy text"
Encrypt method will be something like this:
Code:
def Encrypt(pokemon,switch)
   return  Zlib::Inflate.inflate(Zlib::Inflate.inflate(pokemon+"|"+switch)+$SecretKey)
end
And Decrypt mothod
Code:
def Decrypt(pass)
  arg = (Zlib::Deflate.deflate(Zlib::Deflate.deflate(pass).gsub($SecretKey, ""))).split("|")
  @pokemon = arg[0]
  @switch = arg[1]
  #Do something
end

yeah I knew that, but I was giving him a challenge of finding a method to do so....
(another method is the .pack/.unpack function)
 

Awkward Squirtle

,@,e .ºoO
110
Posts
12
Years
  • Seen Jan 29, 2016
FlipelyFlip: Nice script. Tip: you can use the chomp method to remove possible whitespace from the end of a string (instead of your current slice shenanigans). I like the way you've set up the switches - you could make a set of mutually exclusive passwords by giving them the same switch ID (such as a choice between Bulbasaur, Charmander and Squirtle)!

help-14: Deflate isn't an encryption algorithm, it's a data compression algorithm. Adding a 'secret key' on the end won't make it secure. You're not even checking the secret key after decompression - I can just make a message with an empty 'secret key' and your code will decrypt it as normal (try it). And even if you do check the secret key, I can find the game's actual secret key by decompressing the code and taking the bit off the end - then, I can fake a message and append the key before compressing, and the game will be none the wiser. Pack/unpack similarly doesn't do any encryption - it just converts an array into a string and vice-versa using a predefined format.

As an easier alternative, try the Marshal module - it provides data serialisation, meaning you can pack an actual Pokémon's data into a string with a single line of code. The default implementation is pretty inefficient, but I think there's a method you can override if you want to pack the data into a shorter string.

Pokémon Raptor uses deflate and a conversion to base-64 in its system - it's not encrypted in any way whatsoever. It's easy to fake a Mystery Gift/team code. But the Mystery Gift code there is loaded from a URL defined in the scripts, so you'd have to modify and redistribute the scripts file to change the loaded gift (as I did). And team codes don't really do anything in-game, so faking them doesn't really matter.

You should still have some sort of validation to prevent game crashes from malformed codes - for example, this guy's code is invalid, but the game handles it gracefully (when constructing the team's Pokémon, an invalid species exception is thrown; the script catches it, and displays a message to the screen saying so). FlipelyFlip's code doesn't really need this (as long as the game creator doesn't mess up); however, any code which constructs Pokémon from a user-supplied string should have this sort of error handling. You could also include a checksum, to spot any errors that could have been made when copying the code (rather than immediately trying to load an invalid code).
 

Ho-oh 112

Advance Scripter
311
Posts
13
Years
  • Age 28
  • Seen Mar 8, 2014
Oh i don't know that method, silly me :embarrass:

It's simple:
For compiler:
Code:
packcode = "*^%VVVC0283204cccCCv" # something random like that
pokemon = 493
level = 100
switch = [5, true]
ary=[pokemon,level,switch]
ary.pack(packcode)

for decompiler

Code:
packcode = "*^%VVVC0283204cccCCv" # something random like that
ary=code.unpack(packcode)
pbAddPokemon(ary[0], ary[1])
$game_switches[ary[2]] = ary[3]
 
rescue
Kernel.pbMessage(_INTL("Your gift file is corrupted..."))

now you just need the input code method for it...
 

FlipelyFlip

Arr teh Pirate
44
Posts
12
Years
@Awkward Squirrle:
The switch-thingy is still in ;)
I'm just checking if the defined switch is true or not. If a password sets the switch to true, it'll be for all other passwords which uses this switch to true (:
And about the chomp, I've only worked with the included standard stuff from rgss. I haven't seen all new methods and functions for arrays and hashes. So I fought it would be better for me at first to work with standard than with the included stuff. But don't worry, I'm still testing and working to get all new stuff (:

@Ho-oh 112:
you mean to setup it in an event without a pre-defined password? I can put it in, it's not really a problem.

@all other who requested an online-function:
I have to say it would go over my actual scripting knowledge. I will add it, but it will take time until I know how the online function works ._.

~flipy

(btw: please call me flip or flipy, easier to write and it's a shorter form)

EDIT:

For a password not defined in the hash, you can also use this one:

Spoiler:

to use it, just use the conditional branch script and type in: Password.enter("password", minlength, maxlength).
"password" = password used
minlength = minimum amount of characters
maxlength = maximum amount of characters

and thats it (:

~flipy
 
Last edited:

Ho-oh 112

Advance Scripter
311
Posts
13
Years
  • Age 28
  • Seen Mar 8, 2014
@Ho-oh 112:
you mean to setup it in an event without a pre-defined password? I can put it in, it's not really a problem.


No I meant like my mystery gift system you can generate your gifts instead of adding them in pre-game and using them before hand.
 
Back
Top