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

With Online scripts

Ho-oh 112

Advance Scripter
311
Posts
13
Years
    • Seen Mar 8, 2014
    WARNING, IF YOU HAVE NO IDEA HOW THE POKEMON ESSENTIALS ONLINE WORKS DON'T LOOK HERE!!!

    right, somewhere is this HUGE MESS of code my buddy up system (for online usage) doesn't work, I right click use the Buddy up option and nothing else happens.... to find faster I think you can use the search option (search bud)

    I set the most likely places to have failed first.... Good luck, I know I can't find it.... (The other codes are obviously ruby)

    Lua code:
    Code:
    --  The process function to organize protocol
    --  Copyright(c) 2006 sUiCiDeMAniC
    --  Email:  [EMAIL="[email protected]"][email protected][/EMAIL]
    --  Last update:  05/11/06
    --------------------------------
    --      Main Proccessing      --
    --------------------------------
    function process(cmd,data)
     
    --------------------------------
    --            CHAT            --
    --------------------------------
      if cmd == "<chat>" then
        do NP():SendToAll(data) end
    --------------------------------
    --       AUTHENFICATION (0)   --
    --------------------------------
      elseif cmd == "<0>" then
        do local sname = NP():GetServerName()
        NP():SendToUser(user.id,"<0 "..user.id..">'e' n="..sname.."</0>") end
      elseif cmd == "<auth>" then
        do local sname = NP():GetServerName()
    NP():SendToUser(user.id,"<auth "..user.id..">'e' n="..sname.."</auth>") end
    --------------------------------
    --         ID Request (1)     --
    --------------------------------
      elseif cmd == "<1>" then
        do NP():SendToUser(user.id,"<1>"..user.id.."</1>") end
      elseif cmd == "<getid>" then
        do NP():SendToUser(user.id,"<getid>"..user.id.."</getid>") end
    --------------------------------
    --        NAME Request (2)    --
    --------------------------------
      elseif cmd == "<2>" then
        do NP():SendToUser(user.id,"<2>"..user.name.."</2>") end
      elseif cmd == "<getname>" then
        do NP():SendToUser(user.id,"<getname>"..user.name.."</getname>") end
    --------------------------------
    --   PROFILE/GROUP Request (3)--
    --------------------------------
      elseif cmd == "<3>" then
        if user.profile == nil then
         do NP():SendToUser(user.id,"<3>'standard'</3>") end
        else
         do NP():SendToUser(user.id,"<3>"..user.profile.."</3>") end
        end
      elseif cmd == "<getgroup>" then
        if user.profile == nil then
         do NP():SendToUser(user.id,"<getgroup>'standard'</getgroup>") end
        else
         do NP():SendToUser(user.id,"<getgroup>"..user.profile.."</getgroup>") end
        end
    --------------------------------
    --        CLOSE USER (4)      --
    --------------------------------
      elseif cmd == "<4>" then
        do NP():CloseSocket(user.ip) end
      elseif cmd == "<close>" then
        do NP():CloseSocket(user.ip) end
    --------------------------------
    --         NETPLAYER (5)      --
    --------------------------------
      elseif cmd == "<5>" then
        do 
          local ndata = string.gsub(data,"<5>","")
          NP():SendToAll("<5 "..user.id..">"..ndata)
        end
      elseif cmd == "<netact>" then
        do 
          local nadata = string.gsub(data,"<netact>","")
          NP():SendToAll("<netact "..user.id..">"..nadata)
        end
      elseif cmd == "<netplayer>" then
        do 
          local ndata = string.gsub(data,"<netplayer>","")
          NP():SendToAll("<netplayer "..user.id.." >"..ndata)
        end
    --------------------------------
    --        MAP PLAYER ID (6)   --
    --------------------------------
      elseif cmd == "<6a>" then
        do 
          --data = string.gsub(data, " ", "") 
          mapp_id = string.gsub(data, "<6a>", "") 
          --NP():SendToUser(user.id,"<6a>'Confirmed'</6a>\n")
        end
      elseif cmd == "<mappid>" then
        do 
          mapp_id = string.gsub(data, "<mappid>", "") 
          NP():SendToUser(user.id,"<mappid>'Confirmed'</mappid>\n")
        end
     
      elseif cmd == "<6b>" then
         do NP():SendToUser(user.id,"<6a>"..mapp_id.."</6a>") end
    --------------------------------
    --         MAP PLAYER (6)     --
    --------------------------------
      elseif cmd == "<6>" then
        do 
          local nndata = string.gsub(data,"<6>","")
          NP():SendToUser(mapp_id,"<6 "..user.id..">"..nndata)
        end
      --elseif cmd == "<6>" then
      --  do NP():SendToUser(mapp_id, data) 
      --    NP():SendToUser(user.id, mapp_id..data.."\n") 
      --  end
       elseif cmd == "<mapplayer>" then
        do NP():SendToUser(mapp_id, data) 
          NP():SendToUser(user.id, mapp_id..data.."\n") 
        end
    --------------------------------
    --         KICK (7)           --
    --------------------------------
      elseif cmd == "<7>" then
        do local kickid = string.gsub(data,"<7>","")
          local kickid = string.gsub(kickid,"</7>","")
          NP():SendToUser(kickid, "<18>kicked</18>\n")
          file = io.open("Moderation Logs\\ModLog - "..user.ip.." - "..user.name..".txt", "a+")
          file:write(kickid..data.."\n")
          file:close()
        end
       elseif cmd == "<kick>" then
        do local kickid = string.gsub(data,"<kick>","")
          local kickid = string.gsub(kickid,"</kick>","")
          NP():SendToUser(kickid, "<admin>kicked</admin>\n")
        end
    --------------------------------
    --         KICK ALL (8)       --
    --------------------------------
      elseif cmd == "<8>" then
        do
          NP():SendToAll(kickid, "<18>kick_all</18>\n")
          file = io.open("Moderation Logs\\ModLog - "..user.ip.." - "..user.name..".txt", "a+")
          file:write(data.."\n")
          file:close()
        end
      elseif cmd == "<kickall>" then
        do
          NP():SendToAll(kickid, "<admin>kick_all</admin>\n")
        end
    --------------------------------
    --        REMOVE (9)          --
    --------------------------------
      elseif cmd == "<9>" then
        do
          NP():SendToAll(data)
          NP():SendToAll("<chat>"..user.name.." has left the game</chat>\n")
        end
      elseif cmd == "<remove>" then
        do
          NP():SendToAll(data)
        end
    --------------------------------
    --        REMOVE (9a)          --
    --------------------------------
      elseif cmd == "<9a>" then
        do
          NP():SendToAll(data)
        end
      elseif cmd == "<remove>" then
        do
          NP():SendToAll(data)
        end
    --------------------------------
    --        SYSTEM (10)         --
    --------------------------------
      elseif cmd == "<10>" then
        do NP():SendToAll(data) end
      elseif cmd == "<system>" then
        do NP():SendToAll(data) end
    --------------------------------
    --        TRADE ID (12)       --
    --------------------------------
      elseif cmd == "<12a>" then
        do 
          data = string.gsub(data, " ", "") 
          trade_id = string.gsub(data, "<12a>", "") 
          NP():SendToUser(user.id,"<12a>'Confirmed'</12a>")
        end
      elseif cmd == "<tradeid>" then
        do 
          trade_id = string.gsub(data, "<tradeid>", "") 
          NP():SendToUser(user.id,"<tradeid>'Confirmed'</tradeid>")
        end
    --------------------------------
    --         TRADE (12)         --
    --------------------------------
      elseif cmd == "<12>" then
        do NP():SendToUser(trade_id, data) end
      elseif cmd == "<trade>" then
        do NP():SendToUser(trade_id, data) end
    --------------------------------
    --      PRIVATE CHAT ID (13)  --
    --------------------------------
      elseif cmd == "<13a>" then
        do 
          data = string.gsub(data, " ", "") 
          pchat_id = string.gsub(data, "<13a>", "") 
          --NP():SendToUser(user.id,"<13a>'Confirmed'</13a>")
        end
      elseif cmd == "<pchatid>" then
        do 
          pchat_id = string.gsub(data, "<pchatid>", "") 
          NP():SendToUser(user.id,"<pchatid>'Confirmed'</pchatid>")
        end
    --------------------------------
    --      PRIVATE CHAT (13)     --
    --------------------------------
      elseif cmd == "<13>" then
        do local pmesg = string.gsub(data,"<13>","")
        NP():SendToUser(pchat_id, "<13 "..user.id..">"..pmesg) end
      elseif cmd == "<pchat>" then
        do NP():SendToUser(pchat_id, data) end
    --------------------------------
    --      Poke (15)             --
    --------------------------------
      elseif cmd == "<15>" then
        do local idpoke = string.gsub(data,"<15>","")
          NP():SendToUser(idpoke,"<15>"..user.id.." poke")
        end
    --------------------------------
    --       SLAP PLAYER ID (16)  --
    --------------------------------
      elseif cmd == "<16a>" then
        do 
          data = string.gsub(data, " ", "") 
          slapp_id = string.gsub(data, "<16a>", "") 
          NP():SendToUser(user.id,"<16a>'Confirmed'</16a>\n")
        end
      elseif cmd == "<slappid>" then
        do 
          slapp_id = string.gsub(data, "<slappid>", "") 
          NP():SendToUser(user.id,"<slappid>'Confirmed'</slappid>\n")
        end
    --------------------------------
    --       SLAP PLAYER (16)     --
    --------------------------------
      elseif cmd == "<16>" then
        do 
          NP():SendToUser(slapp_id,"<18>"..data.."</18>\n")
          file = io.open("Moderation Logs\\ModLog - "..user.ip.." - "..user.name..".txt", "a+")
          file:write(slapp_id..data.."\n")
          file:close()
        end
      elseif cmd == "<slap>" then
        do 
          NP():SendToUser(slapp_id,"<admin>"..data.."</admin>\n")
        end
    --------------------------------
    --      TEST END (20)         --
    --------------------------------
      elseif cmd == "<20>" then
        do NP():CloseSocket(user.id) end
      elseif cmd == "<testend>" then
        do NP():CloseSocket(user.id) end
    --------------------------------
    --         PvP (PvP)          --
    --------------------------------
      elseif cmd == "<attack_id>" then
        do attackid = string.gsub(data,"<attack_id>","") end
      elseif cmd == "<result_id>" then
        do resultid = string.gsub(data,"<result_id>","") end
      elseif cmd == "<attack_effect>" then
        do NP():SendToUser(attackid,data) end
      elseif cmd == "<result_effect>" then
        do NP():SendToUser(resultid,data) end
    --------------------------------
    --         State (PvP)        --
    --------------------------------
      elseif cmd == "<state_id>" then
        do stateid = string.gsub(data,"<state_id>","") end
      elseif cmd == "<state>" then
        do NP():SendToUser(stateid,data) end 
    --------------------------------
    --         Error (err)        --
    --------------------------------
      elseif cmd == "<err>" then
        do local bugline = string.gsub(data,"<err>","")
           local bugline = string.gsub(bugline,"</err>","")
           file = io.open("Error Logs\\ErrorLog - "..user.ip.." - "..user.name..".txt", "a+")
           file:write(bugline.."\n")
           file:close()
        end
     
       elseif cmd == "<showani>" then
        do NP():SendToAll(data) end
    --------------------------------
    --     Map Chat ID (21)       --
    --------------------------------
      elseif cmd == "<21a>" then
        do 
          data = string.gsub(data, " ", "") 
          mchat_id = string.gsub(data, "<21a>", "") 
          NP():SendToUser(user.id,"<21a>'Confirmed'</21a>")
        end
    --------------------------------
    --      Map Chat (21)         --
    --------------------------------
      elseif cmd == "<21>" then
        do 
          NP():SendToUser(mchat_id, data) 
        end
    --------------------------------
    --    Get PM Message (22a)    --
    --------------------------------
        elseif cmd == "<22a>" then
          do  
            file = io.open("Private Messages\\PM - "..user.name..".txt", "r")
            for line in file:lines() do
             NP():SendToUser(user.id,"<22a>"..line.."</22a>\n")
            end
            NP():SendToUser(user.id,"<22a>Compelete</22a>\n")
            file:close()
          end
    --------------------------------
    --      Get PM Size (22c)     --
    --------------------------------
         elseif cmd == "<22c>" then
          do
           pmcode = string.gsub(data,"<22c>","")
           pmsize = 0
           file = io.open("Private Messages\\PM - "..pm_username..".txt", "r")
           for line in file:lines() do
            for word in string.gfind(line, "%a+") do
             if word == "aaPMaa" then 
               pmsize = pmsize+1
             end
            end
           end
           NP():SendToUser(user.id,"<22c>"..pmsize.."</22c>\n") 
           file:close()
          end
    --------------------------------
    --     Write PM TO (22b)       --
    --------------------------------
      elseif cmd == "<22b>" then
        do 
          data = string.gsub(data, " ", "") 
          pm_username = string.gsub(data, "<22b>", "") 
        end
    --------------------------------
    --    Write PM MEssage (22d)  --
    --------------------------------
         elseif cmd == "<22d>" then
          do
            data = string.gsub(data,"<22d>","")
            data = string.gsub(data,"</22d>","")
            file = io.open("Private Messages\\PM - "..pm_username..".txt", "a+")
            file:write(data.."\n")
            file:close()
          end
    --------------------------------
    --Delete ALL PM MEssages (22e)--
    --------------------------------
         elseif cmd == "<22e>" then
          do
            file = io.open("Private Messages\\PM - "..user.name..".txt", "w+")
            file:close()
          end
    --------------------------------
    --     Self Switch (23)       --
    --------------------------------
      elseif cmd == "<23>" then
        do NP():SendToAll(data) end
    --------------------------------
    --     Trade Request(24)      --
    --------------------------------
      elseif cmd == "<24>" then
        do 
          data = string.gsub(data, " ", "") 
          tradeid = string.gsub(data, "<24>", "") 
        end
     
              elseif cmd == "<24a>" then
        do NP():SendToUser(tradeid, data) end
    --------------------------------
    --     Trade Request(24c)     --
    --------------------------------
      --elseif cmd == "<24c>" then
        --do 
          --data = string.gsub(data, " ", "") 
          --NP():SendToUser(user.id,"<24a>"..data.."</24a>")
          --NP():SendToUser(trade_id, data)
        --end
    --------------------------------
    --     Trade Exit(24d)        --
    --------------------------------
      elseif cmd == "<24d>" then
        do 
          data = string.gsub(data, " ", "")  
          NP():SendToUser(tradeid, data) 
        end
    --------------------------------
    --     Trade Man ID(25)      --
    --------------------------------
      elseif cmd == "<25>" then
        do 
          data = string.gsub(data, " ", "") 
          tradeid = string.gsub(data, "<25>", "") 
        end
    --------------------------------
    --     Buddy Man ID(Bud)     --
    --------------------------------
      elseif cmd == "<bud>" then
        do 
          data = string.gsub(data, " ", "") 
          buddy = string.gsub(data, "<25>", "") 
        end
    --------------------------------
    --     Buddy Request(bud2)     --
    --------------------------------
      elseif cmd == "<bud2>" then
        do NP():SendToUser(buddy, data) end
    --------------------------------
    --     Trade Request(24a)     --
    --------------------------------
      elseif cmd == "<25a>" then
        do NP():SendToUser(tradeid, data) end
    --------------------------------
    --     Trade Request(24b)     --
    --------------------------------
      elseif cmd == "<25b>" then
        do NP():SendToUser(tradeid, data) end
    --------------------------------
    --     Trade Request(24d)     --
    --------------------------------
      elseif cmd == "<25d>" then
      do
      local data = string.gsub(data,"<25d>","")
        NP():SendToUser(tradeid, "<25d "..user.id..">"..data)
        end
    --------------------------------
    --     Buddy Request(bud3)     --
    --------------------------------
      elseif cmd == "<bud3>" then
        do NP():SendToUser(tradeid, data) end
    --------------------------------
    --     Trade Request(24e)     --
    --------------------------------
      elseif cmd == "<25e>" then
        do NP():SendToUser(tradeid, data) end
    --------------------------------
    --     Trade Request(24f)     --
    --------------------------------
      elseif cmd == "<25f>" then
        do NP():SendToUser(tradeid, data) end
     
          elseif cmd == "<25g>" then
        do NP():SendToUser(tradeid, data) end
     
          elseif cmd == "<25h>" then
        do NP():SendToUser(tradeid, data) end
     
            elseif cmd == "<25i>" then
        do NP():SendToUser(tradeid, data) end
    --------------------------------
    --         Bubble Chat        --
    --------------------------------
      elseif cmd == "<bubble>" then
    do
          local chat = string.gsub(data,"<bubble>","")
          NP():SendToAll("<bubble "..user.id..">"..chat)
     end
    --------------------------------
    --         Erase Event        --
    --------------------------------
      elseif cmd == "<eraseevent>" then
    do
          local id = string.gsub(data,"<eraseevent>","")
          NP():SendToAll("<eraseevent "..user.id..">"..id)
    end
    --------------------------------
    --         Change Var         --
    --------------------------------
      elseif cmd == "<changevar>" then
    do
          local id = string.gsub(data,"<changevar>","")
          NP():SendToAll("<changevar>"..var..">"..id)
    end
    end
    end

    Network Code:

    Code:
    #===============================================================================
    # ** Network - Manages network data.
    #-------------------------------------------------------------------------------
    # Author    Me™ and Shark_Tooth
    # Version   1.0
    # Date      11-04-06
    #===============================================================================
    #-------------------------------------------------------------------------------
    # Begin SDK Enabled Check
    #-------------------------------------------------------------------------------
    module Network
     
    class Main
     
      #--------------------------------------------------------------------------
      # * Attributes
      #-------------------------------------------------------------------------- 
      attr_accessor :socket
      attr_accessor :pm
      # getpm, pmname, writepm
     
      # AUTHENFICATION  = 0     => Authenficates
      # ID_REQUEST      = 1     => Returns ID
      # NAME_REQUEST    = 2     => Returns UserName
      # GROUP_REQUEST   = 3     => Returns Group
      # CLOSE           = 4     => Close, Stop Connection
      # NET_PLAYER      = 5     => Netplayers Data
      # MAP_PLAYER      = 6     => Mapplayers Data
      # KICK            = 7     => Kick a Player
      # KICK ALL        = 8     => Kick all Players
      # REMOVE          = 9     => Remove Player (CLOSE SYNONYM)
      # SYSTEM          = 10    => System (Var's and Switches)
      # MOD_CHANGE      = 11    => Message ot Day Change
      # TRADE           = 12    => Trade
      # PRIVATE_CHAT    = 13    => Private Chat 
      #                 = 14
      # POKE            = 15    => Poke Player
      # SLAP            = 16    => Decrease HP or SP PLayer
      # SLAP ALL        = 17    => Decrease Hp or SP ALL
      # ADM - MOD       = 18    => Admin/Mod Command Returns
      #                 = 19 
      # TEST STOP       = 20    => Connection Test End
     
      #--------------------------------------------------------------------------
      # * Initialiation
      #-------------------------------------------------------------------------- 
      def self.initialize
        @players    = {}
        @mapplayers = {}
        @netactors  = {}
        @pm = {}
        @pm_lines = []
        @user_test  = false
        @user_exist = false
        @socket     = nil
        @nooprec    = 0
        @id         = -1
        @name       = ""
        @group      = ""
        @status     = ""
        @oldx       = -1
        @oldy       = -1
        @oldd       = -1
        @oldp       = -1
        @oldid      = -1
        @login      = false
        @pchat_conf = false
        @send_conf  = false
        @trade_conf = false
        @servername = ""
        @pm_getting = false
        @self_key1 = nil
        @self_key2 = nil
        @self_key3 = nil
        @self_value = nil
        @trade_compelete = false
        @trading = false
        @trade_id = -1
      end
      #--------------------------------------------------------------------------
      # * Returns Servername
      #-------------------------------------------------------------------------- 
      def self.servername
        return @servername.to_s
      end
      #--------------------------------------------------------------------------
      # * Returns Socket
      #-------------------------------------------------------------------------- 
      def self.socket
        return @socket
      end
      #--------------------------------------------------------------------------
      # * Returns UserID
      #-------------------------------------------------------------------------- 
      def self.id
        return @id
      end
      #--------------------------------------------------------------------------
      # * Returns UserName
      #-------------------------------------------------------------------------- 
      def self.name
        return @name
      end  
      #--------------------------------------------------------------------------
      # * Returns current Status
      #-------------------------------------------------------------------------- 
      def self.status
        return "" if @status == nil or @status == []
        return @status
      end
      #--------------------------------------------------------------------------
      # * Returns Group
      #-------------------------------------------------------------------------- 
      def self.group
        if @group.downcase.include?("adm")
          group = "admin"
        elsif @group.downcase.include?("mod")
          group = "mod"
        else
          group = "standard"
        end
        return group
      end
      #--------------------------------------------------------------------------
      # * Returns Mapplayers
      #-------------------------------------------------------------------------- 
      def self.mapplayers
        return {} if @mapplayers == nil
        return @mapplayers
      end
      #--------------------------------------------------------------------------
      # * Returns NetActors
      #-------------------------------------------------------------------------- 
      def self.netactors
        return {} if @netactors == nil
        return @netactors
      end
      #--------------------------------------------------------------------------
      # * Returns Players
      #-------------------------------------------------------------------------- 
      def self.players
        return {} if @players == nil
        return @players
      end
      #--------------------------------------------------------------------------
      # * Destroys player
      #-------------------------------------------------------------------------- 
      def self.destroy(id)
        @players[id.to_s] = nil rescue nil
        @mapplayers[id.to_s] = "" rescue nil
        for player in @mapplayers
          @mapplayers.delete(id.to_s) if player[0].to_i == id.to_i
        end
        for player in @players
          @players.delete(id.to_s) if player[0].to_i == id.to_i
        end
        if $scene.is_a?(Scene_Map)
          begin
            $scene.spriteset[id].dispose unless $scene.spriteset[id].disposed?
          rescue
            nil
          end
        end
      end
      #--------------------------------------------------------------------------
      # * Create A socket
      #-------------------------------------------------------------------------- 
      def self.start_connection(host, port)
        @socket = TCPSocket.new(host, port)
      end
      #--------------------------------------------------------------------------
      # * Asks for Id
      #-------------------------------------------------------------------------- 
      def self.get_id
        @socket.send("<1>'req'</1>\n")
      end
      #--------------------------------------------------------------------------
      # * Asks for name
      #-------------------------------------------------------------------------- 
      def self.get_name
        @socket.send("<2>'req'</2>\n")
      end
      #--------------------------------------------------------------------------
      # * Asks for Group
      #-------------------------------------------------------------------------- 
      def self.get_group
        #@socket.send("<3>'req'</3>\n")
        @socket.send("<check>#{self.name}</check>\n")
      end
      #--------------------------------------------------------------------------
      # * Registers (Attempt to)
      #-------------------------------------------------------------------------- 
      def self.send_register(user,pass)
        # Register with User as name, and Pass as password
        @socket.send("<reges #{user}>#{pass}</reges>\n")
        # Start Loop for Retrival
        loop = 0
          loop do
          loop += 1
          self.update
          # Break If Registration Succeeded
          break if @registered
          # Break if Loop reached 10000
          break if loop == 10000
        end
      end
      #--------------------------------------------------------------------------
      # * Asks for Network Version Number
      #-------------------------------------------------------------------------- 
      def self.retrieve_version
        @socket.send("<ver>#{User_Edit::VERSION}</ver>\n")
      end
      #--------------------------------------------------------------------------
      # * Asks for Message of the day
      #-------------------------------------------------------------------------- 
      def self.retrieve_mod
        @socket.send("<mod>'request'</mod>\n")
      end
      #--------------------------------------------------------------------------
      # * Asks for Login (and confirmation)
      #-------------------------------------------------------------------------- 
      def self.send_login(user,pass)
        @socket.send("<login #{user}>#{pass}</login>\n")
      end
      #--------------------------------------------------------------------------
      # * Send Errors
      #-------------------------------------------------------------------------- 
      def self.send_error(lines)
        if lines.is_a?(Array)
          for line in lines
            @socket.send("<err>#{line}</err>\n")
          end
        elsif lines.is_a?(String)
          @socket.send("<err>#{lines}</err>\n")
        end
      end  
      #--------------------------------------------------------------------------
      # * Authenfication
      #-------------------------------------------------------------------------- 
      def self.amnet_auth
        # Send Authenfication
        @socket.send("<0>'e'</0>\n")
        @auth = false
        # Set Try to 0, then start Loop
        try = 0
        loop do
          # Add 1 to Try
          try += 1
          loop = 0
          # Start Loop for Retrieval
          loop do
            loop += 1
            self.update
            # Break if Authenficated
            break if @auth
            # Break if loop reaches 20000
            break if loop == 20000
          end
          # If the loop was breaked because it reached 10000, display message
          p "#{User_Edit::NOTAUTH}, Try #{try} of #{User_Edit::CONNFAILTRY}" if loop == 20000
          # Stop everything if try mets the maximum try's
          break if try == User_Edit::CONNFAILTRY
          # Break loop if Authenficated
          break if @auth
        end
        # Go to Scene Login if Authenficated
        $scene = Scene_Login.new if @auth
      end
      #--------------------------------------------------------------------------
      # * Send Start Data
      #-------------------------------------------------------------------------- 
      def self.send_start
        send = ""
        # Send Username And character's Graphic Name
        send += "@username = '#{self.name}'; @character_name = '#{$game_player.character_name}';"
        # Sends Map ID, X and Y positions
        send += "@map_id = #{$game_map.map_id}; @x = #{$game_player.x}; @y = #{$game_player.y};"
        # Sends Name
        send += "@name = '#{$Trainer.name}';" if User_Edit::Bandwith >= 1
        # Sends Direction
        send += "@direction = #{$game_player.direction};" if User_Edit::Bandwith >= 2
        # Sends Move Speed
        send += "@move_speed = #{$game_player.move_speed};" if User_Edit::Bandwith >= 3
        # Sends Requesting start
        send+= "start(#{self.id});"
        @socket.send("<5>#{send}</5>\n")
        #send_actor_start
      end
      #--------------------------------------------------------------------------
      # * Return PMs
      #-------------------------------------------------------------------------
      def self.pm
        return @pm
      end
      #--------------------------------------------------------------------------
      # * Get PMs
      #-------------------------------------------------------------------------- 
      def self.get_pms
        @pm_getting = true
        @socket.send("<22a>'Get';</22a>\n")
      end
      #--------------------------------------------------------------------------
      # * Update PMs
      #-------------------------------------------------------------------------- 
      def self.update_pms(message)
       #Starts all the variables
       @pm = {}
       @current_Pm = nil
       @index = -1
       @message = false
       #Makes a loop to look thru the message
       for line in message
         #If the line is a new PM
         if line == "$NEWPM"
          @index+=1
          @pm[@index] = Game_PM.new(@index)
          @message = false
          #if the word has $to_from
         elsif line == "$to_from" and @message == false
           to_from = true
          #if the word has $subject
         elsif line == "$Subject" and @message == false
           subject = true
          #if the word has $message
         elsif line == "$Message" and @message == false
           @message = true
         elsif @message
           @pm[@index].message += line+"\n"
         elsif to_from
           @pm[@index].to_from = line
           to_from = false
         elsif subject
           @pm[@index].subject = line
           subject = false
         end
       end
       @pm_getting = false
     end
      #--------------------------------------------------------------------------
      # * Checks if the PM is still not get.
      #-------------------------------------------------------------------------- 
      def self.pm_getting
        return @pm_getting
      end
      #--------------------------------------------------------------------------
      # * Write PMs
      #-------------------------------------------------------------------------- 
      def self.write_pms(message)
        send = message
        @socket.send("<22d>#{send}</22d>\n")
      end
      #--------------------------------------------------------------------------
      # * Delete All PMs
      #-------------------------------------------------------------------------- 
      def self.delete_all_pms
        @socket.send("<22e>'delete'</22e>\n")
        @pm = {}
      end
      #--------------------------------------------------------------------------
      # * Delete pm(id)
      #-------------------------------------------------------------------------- 
      def self.delete_pm(id)
        @pm.delete(id)
      end
      #--------------------------------------------------------------------------
      # * Send Requested Data
      #-------------------------------------------------------------------------- 
      def self.send_start_request(id)
        send = ""
        # Send Username And character's Graphic Name
        send += "@username = '#{self.name}'; @character_name = '#{$game_player.character_name}'; "
        # Sends Map ID, X and Y positions
        send += "@map_id = #{$game_map.map_id}; @x = #{$game_player.x}; @y = #{$game_player.y}; "
        # Sends Name
        send += "@name = '#{$Trainer.name}'; " if User_Edit::Bandwith >= 1
        # Sends Direction
        send += "@direction = #{$game_player.direction}; " if User_Edit::Bandwith >= 2
        # Sends Move Speed
        send += "@move_speed = #{$game_player.move_speed};" if User_Edit::Bandwith >= 3 
        #@socket.send("<6a>#{id.to_i}</6a>\n")
        @socket.send("<5>#{send}</5>\n")
        #self.send_map
        #self.send_actor_start
      end
      #--------------------------------------------------------------------------
      # * Send Map Id data
      #-------------------------------------------------------------------------- 
      def self.send_map
        send = ""
        # Send Username And character's Graphic Name
        send += "@username = '#{self.name}'; @character_name = '#{$game_player.character_name}'; "
        # Sends Map ID, X and Y positions
        send += "@map_id = #{$game_map.map_id}; @x = #{$game_player.x}; @y = #{$game_player.y}; "
        # Sends Direction
        send += "@direction = #{$game_player.direction};" if User_Edit::Bandwith >= 2
        @socket.send("<5>#{send}</5>\n") 
        for player in @players.values
          next if player.netid == -1
          # If the Player is on the same map...
          if player.map_id == $game_map.map_id
            # Update Map Players
            self.update_map_player(player.netid, nil)
          elsif @mapplayers[player.netid.to_s] != nil
            # Remove from Map Players
            self.update_map_player(player.netid, nil, true)
          end
        end
      end
      #--------------------------------------------------------------------------
      # * Sends your party to the other player
      #-------------------------------------------------------------------------- 
      def self.send_party(netid,string)
        @socket.send("<24>#{netid}\n")
        @socket.send("<24a>#{string}</24a>\n")
      end
      #--------------------------------------------------------------------------
      # * Sends global Variables to everyone
      #-------------------------------------------------------------------------- 
      def self.send_var(netid,string)
        @socket.send("<var>#{netid}\n")
        @socket.send("<vara>#{string}</vara>\n")
      end
      #--------------------------------------------------------------------------
      # * Calls a player to trade
      #-------------------------------------------------------------------------- 
      def self.trade_call(id)
        @trade_compelete = false
        @trading = true
        @socket.send("<24>#{id}\n")
        ids = self.id
        @socket.send("<24c>@trade_id = #{ids}</24c>\n")
      end
      #--------------------------------------------------------------------------
      # * Exit trade.
      #-------------------------------------------------------------------------- 
      def self.trade_exit(id)
        @socket.send("<24>#{id}\n")
        ids = self.id
        @socket.send("<24d>trade_exit = #{ids}</24d>\n")
      end
      #--------------------------------------------------------------------------
      # * Checks if the trade is compelete
      #-------------------------------------------------------------------------- 
      def self.trade_compelete
        return @trade_compelete
      end
      #--------------------------------------------------------------------------
      # * Checks the trade result
      #-------------------------------------------------------------------------- 
      def self.trading
        return @trading
      end
      #--------------------------------------------------------------------------
      # * Send Move Update
      #--------------------------------------------------------------------------
      def self.send_trade_choice(netid,choice)
        @socket.send("<25>#{netid}\n")
        me = self.id
        @socket.send("<25a>#{choice}</25a>\n")
      end
      #--------------------------------------------------------------------------
      # * Send Move Update
      #--------------------------------------------------------------------------
      def self.trade_remove(kind,item_id,netid)
        @socket.send("<25>#{netid}\n")
        me = self.id
        @socket.send("<25b>i_kind = #{kind}; i_id = #{item_id}; id = #{me};</25b>\n")
      end
      #--------------------------------------------------------------------------
      # * Send Trade Request
      #--------------------------------------------------------------------------
      def self.trade_request(netid)
        @socket.send("<25>#{netid}\n")
        name = self.name
        @socket.send("<25d>#{name}</25d>\n")
      end
      #--------------------------------------------------------------------------
      # * Send Buddy Request
      #--------------------------------------------------------------------------
      def self.buddy_request(netid)
        @socket.send("<bud>#{netid}\n")
        name = self.name
        @socket.send("<bud2>#{name}</bud2>\n")
      end
      #--------------------------------------------------------------------------
      # * Send accept trade
      #--------------------------------------------------------------------------
      def self.accept_trade(netid)
        @socket.send("<25>#{netid}\n")
        me = self.id
        @socket.send("<25e>accepted</25e>\n")
      end
      #--------------------------------------------------------------------------
      # * Send accept buddy
      #--------------------------------------------------------------------------
      def self.accept_buddy(netid)
        @socket.send("<bud3>#{netid}\n")
        me = self.id
        @socket.send("<bud3>accepted</bud3>\n")
        $scene = Scene_Buddyup.new(@playerid,@playername)
      end
      #--------------------------------------------------------------------------
      # * Send cancel trade
      #--------------------------------------------------------------------------
      def self.decline_trade(netid)
        @socket.send("<25>#{netid}\n")
        me = self.id
        @socket.send("<25f>#{me};</25f>\n")
      end
     
        def self.trade_dead(netid)
        @socket.send("<25>#{netid}\n")
        me = self.id
        @socket.send("<25g>#{me};</25g>\n")
      end
      #--------------------------------------------------------------------------
      # * Send final accept trade
      #--------------------------------------------------------------------------
      def self.send_final_accept(netid)
        @socket.send("<25>#{netid}\n")
        me = self.id
        @socket.send("<25h>accepted</25h>\n")
      end
      #--------------------------------------------------------------------------
      # * Send final decline trade
      #--------------------------------------------------------------------------
      def self.send_final_decline(netid)
        @socket.send("<25>#{netid}\n")
        me = self.id
        @socket.send("<25i>decline</25i>\n")
      end
      #--------------------------------------------------------------------------
      # * Send Move Update
      #-------------------------------------------------------------------------- 
      def self.send_move_change
        return if @oldx == $game_player.x and @oldy == $game_player.y
        return if @mapplayers == {}
        send = ""
        # Increase Steps if the oldx or the oldy do not match the new ones
        if User_Edit::Bandwith >= 1
          send += "ic;"  if @oldx != $game_player.x or @oldy != $game_player.y
        end
        # New x if x does not mathc the old one
        if @oldx != $game_player.x
          send += "@x = #{$game_player.x}; @tile_id = #{$game_player.tile_id};"
          @oldx = $game_player.x
        end
        # New y if y does not match the old one
        if @oldy != $game_player.y
          send += "@y = #{$game_player.y}; @tile_id = #{$game_player.tile_id};"
          @oldy = $game_player.y
        end
        # Send the Direction if it is different then before
        if User_Edit::Bandwith >= 2
          if @oldd != $game_player.direction 
            send += "@direction = #{$game_player.direction};"  
            @oldd = $game_player.direction
          end
        end
        # Send everything that needs to be sended
        @socket.send("<5>#{send}</5>\n") if send != ""
        end
      #--------------------------------------------------------------------------
      # * Send HP
      #-------------------------------------------------------------------------- 
      def self.send_newhp
        @socket.send("<5>@hp = #{$game_party.actors[0].hp};</5>\n")
      end
      #--------------------------------------------------------------------------
      # * Close Socket
      #-------------------------------------------------------------------------- 
      def self.close_socket
        return if @socket == nil
        @socket.send("<9>#{self.id}</9>\n")
        #@socket.send("<4>'Close'</4>\n")
        @socket.close
        @socket = nil
      end
      #--------------------------------------------------------------------------
      # * Change Messgae of the Day
      #-------------------------------------------------------------------------- 
      def self.change_mod(newmsg)
        @socket.send("<11>#{newmsg}</11>\n")
      end
      #--------------------------------------------------------------------------
      # * Private Chat Send
      #--------------------------------------------------------------------------
      def self.pchat(id,mesg)
        @pchat_conf = false
        # Send the Private Chat Id (without close!!! \<13a>)
        @socket.send("<13a>#{id}\n") 
        # Send Priavte Chat Message
        @socket.send("<13>#{mesg}</13>\n") #if @pchat_conf
        #p "could not send #{mesg} to #{id}..." if not @pchat_conf
      end
      #--------------------------------------------------------------------------
      # * Private Chat Send
      #--------------------------------------------------------------------------
      def self.mchat(id,mesg)
        @mchat_conf = false
        # Send the Chat Id (without close!!! \<21a>)
        @socket.send("<21a>#{id}\n") 
        # Send Chat Message
        @socket.send("<21>#{mesg}</21>\n")
      end
      #--------------------------------------------------------------------------
      # * Check if the user exists on the network..
      #--------------------------------------------------------------------------
      def self.user_exist?(username)
        # Enable the test
        @user_test  = true
        @user_exist = false
        # Send the data for the test
        self.send_login(username.to_s,"*test*")
        # Check for how to long to wait for data (Dependent on username size)
        if username.size <= 8
          # Wait 1.5 seconds if username is less then 8
          for frame in 0..(1.5*40)
            self.update
          end
        elsif username.size > 8 and username.size <= 15
          # Wait 2.3 seconds if username is less then 15
          for frame in 0..(2.3*40)
            self.update
          end
        elsif username.size > 15
          # Wait 3 seconds if username is more then 15
          for frame in 0..(3*40)
            self.update
          end
        end
        # Start Retreival Loop
        loop = 0
        loop do
          loop += 1
          self.update
          # Break if User Test was Finished
          break if @user_test == false
          # Break if loop meets 10000
          break if loop == 10000
        end
        # If it failed, display message
        p User_Edit::USERTFAIL if loop == 10000
        # Return User exists if failed, or if it exists
        return true if @user_exist or loop == 10000
        return false
      end
      #--------------------------------------------------------------------------
      # * Trade
      #-------------------------------------------------------------------------- 
      def self.trade(id,type,item,num=1,todo='gain')
        # Gain is used for normal trade,
        # Lose is used as Admin Command
        # Check if you got item
        case type
         when 0
          got = $game_party.item_number(item)
         when 1
          got = $game_party.weapon_number(item)
         when 2
          got = $game_party.armor_number(item)
        end
        # Print if not, return
        p "#{User_Edit::DONTGOTTRADE} (trade: kind = #{type} id = #{item})" if got == 0 and todo == 'gain'
        return if got == 0 and todo == 'gain'
        p "#{User_Edit::NOTENOUGHTRADE} (trade: kind = #{type} id = #{item})" if got < num and todo == 'gain'
        return if got < num and todo == 'gain'
        @pchat_conf = false
        # Send the Trade Id (without close!!! \<12a>)
        @socket.send("<12a>#{id}\n") 
        @socket.send("<12>type=#{type} item=#{item} num=#{num} todo=#{todo}</12>\n")
          case type
           when 0
            $game_party.lose_item(item,num) if todo == 'gain'
           when 1
            $game_party.lose_weapon(item, num)  if todo == 'gain'
           when 2
            $game_party.lose_armor(item, num)  if todo == 'gain'
          end
      end
      #--------------------------------------------------------------------------
      # * Send Result
      #-------------------------------------------------------------------------- 
      def self.send_result(id)
        @socket.send("<result_id>#{id}</result_id>\n")
        @socket.send("<result_effect>#{self.id}</result_effect>\n")
      end
      #--------------------------------------------------------------------------
      # * Send Dead
      #-------------------------------------------------------------------------- 
      def self.send_dead
        @socket.send("<9>#{self.id}</9>\n")
      end
      #--------------------------------------------------------------------------
      # * Update Net Players
      #-------------------------------------------------------------------------- 
      def self.update_net_player(id, data)
        # Turn Id in Hash into Netplayer (if not yet)
        @players[id] ||= Game_NetPlayer.new 
        # Set the Global NetId if it is not Set yet
        @players[id].do_id(id) if @players[id].netid == -1
        # Refresh -> Change data to new data
        @players[id].refresh(data)      
        # Return if the Id is Yourself
        return if id.to_i == self.id.to_i
        # Return if you are not yet on a Map
        return if $game_map == nil
        # If the Player is on the same map...
        if @players[id].map_id == $game_map.map_id
          # Update Map Players
          self.update_map_player(id, data)
        elsif @mapplayers[id] != nil
          # Remove from Map Players
          self.update_map_player(id, data, true)
        end
      end
      #--------------------------------------------------------------------------
      # * Update Map Players
      #-------------------------------------------------------------------------- 
      def self.update_map_player(id, data, kill=false)
        # Return if the Id is Yourself
        return if id.to_i == self.id.to_i
        # If Kill (remove) is true...
        if kill and @mapplayers[id] != nil
          # Delete Map Player
          @mapplayers.delete(id.to_i) rescue nil
          if $scene.is_a?(Scene_Map)
             $scene.spriteset.delete(id.to_i) rescue nil
          end
          $game_temp.spriteset_refresh = true
          return
        end
        @mapplayers[id] ||= @players[id] if @players[id] != nil
        # Turn Id in Hash into Netplayer (if not yet)
        @mapplayers[id] ||= Game_NetPlayer.new
        # Set the Global NetId if it is not Set yet
        @mapplayers[id].netid = id if @mapplayers[id].netid == -1
        # Refresh -> Change data to new data
        @mapplayers[id].refresh(data)
      end
      #--------------------------------------------------------------------------
      # * Update Net Actors
      #-------------------------------------------------------------------------- 
      def self.update_net_actor(id,data,actor_id)
        return
        return if id.to_i == self.id.to_i
        # Turn Id in Hash into Netplayer (if not yet)
        @netactors[id] ||= Game_NetActor.new(actor_id)
        # Set the Global NetId if it is not Set yet
        @netactors[id].netid = id if @netactors[id].netid == -1
        # Refresh -> Change data to new data
        @netactors[id].refresh(data)
      end
      #--------------------------------------------------------------------------
      # * Update
      #-------------------------------------------------------------------------- 
      def self.update
        # If Socket got lines, continue
        return unless @socket.ready?
        for line in @socket.recv(0xfff).split("\n")
          @nooprec += 1 if line.include?("\000\000\000\000") 
          return if line.include?("\000\000\000\000")
          p "#{line}" unless line.include?("<5>") or line.include?("<6>")or not $DEBUG or not User_Edit::PRINTLINES
          # Set Used line to false
          updatebool = false
          #Update Walking
          updatebool = self.update_walking(line) if @login and $game_map != nil
          # Update Ingame Protocol, if LogedIn and Map loaded
          updatebool = self.update_ingame(line)  if updatebool == false and @login and $game_map != nil
          # Update System Protocol, if command is not Ingame
          updatebool = self.update_system(line)  if updatebool == false 
          # Update Admin/Mod Protocol, if command is not System
          updatebool = self.update_admmod(line)  if updatebool == false
          # Update Outgame Protocol, if command is not Admin/Mod
          updatebool = self.update_outgame(line) if updatebool == false
        end
      end
      #--------------------------------------------------------------------------
      # * Update Admin and Mod Command Recievals -> 18
      #-------------------------------------------------------------------------- 
      def self.update_admmod(line)
        case line
         # Admin Command Recieval
         when /<18>(.*)<\/18>/
          # Kick All Command
          if $1.to_s == "kick_all"
            p User_Edit::ADMKICKALL
            self.close_socket
            $scene = nil
            return true
          # Kick Command
          elsif $1.to_s == "kicked"
            p User_Edit::ADMKICK
            self.close_socket
            $scene = nil
            return true
          end
         return false
        end
        return false
      end
      #--------------------------------------------------------------------------
      # * Update all Not-Ingame Protocol Parts -> 0, login, reges
      #-------------------------------------------------------------------------- 
      def self.update_outgame(line)
        case line
         # Server Authenfication
         when /<0 (.*)>(.*) n=(.*)<\/0>/ 
          a = self.authenficate($1,$2)
          @servername = $3.to_s
          return true if a
         # Registration Conformation
         when /<reges>(.*)<\/reges>/
          @user_test = false
          return true
         # Login, With User Test
         when /<login>(.*)<\/login>/
          if not @user_test
            # When Log in Succeeded, and not User Test...
            if $1 == "allow" and not @user_test
              # Login and Status to Logged-in
              @login = true
              @status = User_Edit::LOGIN_STATUS
              text = [@status]
              $scene.set_status(@status) if $scene.is_a?(Scene_Login)
              # Get Name (By Server)
              self.get_name
              # Start Loop for Retrieval
              loop = 0
              loop do
                self.update
                loop += 1
                # Break if loop reaches 10000
                break if loop == 10000
                # Break if Name and ID are recieved
                break if self.name != "" and self.name != nil and self.id != -1
              end
              self.get_group
              # Goto Scene Title
              #sscene=PokemonLoadScene.new
           #sscreen=PokemonLoad.new(sscene)
           #sscreen.pbStartLoadScreen
           $scene = PokemonLoad.new(PokemonLoadScene.new)
           $scene.pbStartLoadScreen
             # return true
            # When Wrong Username and not User Test
            elsif $1 == "wu" and not @user_test
              # Set status to Incorrect Username
              @status = User_Edit::LOGIN_USERERROR
              $scene.set_status(@status) if $scene.is_a?(Scene_Login)
              return true
            # When Wrong Password and not User Test
            elsif $1 == "wp" and not @user_test
              # Set status to Incorrect Passowrd
              @status = User_Edit::LOGIN_PASSERROR
              $scene.set_status(@status) if $scene.is_a?(Scene_Login)
              return true
            # When Other Command, and Not User test
            elsif not @user_test
              # ERROR!
              @status = User_Edit::UNEXPECTLOGERR
              p @status
              return true
            end
          # If it IS a user test...
          else
            @user_exist = false
            #...and wrong user -> does not exist
            if $1 == "wu"
              # User does not Exist
              @user_exist = false
              @user_test = false
            #...and wrong pass -> does exist
            elsif $1 == "wp"
              # User Does Exist
              @user_exist = true
              @user_test = false
            end
            return true
          end
          return false
        end
        return false
      end
      #--------------------------------------------------------------------------
      # * Update System Protocol Parts -> ver, mod, 1, 2, 3, 10
      #-------------------------------------------------------------------------- 
      def self.update_system(line)
        case line
         # Version Recieval
         when /<ver>(.*)<\/ver>/ 
          $game_temp.msg = User_Edits::VER_ERROR if $1.to_s == nil 
          @version = $1.to_s if $1.to_s != nil 
          return true
         # Message Of the Day Recieval
         when /<mod>(.*)<\/mod>/
          $game_temp.motd = $1.to_s
          return true
         # User ID Recieval (Session Based)
         when /<1>(.*)<\/1>/
          @id = $1.to_s
          return true
         # User Name Recieval
         when /<2>(.*)<\/2>/
          @name = $1.to_s
          return true
         # Group Recieval
         when /<3>(.*)<\/3>/
          @group = $1.to_s
          return true
         when /<check>(.*)<\/check>/
          @group = $1.to_s
          return true
         # System Update
         when /<10>(.*)<\/10>/
          return true if $1 == nil 
          return true if $1.match(/File|system|`/)
          eval($1) 
          $game_map.need_refresh = true
          return true
         when /<23>(.*)<\/23>/
          eval($1)
          key = []
          key.push(@self_key1)
          key.push(@self_key2)
          key.push(@self_key3)
          $game_self_switches[key] = @self_value
          @self_key1 = nil
          @self_key2 = nil
          @self_key3 = nil
          @self_value = nil
          $game_map.need_refresh = true
          key = []
          return true
     
         return true
         # Attacked!
         when /<attack_effect>dam=(.*) ani=(.*) id=(.*)<\/attack_effect>/
          $game_party.actors[0].hp -= $1.to_i
          #$game_party.actors[0].attack_effect($1)
          $game_player.animation_id = $2.to_i
          #for mplayer in $scene.spriteset.network_sprites.values
          #  mplayer.show_text("Attacks",16,0) if mplayer.netid.to_i == $3.to_i
          #end  
          $scene.spriteset.charsprite.damage($1.to_i,false) if $scene.is_a?(Scene_Map)
          $scene.spriteset.charsprite.whiten if $scene.is_a?(Scene_Map)
          self.send_newhp
          if $game_party.actors[0].hp <= 0 or $game_party.actors[0].dead?
            $game_party.actors[0].hp = $game_party.actors[0].maxhp
            self.send_result($3.to_i)
            if $scene.is_a?(Scene_Map)
              $scene.spriteset.charsprite.collapse 
              while $scene.spriteset.charsprite.effect?
                Graphics.update
                $scene.spriteset.update
              end
            end
            self.send_dead
            $scene = Scene_Gameover.new 
          end
          return true
          # Killed
         when /<result_effect>(.*)<\/result_effect>/ 
           $scene.spriteset.charsprite.show_text("Killed",16,3)
           for mplayer in $scene.spriteset.network_sprites.values
              mplayer.collapse if mplayer.netid.to_i == $1.to_i
           end  
           return true
        end
        return false
      end
      #--------------------------------------------------------------------------
      # * Update Walking
      #-------------------------------------------------------------------------- 
      def self.update_walking(line)
        case line
        # Player information Processing
         when /<player id=(.*)>(.*)<\/player>/
          self.update_net_player($1, $2)
          return true
         # Player Processing
         when /<5 (.*)>(.*)<\/5>/
          # Update Player
          self.update_net_player($1, $2)
          # If it is first time connected...
          if $2.include?("start")
            # ... and it is not yourself ...
            if $1.to_i != self.id.to_i
              # ... and it is on the same map...
              if @players[$1].map_id == $game_map.map_id
                # ...  Return the Requested Information
                self.send_start_request($1.to_i)
                $game_temp.spriteset_refresh = true
              end
            end
          end
         return true
         # Map PLayer Processing
         when /<6 (.*)>(.*)<\/6>/
          # Return if it is yourself
          return true if $1.to_i == self.id.to_i
          # Update Map Player
          #self.update_map_player($1, $2)
          self.update_net_player($1, $2)
          # If it is first time connected...
          if $2.include?("start") or $2.include?("map")
            # ... and it is not yourself ...
            if $1.to_i != self.id.to_i
              # ... and it is on the same map...
              if @players[$1].map_id == $game_map.map_id
                # ...  Return the Requested Information
                self.send_start_request($1.to_i)
                $game_temp.spriteset_refresh = true
              end
            end
          end
          return true
        # Map PLayer Processing
         when /<netact (.*)>data=(.*) id=(.*)<\/netact>/
          # Return if it is yourself
          return true if $1.to_i == self.id.to_i
          # Update Map Player
          self.update_net_actor($1, $2, $3)
          return true
        end
        return false
      end
      #--------------------------------------------------------------------------
      # * Update Ingame Parts -> player, 5, 6, 9, 12, 13
      #-------------------------------------------------------------------------- 
      def self.update_ingame(line)
        case line
         when /<6a>(.*)<\/6a>/
           @send_conf = true
           return true if $1.to_s ==  "'Confirmed'"
         # Chat Recieval
         when /<chat>(.*)<\/chat>/    
          $game_temp.chat_log.push($1.to_s)
          $game_temp.chat_refresh = true
          return true
         # Remove Player ( Disconnected )
         when /<9>(.*)<\/9>/
          # Destroy Netplayer and MapPlayer things
          self.destroy($1.to_i)
          # Redraw Mapplayer Sprites
          $game_temp.spriteset_refresh = true
    #      $game_temp.spriteset_renew = true
          if $game_temp.tradeid == $1.to_i
            $game_temp.trade_request_declined = true
            end
         when /<12>type=(.*) item=(.*) num=(.*) todo=(.*)<\/12>/
          case $1.to_i
           when 0
            $game_party.gain_item($2.to_i, $3.to_i)    if $4 == 'gain' 
            $game_party.lose_item($2.to_i, $3.to_i)    if $4 == 'lose' 
           when 1
            $game_party.gain_weapon($2.to_i, $3.to_i)  if $4 == 'gain' 
            $game_party.lose_weapon($2.to_i, $3.to_i)  if $4 == 'lose' 
           when 2
            $game_party.gain_armor($2.to_i, $3.to_i)   if $4 == 'gain'
            $game_party.lose_weapon($2.to_i, $3.to_i)  if $4 == 'lose' 
          end
          $game_temp.refresh_itemtrade = true
          return true
         when /<12a>(.*)<\/12a>/
           @trade_conf = true
           return true if $1.to_s == "'Confirmed'"
         # Private Chat Incomming Message
         when /<13 (.*)>(.*)<\/13>/
           got = false
           id = false
          for chat in 0..$game_temp.pchat_log.size
            if $game_temp.lastpchatid[chat].to_i == $1.to_i
              got = true
              id = chat
            end
          end
          if got
            $game_temp.pchat_log[id].push($2)
            $game_temp.lastpchatid[id] = $1.to_i
            $game_temp.pchat_refresh[id] = true
          else
            id = $game_temp.pchat_log.size
            $game_temp.pchat_log[id] = []
            $game_temp.pchat_log[id].push($2)
            $game_temp.lastpchatid[id] = -1
            $game_temp.lastpchatid[id] = $1.to_i
            $game_temp.pchat_refresh[id] = false
            $game_temp.pchat_refresh[id] = true
          end
          return true
         # Private Chat ID confirmation
         when /<13a>(.*)<\/13a>/
          @pchat_conf = true
          return true if $1.to_s == "'Confirmed'"
         # Private Chat ID confirmation
         when /<21a>(.*)<\/21a>/
           @mchat_conf = true
           return true if $1.to_s == "'Confirmed'"
         #Map Chat Recieval
         when /<21>(.*)<\/21>/       
          $game_temp.chat_log.push($1.to_s)
          $game_temp.chat_refresh = true
          return true
        when /<22a>(.*)<\/22a>/
          if $1 != "Compelete"
            @pm_lines.push("#{$1}")
          elsif $1 == "Compelete"
            update_pms(@pm_lines)
            @pm_lines = []
          end
          return true
    when /<24a>(.*)<\/24a>/
      @data = $1.split(/,\s*/)
          $game_temp.theirparty = @data
         $game_temp.theirpartylength = 1 if @data[0] !=nil
         $game_temp.theirpartylength = 2 if @data[5] !=nil
         $game_temp.theirpartylength = 3 if @data[10] !=nil
         $game_temp.theirpartylength = 4 if @data[15] !=nil
         $game_temp.theirpartylength = 5 if @data[20] !=nil
         $game_temp.theirpartylength = 6 if @data[21] !=nil
         return true
        when /<24c>(.*)<\/24c>/
          eval($1)
          $scene = Scene_Trade.new(@trade_id)
          self.trade_add(-1,-1,@trade_id)
          @trade_id = -1
          return true
        when /<24d>(.*)<\/24d>/
          trade_exit = -1
          eval($1)
          $game_temp.trade_window.dispose
          $game_temp.trade_window = nil
          trade_exit = -1
          p 'yeah'
          return true
          when /<bud2>(.*)<\/bud2>/
         $game_temp.chat_log.push("~~" + $2.to_s + User_Edit::BUDDY_START_TEXT+ "~~")
         $game_temp.chat_refresh = true
        $scene = Scene_Buddyup.new(@playerid,@playername)
         if $game_temp.trade_dead_id.include?($2)
           $game_temp.trade_dead_id.delete($2)
           end
        when /<25a>(.*)<\/25a>/
          @data = $1.split(/,\s*/)
          $game_temp.theirchosen = @data
          $game_temp.updatechosen = true if $game_temp.theirchosen != nil
          return true
        when /<25b>(.*)<\/25b>/
          i_kind = -1
          i_id = -1
          id = -1
          eval($1)
          $game_temp.items2[id] = {} if $game_temp.items2[id] == nil
          $game_temp.weapons2[id] = {} if $game_temp.weapons2[id] == nil
          $game_temp.armors2[id] = {} if $game_temp.armors2[id] == nil
          case i_kind
          when 0
            if  $game_temp.items2[id][i_id] > 1
                $game_temp.items2[id][i_id] -= 1 
            else
                $game_temp.items2[id].delete(i_id)
            end
          when 1
            if $game_temp.weapons2[id][i_id] > 1
              $game_temp.weapons2[id][i_id] -= 1
            else
              $game_temp.weapons2[id].delete(i_id)
            end
          when 2
            if $game_temp.armors2[id][i_id] > 1
              $game_temp.armors2[id][i_id] -= 1 
            else
              $game_temp.armors2[id].delete(i_id)
            end
          end
          $game_temp.trade_refresh = true
          return true
        when /<25d (.*)>(.*)<\/25d>/
         # $game_temp.trade_accepting = true
         # p "trade"
         $game_temp.chat_log.push("~~" + $2.to_s + User_Edit::TRADE_START_TEXT+ "~~")
         $game_temp.chat_refresh = true 
         if $game_temp.trade_dead_id.include?($2)
           $game_temp.trade_dead_id.delete($2)
           end
          return true
        when /<25e>(.*)<\/25e>/ #Accept
          if $game_temp.trading == true
          $game_temp.trade_accepting = false
        elsif $game_temp.trading == false
          self.trade_dead($1)
          end
          return true
        when /<25f>(.*)<\/25f>/ #Decline
          $game_temp.trade_accepting = false
          $game_temp.trade_request_declined = true
          return true
        when /<25g>(.*)<\/25g>/ #Decline
          $game_temp.trade_dead = true
          $game_temp.trade_dead_id.push($1.to_i)
          return true
          when /<25h>(.*)<\/25h>/ #Accept
          $game_temp.final_accept = true
          return true
          when /<25i>(.*)<\/25i>/ #Accept
          $game_temp.final_decline = true
          return true
            when/<bubble (.*)>(.*)<\/bubble>/
         if $1.to_i == @id.to_i
          $game_player.show_text($2.to_s,User_Edit::BUBBLE_CHAT_COLOUR)
         else
          if @players[$1].map_id == $game_map.map_id
           @players[$1].show_text($2.to_s,User_Edit::BUBBLE_CHAT_COLOUR)
          end
         end
    return true
            when /<eraseevent (.*)>(.*)<\/eraseevent>/
             if $scene = Scene_Map
              if @players[$1].map_id == $game_map.map_id
              MInterpreter.erase_event($2.to_i)
            end
            end
    return true
    end
     
        return false
      end
      #--------------------------------------------------------------------------
      # * Authenficate <0>
      #-------------------------------------------------------------------------- 
      def self.authenficate(id,echo)
        if echo == "'e'"
          # If Echo was returned, Authenficated
          @auth = true
          @id = id
          return true
        end  
        return false
      end
     
    end
    #-------------------------------------------------------------------------------
    # End Class
    #-------------------------------------------------------------------------------
    class Base
      #--------------------------------------------------------------------------
      # * Updates Default Classes
      #-------------------------------------------------------------------------- 
      def self.update
        # Update Input
        Input.update
        # Update Graphics
        Graphics.update
        # Update Mouse
        if $mouse == nil
          $mouse = Game_Mouse.new
          end
        $mouse.update
        # Update Main (if Connected)
        Main.update if Main.socket != nil
      end
    end
    #-------------------------------------------------------------------------------
    # End Class
    #-------------------------------------------------------------------------------
    class Test
      attr_accessor :socket
      #--------------------------------------------------------------------------
      # * Returns Testing Status
      #-------------------------------------------------------------------------- 
      def self.testing
        return true if @testing
        return false
      end
      #--------------------------------------------------------------------------
      # * Tests Connection
      #-------------------------------------------------------------------------- 
      def self.test_connection(host, port)
        # We are Testing, not Complted the Test
        @testing = true
        @complete = false
        # Start Connection
        @socket = TCPSocket.new(host, port)
        if not @complete
          # If the Test Succeeded (did not encounter errors...)
          self.test_result(false)
          @socket.send("<20>'Test Completed'</20>")
          begin
            # Close Connection
            @socket.close rescue @socket = nil
          end
        end
      end
      #--------------------------------------------------------------------------
      # * Set Test Result
      #-------------------------------------------------------------------------- 
      def self.test_result(value)
        # Set Result to value, and Complete Test
        @result = value
        @complete = true
      end
      #--------------------------------------------------------------------------
      # * Returns Test Completed Status
      #-------------------------------------------------------------------------- 
      def self.testcompleted
        return @complete
      end
      #--------------------------------------------------------------------------
      # * Resets Test
      #-------------------------------------------------------------------------- 
      def self.testreset
        # Reset all Values
        @complete = false
        @socket = nil
        @result = nil
        @testing = false
      end
      #--------------------------------------------------------------------------
      # * Returns Result
      #-------------------------------------------------------------------------- 
      def self.result
        return @result
      end
    end
    #-------------------------------------------------------------------------------
    # End Class
    #-------------------------------------------------------------------------------
      #--------------------------------------------------------------------------
      # * Module Update
      #-------------------------------------------------------------------------- 
      def self.update
      end
    end
    #-------------------------------------------------------------------------------
    # End Module
    #-------------------------------------------------------------------------------
    #-------------------------------------------------------------------------------
    # End SDK Enabled Test
    #-------------------------------------------------------------------------------


    BUDDY UP CODE:
    Code:
    class Scene_Buddyup
     
      def initialize(playerid, player)
        @playerid = playerid
        @playerName = player
        Network::Main.send_party(@playerid,getpartystring)
        while true do
          if $game.temp_theirparty != nil
        receivePartyData(@playerid, @playerName)
      end
        end
      end
     
     
      def receivePartyData(playerid, playername)
         if $game_temp.id == 1
        pbRegisterBuddy(PBTrainers::PkMnTRAINER_Male,
        "Online Trainer Boy", playername, playerid)
      else
            pbRegisterBuddy(PBTrainers::PkMnTRAINER_Female,
        "Online Trainer Girl", playername, playerid)
      end
    end
     
    def pbRegisterBuddy(trainerid,trainername, name, id)
     trainer=pbLoadTrainer(trainerid,trainername,id)
     trainerobject=PokeBattle_Trainer.new(_INTL(trainername),trainerid)
     trainerobject.name = name
     trainerobject.setForeignID(id)
     for i in $game_temp.theirparty
      i.trainerID=trainerobject.id
      i.ot=trainerobject.name
      i.calcStats
      p 'hi'
    end
      p 'hi'
     $PokemonGlobal.partner=[trainerid,trainerobject.name,trainerobject.id,trainer[2]]
    end
     def getpartystring
       party = $Trainer.party
       array = []
       array.push("#{party[0].name},","#{party[0].species},","#{party[0].eggsteps},","#{party[0].personalID},","#{party[0].level},") if $Trainer.party.length >= 1
       array.push("#{party[1].name},","#{party[1].species},","#{party[1].eggsteps},","#{party[1].personalID},","#{party[1].level},") if $Trainer.party.length >= 2
       array.push("#{party[2].name},","#{party[2].species},","#{party[2].eggsteps},","#{party[2].personalID},","#{party[2].level},") if $Trainer.party.length >= 3
       array.push("#{party[3].name},","#{party[3].species},","#{party[3].eggsteps},","#{party[3].personalID},","#{party[3].level},") if $Trainer.party.length >= 4
       array.push("#{party[4].name},","#{party[4].species},","#{party[4].eggsteps},","#{party[4].personalID},","#{party[4].level},") if $Trainer.party.length >= 5
       array.push("#{party[5].name},","#{party[5].species},","#{party[5].eggsteps},","#{party[5].personalID},","#{party[5].level}") if $Trainer.party.length >= 6
      return array
      end
    end

    Pokemon Map2 Code
    Code:
    #==============================================================================
    # ** Scene_Map - Additions for Netplay Plus™
    #------------------------------------------------------------------------------
    # Author    Me™ and Shark_Tooth
    # Version   1.0
    #==============================================================================
    class Scene_Map
      attr_accessor :spriteset
      #--------------------------------------------------------------------------
      # * Initializes map.
      #--------------------------------------------------------------------------
      def initialize
        Network::Main.send_map
      end
      #--------------------------------------------------------------------------
      # * Transfer Player
      #--------------------------------------------------------------------------
      alias pldlltransfer_player transfer_player
      def transfer_player
        pldlltransfer_player
        a = Network::Main.mapplayers
        a = {}
        Network::Main.send_start
        $scene = Scene_Reinit.new
        #$game_temp.spriteset_renew = true
      end
      #--------------------------------------------------------------------------
      # * Updates Net/Map PLayers
      #--------------------------------------------------------------------------
      def update_netplayers
        if $game_temp.spriteset_renew
          @spriteset.dispose
          @spriteset = nil
          @spriteset = Spriteset_Map.new
          $game_temp.spriteset_renew = false
          return
        end
        return if Network::Main.mapplayers == {}
        for mapplayer in Network::Main.mapplayers.values
          next if mapplayer == nil
          mapplayer.update
        end
      end
      #--------------------------------------------------------------------------
      # * Updates Systems
      #--------------------------------------------------------------------------
      alias netplay2_update_systems update_systems
      def update_systems
        # Update Network
        update_network
        # Update Mouse
        update_mouse
        # Update Input
        update_input
        # Update old systems
        netplay2_update_systems
        # Update Netplayers
        update_netplayers
        # Update Move
        Network::Main.send_move_change
        # Update Chat
        update_chat
        # Update Private Chat
        update_pchat
        # Update Mouse Position
        $mouse.update
      end
      #--------------------------------------------------------------------------
      # * Updates Chat
      #--------------------------------------------------------------------------  
      def update_chat
      end
      #--------------------------------------------------------------------------
      # * Updates Private Chat
      #--------------------------------------------------------------------------
      def update_pchat
        chatdo = false
        chatid = -1
        for chat in 0..$game_temp.pchat_refresh.size
          if $game_temp.pchat_refresh[chat]
            chatdo = true
            chatid = chat
          end
        end
        $scene = Scene_PChat.new(chatid-1) unless $game_temp.pchat_refresh.size <= 1 if chatdo
        #calls chat if F7 is pressed.
      end
      #--------------------------------------------------------------------------
      # * Updates Input
      #--------------------------------------------------------------------------
      def update_input
        if Input.trigger?(Input::C)
          for player in Network::Main.mapplayers.values
            next if player == nil
            next if not face_too?(player)
          #  update_pvp if SDK.state('Player_vs_Player2')
          end
        end
      end
      #--------------------------------------------------------------------------
      # * Updates Mouse
      #--------------------------------------------------------------------------  
      def update_mouse
        if Input.triggerd?(Input::Mouse_Right)
            for player in Network::Main.mapplayers.values
              next if player == nil
              next if player.x != $mouse.map_x or player.y != $mouse.map_y
              sscene=RightMenu_Scene.new
              sscreen=RightMenu.new(sscene,player.username,player.netid) 
              sscreen.pbStartRightMenu
            end
          end
          for i in 0..$game_temp.chat_log.size - 1
                if $game_temp.chat_log[i].to_s.include?("~")
            if Input.triggerd?(Input::Mouse_Left) and $mouse.x >=10 && $mouse.x <= 328 and $mouse.y >= 320 + (i*16) - 8 && $mouse.y <= 320 + (i*16) - 8 + 32
              if $Trainer.party == []
                $game_temp.chat_log.push("Can't accept trade, you don't have any Pokemon.")
              $game_temp.chat_refresh = true
                else
              @data = $game_temp.chat_log[i]
              @data.gsub!(User_Edit::TRADE_START_TEXT,"")
              @data.gsub!("~~","")
              for p in Network::Main.mapplayers.values
              next if p == nil
              next if @data != p.username
              @id = p.netid
            end
     
            if $game_temp.trade_dead_id.include?(@id)
              #do nothing
              else
            Network::Main.accept_trade(@id)
            $scene = Scene_Trade.new(@id,@data)
          end
          end
            end
            end
          end
                  for i in 0..$game_temp.chat_log.size - 1
                if $game_temp.chat_log[i].to_s.include?("~")
            if Input.triggerd?(Input::Mouse_Left) and $mouse.x >=10 && $mouse.x <= 328 and $mouse.y >= 320 + (i*16) - 8 && $mouse.y <= 320 + (i*16) - 8 + 32
              if $Trainer.party == []
                $game_temp.chat_log.push("Can't accept buddy, you don't have any Pokemon.")
              $game_temp.chat_refresh = true
                else
              @data = $game_temp.chat_log[i]
              @data.gsub!(User_Edit::BUDDY_START_TEXT,"")
              @data.gsub!("~~","")
              for p in Network::Main.mapplayers.values
              next if p == nil
              next if @data != p.username
              @id = p.netid
            end
            if $game_temp.trade_dead_id.include?(@id)
              #do nothing
              else
            Network::Main.accept_buddy(@id)
            $scene = Scene_Buddyup.new(@id,@data)
          end
          end
            end
            end
          end
      end
      #-------------------------------------------------------------------------
      # * Faceing and next too (object) ?
      #--------------------------------------------------------------------------
      def face_too?(events)
        new_x = $game_player.x + ($game_player.direction == 6 ? 1 : $game_player.direction == 4 ? -1 : 0)
        new_y = $game_player.y + ($game_player.direction == 2 ? 1 : $game_player.direction == 8 ? -1 : 0)
        # If event coordinates are consistent
        return true if events.x == new_x and events.y == new_y
        return false
      end
      #--------------------------------------------------------------------------
      # * Updates Network
      #-------------------------------------------------------------------------- 
      def update_network
        Network::Main.update
      end
      #end class
    end

    Code:
    class RightMenu_Scene
    def pbShowCommands(commands)
     ret=-1
     cmdwindow=@sprites["cmdwindow"]
     cmdwindow.viewport=@viewport
     cmdwindow.resizeToFit(commands)
     cmdwindow.commands=commands
     cmdwindow.x=Graphics.width-cmdwindow.width
     cmdwindow.y=0
     cmdwindow.visible=true
       loop do
        cmdwindow.update
        Graphics.update
        Input.update
        pbUpdateSceneMap
        if Input.trigger?(Input::B)
         ret=-1
         break
        end
        if Input.trigger?(Input::C)
         ret=cmdwindow.index
         break
        end
       end
     return ret
    end
    def pbShowInfo(text)
      @sprites["infowindow"].resizeToFit(text,Graphics.height)
      @sprites["infowindow"].text=text
      @sprites["infowindow"].visible=true
      @infostate=true
    end
    def pbShowHelp(text)
      @sprites["helpwindow"].resizeToFit(text,Graphics.height)
      @sprites["helpwindow"].text=text
      @sprites["helpwindow"].visible=true
      @helpstate=true
      pbBottomLeft(@sprites["helpwindow"])
    end
    def pbStartScene
     @viewport=Viewport.new(0,0,Graphics.width,Graphics.height)
     @viewport.z=99999
     @sprites={}
     @sprites["cmdwindow"]=Window_CommandPokemon.new([])
     @sprites["infowindow"]=Window_UnformattedTextPokemon.newWithSize("",0,0,32,32,@viewport)
     @sprites["infowindow"].visible=false
     @sprites["helpwindow"]=Window_UnformattedTextPokemon.newWithSize("",0,0,32,32,@viewport)
     @sprites["helpwindow"].visible=false
     @sprites["cmdwindow"].visible=false
     @infostate=false
     @helpstate=false
    end
    def pbHideMenu
     @sprites["cmdwindow"].visible=false
     @sprites["infowindow"].visible=false
     @sprites["helpwindow"].visible=false
    end
    def pbShowMenu
     @sprites["cmdwindow"].visible=true
     @sprites["infowindow"].visible=@infostate
     @sprites["helpwindow"].visible=@helpstate
    end
    def pbEndScene
     pbDisposeSpriteHash(@sprites)
     @viewport.dispose
    end
    def pbRefresh
    end
    end
     
    class RightMenu
    def initialize(scene,playername,playerid)
     @scene=scene
     @playername = playername
     @playerid = playerid
    end
    def pbShowMenu
     @scene.pbRefresh
     @scene.pbShowMenu
    end
    def pbStartRightMenu
      @scene.pbStartScene
      endscene = true
      commands=[]
      cmdpchat=-1
      cmdtrade=-1
      cmdpm=-1
      cmdbuddy=-1
      cmdignore=-1
      commands[cmdpchat=commands.length]=_INTL(User_Edit::RIGHT_PRIVATE_CHAT_TEXT + @playername)
      commands[cmdtrade=commands.length]=_INTL(User_Edit::RIGHT_TRADE_TEXT + @playername)
      commands[cmdpm=commands.length]=_INTL(User_Edit::RIGHT_PERSONAL_MESSAGE_TEXT + @playername)
      commands[cmdbuddy=commands.length]=_INTL(User_Edit::RIGHT_BUDDY,@playername)
      commands[cmdignore=commands.length]=_INTL(User_Edit::RIGHT_IGNORE,@playername)
      commands[commands.length]=_INTL(User_Edit::RIGHT_EXIT_TEXT)
      Audio.se_play("Audio/SE/menu.wav")
      loop do
       [email protected](commands)
       if cmdpchat>=0 && command==cmdpchat
         $scene = Scene_PChat.new(@playerid)
         break
       elsif cmdtrade>=0 && command==cmdtrade
          if $Trainer.party == []
          $game_temp.chat_log.push("You can't send a trade invite, you don't have any Pokemon.")
          $game_temp.chat_refresh = true
          break
          else
          Network::Main.trade_request(@playerid)
          $game_temp.trading = true
          $game_temp.trade_accepting = true
          $scene = Scene_Trade.new(@playerid,@playername)
         break
         end
       elsif cmdbuddy>=0 && command==cmdbuddy
         Network::Main.buddy_request(@playerid)
         break
       elsif cmdignore>=0 && command==cmdignore
         p "add ignore"
         break
       elsif cmdpm>=0 && command==cmdpm
         p "pm with #{@playername}"
         break
       else
         break
      end
    end  
      @scene.pbEndScene if endscene
    end
    end
     
    Back
    Top