Thread: [Essentials Script] Ho-oh 112's Mystery gift system
View Single Post
  #1    
Old January 5th, 2012 (6:43 PM). Edited March 19th, 2012 by Ho-oh 112.
Ho-oh 112's Avatar
Ho-oh 112 Ho-oh 112 is offline
Advance Scripter
     
    Join Date: Feb 2011
    Age: 21
    Gender: Male
    Nature: Hasty
    Posts: 311
    Right, It's been a while SOOOOOOO I gave a new update + re-did my post...

    HOW TO USE:
    make a text file like this (text.txt or something)
    REMEMBER TO USE NEW LINES
    write in it:
    Message (Hello this is a message)
    Type (0 pokemon, 1 egg, 2 item, 3 none)
    Pokemon/item (depends on it)
    level
    form
    shiny (0 normal, 1 shiny, 2 shadow, 3 both)
    move1
    move2
    move3
    move4
    ot (Owner Name)
    id (id CAN'T START WITH 0, 5 numbers long)
    nature
    ability (0, 1, 2 Hidden)
    item (0 for none)
    ribbon (0 for none)
    gender (0 male, 1 female)
    ivs (1 HP, 2 ATK, 3 DEF, 4 SPEED, 5 SPEC. ATK, 6 SPEC. DEF) (0-5) SERPERATE LINES FOR ALL OF THEM!
    varswitch ("Switch" if a switch "Var" or "Variable" if a Variable)
    varswutchnum (number of the switch/var)
    varswitchvalue (var/switch value)
    OK NOW I RECOMEND USING WEBS.COM TO MAKE A SITE FOR YOUR GAME THEN UPLOAD GIFT THERE AS YOU CAN CHANGE TEXT DOCUMENTS WITHOUT REUPLOADING.
    =end
    To load a gift: pbMysteryGift


    Code:
    def pbMysteryGift
      message=nil
      type=nil
      species=nil
      level=nil
      form=nil
      shiny=nil 
      move1=nil 
      move2=nil 
      move3=nil 
      move4=nil 
      ot=nil 
      id=nil 
      nature=nil 
      abillity=nil 
      item=nil 
      ribbon=nil 
      iv1=nil 
      iv2=nil 
      iv3=nil 
      iv4=nil 
      iv5=nil 
      iv6=nil
      switchvar = "Switch" # Var/Variable if it's a variable
      switchvarnum = 50 # switch/var number
      switchvarvalue = false
      #second value: If a var it can be string/number/ or bool switches only bool
      badgecount = 0 # Number of badges needed to get pokemon
    link="http://rmxpmysterygift.webs.com/Gifts/Gift.txt"
    code=pbDownloadToString(link)
    if code == ""
      return false
    end
    file = File.open('text.txt', 'wb'){|f|
    f.write(code)
    }
    array = IO.readlines('text.txt')
    message=array[0]
    type=array[1]
    type = type.to_i + 1 - 1
    if type == 3
      Kernel.pbMessage(_INTL("There are no gifts avaible."))
      return true
    else
      Kernel.pbMessage(_INTL("A gift was found!"))
      if $game_variables[6] == message && $DEBUG == false
      Kernel.pbMessage(_INTL("You already got the gift!"))
      return true
      end
    end
      Kernel.pbMessage(_INTL(message)) # displays custom message
    $game_variables[6] = message # The "detection code"
    switchvar=array[23]
    switchvarvalue=[array[24],array[25]]
    badgecount=array[26]
    badgecount=badgecount.to_i
    pbNextCheck(switchvar,switchvarvalue,badgecount)
    species=array[2]
    species = species.to_i + 1 - 1
    if type == 2
    Kernel.pbReceiveItem(species)
    $game_variables[1] = PBItems.getName(species)
    return true
    end
    if $Trainer.party.length == 6
      Kernel.pbMessage(_INTL("Your party is full!"))
      $game_variables[1] = 0
      return true
    end
      $game_variables[1] = PBSpecies.getName(species)
    if type == 1
      pbGenerateEgg(species)
      $game_variables[1] = "Mystery Egg"
      return true
    end
    level=array[3]
    level = level.to_i + 1 - 1
    form=array[4]
    form = form.to_i + 1 - 1
    shiny=array[5]
    shiny = shiny.to_i + 1 - 1
    move1=array[6]
    move1 = move1.to_i + 1 - 1
    move2=array[7]
    move2 = move2.to_i + 1 - 1
    move3=array[8]
    move3 = move3.to_i + 1 - 1
    move4=array[9]
    move4 = move4.to_i + 1 - 1
    ot=array[10]
    id=array[11]
    id = id.to_i + 1 - 1
    nature=array[12]
    nature = nature.to_i + 1 - 1
    ability=array[13]
    ability = ability.to_i + 1 - 1
    item=array[14]
    item = item.to_i + 1 - 1
    ribbon=array[15]
    ribbon = ribbon.to_i + 1 - 1
    gender=array[16]
    gender = gender.to_i + 1 - 1
    iv1=array[17]
    iv1 = iv1.to_i + 1 - 1
    iv2=array[18]
    iv2 = iv2.to_i + 1 - 1
    iv3=array[19]
    iv3 = iv3.to_i + 1 - 1
    iv4=array[20]
    iv4 = iv4.to_i + 1 - 1
    iv5=array[21]
    iv5 = iv5.to_i + 1 - 1
    iv6=array[22]
    iv6 = iv6.to_i + 1 - 1
    iv = [iv1, iv2, iv3, iv4, iv5, iv6]
    moves=[move1, move2, move3, move4]
    # Checks badge count if it's more than 0 if not it ignores this...
    if badgecount > 0
      if $Trainer.badges[badgecount] != true
        Kernel.pbMessage(_INTL("You do not have enough badges to get this gift. badges required: {1}", badgecount))
        return
      end
    end
    if switchvar == "Switch"
      $game_switches[switchvarvalue[0]] = switchvarvalue[1]
    elsif switchvar == "Variable" or switchvar == "Var"
      $game_variables[switchvarvalue[0]] = switchvarvalue[1]
    end
    if species == nil
      return false
    end
    if level == nil
      return false
    end
    gift = PokeBattle_Pokemon.new(species,level)
    gift.trainerID = id
    gift.ot = ot
    gift.form = form
    gift.ballused = pbGetBallType(:CHERISHBALL) # All Pokemon are in these.
    if shiny == 1
      gift.makeShiny
    elsif shiny == 2
      gift.makeShadow
    elsif shiny == 3
      gift.makeShiny
      gift.makeShadow
    end
    if ribbon > 0
      gift.setRibbon(ribbon)
    end
    if item > 0
      gift.item = item
    end
    gift.setNature(nature)
    gift.abilityflag=ability
    # Teaches moves
    for i in 0..3
      gift.moves[i]=PBMove.new(moves[i])
    end
    pbAddToPartySilent(gift)
    pbSave
    rescue
    Kernel.pbMessage(_INTL("The gift is corrupted"))
    return
    end
     
    def pbNextCheck(var1,var2,badge)
    # Checks badge count if it's more than 0 if not it ignores this...
    if badge > 0
      if $Trainer.badges[badge] != true
        Kernel.pbMessage(_INTL("You do not have enough badges to get this gift. badges required: {1}", badgecount))
        return
      end
    end
    if var1 == "Switch"
      var2[1].to_b
      $game_switches[var2[0]] = var2[1]
    elsif var1 == "Variable" or var1 == "Var"
      $game_variables[var2[0]] = var2[1]
    end
    end
    Whats New:
    Removed the mySql thing because it didn't work....
    Added badge counter (not tested but should work)
    Added Var/Switch setting (not tested....)

    Todo:
    None as of now

    Bugs:
    None as of now
    Reply With Quote