Instance Map Script Help?

Started by chaucer, September 26, 2014, 08:26:34 pm

Previous topic - Next topic

chaucer

Hello all, I've been working on a script to add instance maps to RMX-OS, and I've run into a few problems, I'm not that great of a scripter, so bear with me please. I've tried to get what i could written down which wasn't very much I'll post it below though. The problem I seem to be running into right now, is loading the instance of the map into the game. I'm not 100% sure I'm heading in the right direction either. but that's why I decided to post here before i continue any further. any help is greatly appreciated.

Spoiler: ShowHide
module MAP_SETUP
  INSTANCE_MAPS = [2]
  MAP_LIMIT = 999
end

class Instance_Maps #< Game_Map
  def initialize
    @map_id = 0
    @instance_id = (@map_id + ($network.user_id * (MAP_SETUP::MAP_LIMIT + 1))) - 1
   
  end
  def update_maps(map_id)
    @map_id = map_id
    if MAP_SETUP::INSTANCE_MAPS.include?(@map_id)
    @instance_id = (@map_id + ($network.user_id * (MAP_SETUP::MAP_LIMIT + 1))) - 1
    # Load map from file and set @map
    @map = load_data(sprintf("Data/Map%03d.rxdata", @instance_id))
    @imap = load_data(sprintf("Data/Map%03d.rxdata", @map_id))
    tileset = $data_tilesets[@imap.tileset_id]
    @tileset_name = tileset.tileset_name
    @autotile_names = tileset.autotile_names
    @panorama_name = tileset.panorama_name
    @panorama_hue = tileset.panorama_hue
    @fog_name = tileset.fog_name
    @fog_hue = tileset.fog_hue
    @fog_opacity = tileset.fog_opacity
    @fog_blend_type = tileset.fog_blend_type
    @fog_zoom = tileset.fog_zoom
    @fog_sx = tileset.fog_sx
    @fog_sy = tileset.fog_sy
    @battleback_name = tileset.battleback_name
    @passages = tileset.passages
    @priorities = tileset.priorities
    @terrain_tags = tileset.terrain_tags
    # Initialize displayed coordinates
    @display_x = 0
    @display_y = 0
    # Clear refresh request flag
    @need_refresh = false
    # Set map event data
    @events = {}
    for i in @map.events.keys
      @events[i] = Game_Event.new(@map_id, @map.events[i])
    end
    # Set common event data
    @common_events = {}
    for i in 1...$data_common_events.size
      @common_events[i] = Game_CommonEvent.new(i)
    end
    # Initialize all fog information
    @fog_ox = 0
    @fog_oy = 0
    @fog_tone = Tone.new(0, 0, 0, 0)
    @fog_tone_target = Tone.new(0, 0, 0, 0)
    @fog_tone_duration = 0
    @fog_opacity_duration = 0
    @fog_opacity_target = 0
    # Initialize scroll information
    @scroll_direction = 2
    @scroll_rest = 0
    @scroll_speed = 4
    end
  end
end

class Interpreter
  alias command_201_instance command_201
  def command_201
    command_201_instance
    @instance = Instance_Maps.new
    @instance.update_maps(@parameters[1])
    if @parameters[0] == 0 && MAP_SETUP::INSTANCE_MAPS.include?(@parameters[1])
      #$game_temp.player_new_map_id = @instance_id
      #$game_temp.player_new_x = @parameters[2]
      #$game_temp.player_new_y = @parameters[3]
      #$game_temp.player_new_direction = @parameters[4]
    end
  end
end

Ryex

I'm not sure what girl trying to do with the instance id but your going about it the wrong way. All instance do sould be greater than the limit of map ids but there shouldn't be a direct relationship between the real and instance Ids.

The server should create and assign instance ids arbitrary. The server should also provide a means of mapping the instance  into the real. Eg if I ask the sever "what is the map for instance  1372,
?" abed the server responds "2" I load the data for map 2
I no longer keep up with posts in the forum very well. If you have a question or comment, about my work, or in general I welcome PM's. if you make a post in one of my threads and I don't reply with in a day or two feel free to PM me and point it out to me.<br /><br />DropBox, the best free file syncing service there is.<br />

chaucer

September 27, 2014, 01:44:53 am #2 Last Edit: September 27, 2014, 02:03:26 am by chaucer
yeah, I'm had a feeling i was way off haha, that's why I wanted to post before i got any further into it, my logic behind instance_id was that i would take the map's ID as long as it was inside the instance map array, and well the math inside is to make sure every instance is assigned based upon a players user_id, but I don't know how to bring that map into the game, as that actual map is nil. I'm glad I posted before I continued going on that route though, I have a feeling this is gonna be a bit more complicated than I had planned, lol but I'll still give it a try. Since I'm pretty much way off right now, May I ask you to point me in the right direction, How do I go about creating server side instance id's.

edit: okay, so lets say the map limit is 1000 since rmxp map's only go to 999 so 1000 will be the start of instance maps correct? and then every instance created after that will be + 1, but I'd need to do it so the server is assigning these maps, which would mean I'd need to create an extension for RMX-OS? and then assign each instance to each player that enters the map, then when they player is transfered to an instance map, I'd tell it to load the ID of (in example) 2(this last part is the part I don't quite grasp exactly, or maybe i got all of this wrong? xD hopefully not ><)

Ryex

Your on the right track. Your go no to need to create an extension
And have it process messages. Then make the extention process requests for instance maps
I no longer keep up with posts in the forum very well. If you have a question or comment, about my work, or in general I welcome PM's. if you make a post in one of my threads and I don't reply with in a day or two feel free to PM me and point it out to me.<br /><br />DropBox, the best free file syncing service there is.<br />

chaucer

September 27, 2014, 12:09:30 pm #4 Last Edit: September 27, 2014, 12:20:17 pm by chaucer
hmm, I might be a little slow here, but by 'messages' you mean messages from the client I.E. the data that will be used for instances, or do you mean messages, like messages that the player sends through chat. lol probably a stupid question sorry.  :facepalm:

Edit: Also I've never really messed with server extensions, so I might get some things wrong, Attempting it now.

Ryex

September 27, 2014, 12:48:16 pm #5 Last Edit: September 29, 2014, 08:35:51 pm by Ryex
Lets look at it like so


this is an extension skeleton for what your looking to do

Code: ruby

module RMXOS
   
   #------------------------------------------------------------------
   # Passes the extension's main module to RMX-OS on the top
   # level so it can handle this extension.
   # Returns: Module of this extension for update.
   #------------------------------------------------------------------
   def self.load_current_extension
       return ExtensionSkeleton
   end
   
end

#======================================================================
# module ExtensionSkeleton
#======================================================================

module ExtensionSkeleton
   
   # extension version
   VERSION = 1.0
   # required RMX-OS version
   RMXOS_VERSION = 2.0
   # whether the server should update this extension in an idividual thread or not
   SERVER_THREAD = true
   # the extension's name/identifier
   IDENTIFIER = 'Extension Skeleton'
   
   # :::: START Configuration
   # - YOUR CONFIGURATION HERE
   # :::: END Configuration
   
   #------------------------------------------------------------------
   # Initializes the extension (i.e. instantiation of classes).
   #------------------------------------------------------------------
   def self.initialize
       # create mutex
       @mutex = Mutex.new
   end
   #------------------------------------------------------------------
   # Gets the local extension mutex.
   #------------------------------------------------------------------
   def self.mutex
       return @mutex
   end
   #------------------------------------------------------------------
   # Calls constant updating on the server.
   #------------------------------------------------------------------
   def self.main
       # while server is running
       while RMXOS.server.running
           @mutex.synchronize {
               self.server_update
           }
           sleep(0.1) # 0.1 seconds pause, decreases server load
       end
   end
   #------------------------------------------------------------------
   # Handles the server update.
   #------------------------------------------------------------------
   def self.server_update
       # - YOUR SERVER CODE HERE
   end
   #------------------------------------------------------------------
   # Handles updating from a client.
   # client - Client instance (from Client.rb)
   # Returns: Whether to stop check the message or not.
   #------------------------------------------------------------------
   def self.client_update(client)
       case client.message
       when /\AINSTN\t(\d\d\d)\Z/ # match INSTN at beginning of the string followed by a map id then the end of the string
           #create new instance for map ID
module RMXOS
   
   #------------------------------------------------------------------
   # Passes the extension's main module to RMX-OS on the top
   # level so it can handle this extension.
   # Returns: Module of this extension for update.
   #------------------------------------------------------------------
   def self.load_current_extension
       return ExtensionSkeleton
   end
   
end

#======================================================================
# module ExtensionSkeleton
#======================================================================

module ExtensionSkeleton
   
   # extension version
   VERSION = 1.0
   # required RMX-OS version
   RMXOS_VERSION = 2.0
   # whether the server should update this extension in an idividual thread or not
   SERVER_THREAD = true
   # the extension's name/identifier
   IDENTIFIER = 'Extension Skeleton'
   
   # :::: START Configuration
   # - YOUR CONFIGURATION HERE
   # :::: END Configuration
   
   #------------------------------------------------------------------
   # Initializes the extension (i.e. instantiation of classes).
   #------------------------------------------------------------------
   def self.initialize
       # create mutex
       @mutex = Mutex.new
   end
   #------------------------------------------------------------------
   # Gets the local extension mutex.
   #------------------------------------------------------------------
   def self.mutex
       return @mutex
   end
   #------------------------------------------------------------------
   # Calls constant updating on the server.
   #------------------------------------------------------------------
   def self.main
       # while server is running
       while RMXOS.server.running
           @mutex.synchronize {
               self.server_update
           }
           sleep(0.1) # 0.1 seconds pause, decreases server load
       end
   end
   #------------------------------------------------------------------
   # Handles the server update.
   #------------------------------------------------------------------
   def self.server_update
       # - YOUR SERVER CODE HERE
   end
   #------------------------------------------------------------------
   # Handles updating from a client.
   # client - Client instance (from Client.rb)
   # Returns: Whether to stop check the message or not.
   #------------------------------------------------------------------
   def self.client_update(client)
       case client.message
       when /\AINSTN\t(\d\d\d)\Z/ # match INSTN at beginning of the string followed by a map id then the end of the string
           #create new instance for map ID $1.to_i << capture group
           return true #the message was process by this extention, return true to prevent others form processing it
       when /\AINSTM\t(\d+)\Z/
           #return the map ID of teh passed instance ID ie ID 1002 is map 3 etc.
           client.send(sprintf('INSTM\t%03d\t%03d', instance_id, map_id)) #send back to the client the instance and map id pairing
           return true #the message was process by this extention, return true to prevent others form processing it
       end
       return false # the message was not processed by the extention, return false to allow others to process it.
   end
   
e

.to_i << capture group
           return true #the message was process by this extention, return true to prevent others form processing it
       when /\AINSTM\t(\d+)\Z/
           #return the map ID of teh passed instance ID ie ID 1002 is map 3 etc.
           client.send(sprintf('INSTM\t%03d\t%03d', instance_id, map_id)) #send back to the client the instance and map id pairing
           return true #the message was process by this extention, return true to prevent others form processing it
       end
       return false # the message was not processed by the extention, return false to allow others to process it.
   end
   
e



Then in the client

Code: ruby

@map_id = $network.send(sprintf('INSTM%03d', @instance_id))

#wait for message to be returned
@map = load_data(sprintf("Data/Map%03d.rxdata", @map_id))
I no longer keep up with posts in the forum very well. If you have a question or comment, about my work, or in general I welcome PM's. if you make a post in one of my threads and I don't reply with in a day or two feel free to PM me and point it out to me.<br /><br />DropBox, the best free file syncing service there is.<br />

chaucer

September 27, 2014, 02:03:38 pm #6 Last Edit: September 27, 2014, 05:36:16 pm by chaucer
Aww man now i feel even more stupid lol, I can make the code work based on this, I only feel dumb for my lack of knowledge of some classes/methods used to construct the skeleton extension.  :'( I need to study ruby more lol. Thanks for helping clear up how to go about it though, (I was off to another wrong start already.  :() I'll be back again if i need any more assistance ^^
Edit: well here's where I got with it so far, I believe I'm doing it right now? or is this the data that I should be putting Client side? for some reason it keeps trying to send me to map 10? I guess my problem is it's not getting the ID from the servers Instance IDs? and I'm not sure How I'd push that into the client side.

server side
Spoiler: ShowHide

module RMXOS
   
   #------------------------------------------------------------------
   # Passes the extension's main module to RMX-OS on the top
   # level so it can handle this extension.
   # Returns: Module of this extension for update.
   #------------------------------------------------------------------
   def self.load_current_extension
       return InstanceMaps
   end
   
end

#======================================================================
# module ExtensionSkeleton
#======================================================================

module InstanceMaps
   
   # extension version
   VERSION = 1.0
   # required RMX-OS version
   RMXOS_VERSION = 2.0
   # whether the server should update this extension in an idividual thread or not
   SERVER_THREAD = true
   # the extension's name/identifier
   IDENTIFIER = 'Instance_Maps'
   
   # :::: START Configuration
   #Instance start map
   INST_STRT = 1000
   #Instance Increment
   INST_INCR = 0
   # :::: END Configuration
   
   #------------------------------------------------------------------
   # Initializes the extension (i.e. instantiation of classes).
   #------------------------------------------------------------------
   def self.initialize
       # create mutex
       @mutex = Mutex.new
   end
   #------------------------------------------------------------------
   # Gets the local extension mutex.
   #------------------------------------------------------------------
   def self.mutex
       return @mutex
   end
   #------------------------------------------------------------------
   # Calls constant updating on the server.
   #------------------------------------------------------------------
   def self.main
       # while server is running
       while RMXOS.server.running
           @mutex.synchronize {
               self.server_update
           }
           sleep(0.1) # 0.1 seconds pause, decreases server load
       end
   end
   #------------------------------------------------------------------
   # Handles the server update.
   #------------------------------------------------------------------
   def self.server_update
     @incr = RMXOS::InstanceMaps.INST_INCR
     @instance_id = RMXOS::InstanceMaps.INST_STRT + @incr
     RMXOS::InstanceMaps.INST_INCR += 1
     
   end
   #------------------------------------------------------------------
   # Handles updating from a client.
   # client - Client instance (from Client.rb)
   # Returns: Whether to stop check the message or not.
   #------------------------------------------------------------------
   def self.client_update(client)
       instance_id = @instance_id
       case client.message
       when /\AINSTN\t(\d\d\d)\Z/ # match INSTN at beginning of the string followed by a map id then the end of the string
           #create new instance for map ID $1.to_i << capture group
           return true #the message was process by this extention, return true to prevent others form processing it
       when /\AINSTM\t(\d+)\Z/
           #return the map ID of teh passed instance ID ie ID 1002 is map 3 etc.
           client.send(sprintf('INSTM\t%03d\t%03d', instance_id, map_id)) #send back to the client the instance and map id pairing
           return true #the message was process by this extention, return true to prevent others form processing it
       end
       return false # the message was not processed by the extention, return false to allow others to process it.
   end
   
end


clientside
Spoiler: ShowHide

module MAP_SETUP
 INSTANCE_MAPS = [2]
end

class Instance_Maps
 def initialize
   @map_id = 0
   @old_instance_id = 1000
   
 end
 def update_maps(map_id)
   @instance_id = @old_instance_id + 1
   @map_id = $network.send(sprintf('INSTM%03d', @instance_id))
   #wait for message to be returned
   @map = load_data(sprintf("Data/Map%03d.rxdata", @map_id))
   @old_instance_id = @instance_id
 end
end

class Interpreter
 alias command_201_instance command_201
 def command_201
   command_201_instance
   @instance = Instance_Maps.new
   if @parameters[0] == 0 && MAP_SETUP::INSTANCE_MAPS.include?(@parameters[1])
     @instance.update_maps(@parameters[1])
     @parameters[1] = @map_id
   end
     $game_temp.player_new_map_id = @parameters[1]
     $game_temp.player_new_x = @parameters[2]
     $game_temp.player_new_y = @parameters[3]
     $game_temp.player_new_direction = @parameters[4]
 end
end

Ryex

Whats with the incriminating the variable in the server update code? you would only really need to update it when you add a new map, a preferably you would update a instance variable not the module constant (considering it's impossible to update a constant)

also, on the client side, $network.send does not return like I was implying, it's an async method that send a message to the server. the server then takes it's time and send a message back. and when that message come back you need to intercept the message in the RMXOS message processing method and tell the game what map to load.
I no longer keep up with posts in the forum very well. If you have a question or comment, about my work, or in general I welcome PM's. if you make a post in one of my threads and I don't reply with in a day or two feel free to PM me and point it out to me.<br /><br />DropBox, the best free file syncing service there is.<br />

chaucer

ok I modified the Server Extension a bit? I hope this is better, also sorry I'm not the best scripter lol. also honestly I don't even know how the $network.send works,  working with an extension is a bit foreign to me. but best way to learn is trial and error.

hope this is a bit better?
Spoiler: ShowHide

module RMXOS
   
    #------------------------------------------------------------------
    # Passes the extension's main module to RMX-OS on the top
    # level so it can handle this extension.
    # Returns: Module of this extension for update.
    #------------------------------------------------------------------
    def self.load_current_extension
        return InstanceMaps
    end
   
end

#======================================================================
# module ExtensionSkeleton
#======================================================================

module InstanceMaps
   
    # extension version
    VERSION = 1.0
    # required RMX-OS version
    RMXOS_VERSION = 2.0
    # whether the server should update this extension in an idividual thread or not
    SERVER_THREAD = true
    # the extension's name/identifier
    IDENTIFIER = 'Instance_Maps'
   
    # :::: START Configuration
    #Instance start map
    INST_STRT = 1000
    # :::: END Configuration
   
    #------------------------------------------------------------------
    # Initializes the extension (i.e. instantiation of classes).
    #------------------------------------------------------------------
    def self.initialize
        # create mutex
        @mutex = Mutex.new
        @old_map = client.player.map_id
        @inst_incr = 0
    end
    #------------------------------------------------------------------
    # Gets the local extension mutex.
    #------------------------------------------------------------------
    def self.mutex
        return @mutex
    end
    #------------------------------------------------------------------
    # Calls constant updating on the server.
    #------------------------------------------------------------------
    def self.main
        # while server is running
        while RMXOS.server.running
            @mutex.synchronize {
                self.server_update
            }
            sleep(0.1) # 0.1 seconds pause, decreases server load
        end
    end
    #------------------------------------------------------------------
    # Handles the server update.
    #------------------------------------------------------------------
    def self.server_update
      if @old_map != client.player.map_id
        @old_map = client.player.map_id
        @incr = inst_incr + 1
        @inst_incr = @incr
        @instance_map = RMXOS::InstanceMaps.INST_STRT + @incr
       
      end
    end
    #------------------------------------------------------------------
    # Handles updating from a client.
    # client - Client instance (from Client.rb)
    # Returns: Whether to stop check the message or not.
    #------------------------------------------------------------------
    def self.client_update(client)
        instance_id = @instance_id
        case client.message
        when /\AINSTN\t(\d\d\d)\Z/ # match INSTN at beginning of the string followed by a map id then the end of the string
            #create new instance for map ID $1.to_i << capture group
            return true #the message was process by this extention, return true to prevent others form processing it
        when /\AINSTM\t(\d+)\Z/
            #return the map ID of teh passed instance ID ie ID 1002 is map 3 etc.
            client.send(sprintf('INSTM\t%03d\t%03d', instance_id, map_id)) #send back to the client the instance and map id pairing
            return true #the message was process by this extention, return true to prevent others form processing it
        end
        return false # the message was not processed by the extention, return false to allow others to process it.
    end
   
end

Ryex

Don't beat your self up about not being the best scripter, your doing this to learn, your not SUPOSED to know everything.

that said you should probably be reading the RMX-OS source and trying to figuring out how the communication between the client and server works. it't not all the diffract but it took me about a day the first time I read it as I didn't understand client server iterations yet.

here is a basic run down

both the client and server are running infinite loops sending and waiting for messages from each other. in the client's case it's also updating graphics in that loop.

ever loop both the client and server check for incoming messages and if there is one processes it. when dealing with a network there is absolutely no way to determine how long something will take in transit as such this looping scheme is the only option.

the server starts a new thread for each connecting client and loops waiting for messages inside the new loop. it also has it's own thread with an update loop to check for new client connections and do general maintenance
the client checks for messages each graphics loop


as for your edits to the extension I don't think you've grasped what I meant yet the server_update method is for updating the plugin with the serer's main loop. it's only used for updating things inside the plugin that need to be updated constantly in relation to the server only and not the clients. in your case you might use it to remove dead instance map ids perhaps because they are no longer in use or needed.

you got the idea for using instance variables right though but your still going about assigning the ID's for maps wrong. The idea is to assign new id's on the fly, and perhaps the map is for a player and perhaps it isn't. Use a hash to map instance ID's to real map ids. when making a new instance just choose the next available number and map it to the map ID needed.
I no longer keep up with posts in the forum very well. If you have a question or comment, about my work, or in general I welcome PM's. if you make a post in one of my threads and I don't reply with in a day or two feel free to PM me and point it out to me.<br /><br />DropBox, the best free file syncing service there is.<br />

chaucer

September 27, 2014, 09:43:49 pm #10 Last Edit: September 29, 2014, 06:58:59 pm by Ryex
Haha hashes... they're not my strong point I've been trying to find out how they work I've read several ruby descriptions for it but I'm not sure if it's paid off, I'll give it a shot and see what I come up with though :) please correct me if i'm wrong.

this part would go into the server_update correct?
Code: ruby

def self.server_update
@incr = inst_incr + 1
       @inst_incr = @incr
@instance_map = RMXOS::InstanceMaps.INST_STRT + @incr
#first create the hash
hash = {@map_id => @instance_id
}
end


and to use the info I would then need to do this?

Code: ruby

def self.client_update(client)
#then send data to client? i believe?
       hash.each do |map_id,instance_id|
       case client.message
       when /\AINSTN\t(\d\d\d)\Z/ # match INSTN at beginning of the string followed by a map id then the end of the string
           #create new instance for map ID
def self.client_update(client)
#then send data to client? i believe?
       hash.each do |map_id,instance_id|
       case client.message
       when /\AINSTN\t(\d\d\d)\Z/ # match INSTN at beginning of the string followed by a map id then the end of the string
           #create new instance for map ID $1.to_i << capture group
           return true #the message was process by this extention, return true to prevent others form processing it
       when /\AINSTM\t(\d+)\Z/
           #return the map ID of teh passed instance ID ie ID 1002 is map 3 etc.
           client.send(sprintf('INSTM\t%03d\t%03d', instance_id, map_id)) #send back to the client the instance and map id pairing
           return true #the message was process by this extention, return true to prevent others form processing it
       end
       return false # the message was not processed by the extention, return false to allow others to process it.
   end
end
.to_i << capture group
           return true #the message was process by this extention, return true to prevent others form processing it
       when /\AINSTM\t(\d+)\Z/
           #return the map ID of teh passed instance ID ie ID 1002 is map 3 etc.
           client.send(sprintf('INSTM\t%03d\t%03d', instance_id, map_id)) #send back to the client the instance and map id pairing
           return true #the message was process by this extention, return true to prevent others form processing it
       end
       return false # the message was not processed by the extention, return false to allow others to process it.
   end
end

Ryex

you not hearing what I'm saying about the server_update method. don't use it it's for server side updates only. at some point you may need to use it to remove unneeded instance ID's but as of right now it should contain nothing.

in the initialize method do this


@instance_maps = {}


this creates a hash

then when a new instance is requested


@instance_maps[instance_id] = real_id


this sets the key for the requested instance_id in the hash to the value of real_id

to figure out what map to use for and given instance id


real_id = @instance_maps[instance_id]


then send that real_id back to the client.
I no longer keep up with posts in the forum very well. If you have a question or comment, about my work, or in general I welcome PM's. if you make a post in one of my threads and I don't reply with in a day or two feel free to PM me and point it out to me.<br /><br />DropBox, the best free file syncing service there is.<br />

chaucer

September 27, 2014, 11:11:57 pm #12 Last Edit: September 27, 2014, 11:14:26 pm by chaucer
Ahh Okay I thought that incrementing the instance map had to be done server side, my bad on that, and okay I'll take another swing at this hopefully on Monday I'm burned out today my mind is turning to mush as we speak lol. In the meantime, I'll studying RMXOS manual more thoroughly with the free time i get between now and then. Thanks for the assistance on this and for being patient. Hopefully I do a bit better next time haha.

Edit: I gave you a level + for the helpful and in-depth advice as well as helping explain things for me to understand easier it's greatly appreciated.  :D

chaucer

September 30, 2014, 10:18:45 pm #13 Last Edit: September 30, 2014, 10:33:19 pm by Ryex
OK! So I'm back to take another shot at getting this going, since last time I've read through RMXOS Manually thoroughly as well as did a little bit more research on hashes(a little, and I don't think I grasped much more from it but i tried lol.) and feel a bit more optimistic that I can do this. But My brain is still mush after a long day so bare with my noob-ness please if I mess up so I understand now what you were saying about the server_update  :facepalm: anyways I believe I posted this correct now...

Spoiler: ShowHide
Code: ruby

module RMXOS
   
   #------------------------------------------------------------------
   # Passes the extension's main module to RMX-OS on the top
   # level so it can handle this extension.
   # Returns: Module of this extension for update.
   #------------------------------------------------------------------
   def self.load_current_extension
       return InstanceMaps
   end
   
end

#======================================================================
# module ExtensionSkeleton
#======================================================================

module InstanceMaps
   
   # extension version
   VERSION = 1.0
   # required RMX-OS version
   RMXOS_VERSION = 2.0
   # whether the server should update this extension in an idividual thread or not
   SERVER_THREAD = true
   # the extension's name/identifier
   IDENTIFIER = 'Instance_Maps'
   
   # :::: START Configuration
   #Instance start map
   INST_STRT = 1000
   # :::: END Configuration
   
   #------------------------------------------------------------------
   # Initializes the extension (i.e. instantiation of classes).
   #------------------------------------------------------------------
   def self.initialize
       # create mutex
       @mutex = Mutex.new
       @instance_maps = {}
       @inst_incr = 0
   end
   #------------------------------------------------------------------
   # Gets the local extension mutex.
   #------------------------------------------------------------------
   def self.mutex
       return @mutex
   end
   #------------------------------------------------------------------
   # Calls constant updating on the server.
   #------------------------------------------------------------------
   def self.main
       # while server is running
       while RMXOS.server.running
           @mutex.synchronize {
               self.server_update
           }
           sleep(0.1) # 0.1 seconds pause, decreases server load
       end
   end
   #------------------------------------------------------------------
   # Handles the server update.
   #------------------------------------------------------------------
   def self.server_update
     if @old_map != client.player.map_id
       
     end
   end
   #------------------------------------------------------------------
   # Handles updating from a client.
   # client - Client instance (from Client.rb)
   # Returns: Whether to stop check the message or not.
   #------------------------------------------------------------------
   def self.client_update(client)
     instance_id = RMXOS::InstanceMaps.INST.STRT + @inst_incr
     @inst_incr += 1
     @instance_maps[instance_id] = real_id
     
       case client.message
       when /\AINSTN\t(\d\d\d)\Z/ # match INSTN at beginning of the string followed by a map id then the end of the string
           #create new instance for map ID
module RMXOS
   
   #------------------------------------------------------------------
   # Passes the extension's main module to RMX-OS on the top
   # level so it can handle this extension.
   # Returns: Module of this extension for update.
   #------------------------------------------------------------------
   def self.load_current_extension
       return InstanceMaps
   end
   
end

#======================================================================
# module ExtensionSkeleton
#======================================================================

module InstanceMaps
   
   # extension version
   VERSION = 1.0
   # required RMX-OS version
   RMXOS_VERSION = 2.0
   # whether the server should update this extension in an idividual thread or not
   SERVER_THREAD = true
   # the extension's name/identifier
   IDENTIFIER = 'Instance_Maps'
   
   # :::: START Configuration
   #Instance start map
   INST_STRT = 1000
   # :::: END Configuration
   
   #------------------------------------------------------------------
   # Initializes the extension (i.e. instantiation of classes).
   #------------------------------------------------------------------
   def self.initialize
       # create mutex
       @mutex = Mutex.new
       @instance_maps = {}
       @inst_incr = 0
   end
   #------------------------------------------------------------------
   # Gets the local extension mutex.
   #------------------------------------------------------------------
   def self.mutex
       return @mutex
   end
   #------------------------------------------------------------------
   # Calls constant updating on the server.
   #------------------------------------------------------------------
   def self.main
       # while server is running
       while RMXOS.server.running
           @mutex.synchronize {
               self.server_update
           }
           sleep(0.1) # 0.1 seconds pause, decreases server load
       end
   end
   #------------------------------------------------------------------
   # Handles the server update.
   #------------------------------------------------------------------
   def self.server_update
     if @old_map != client.player.map_id
       
     end
   end
   #------------------------------------------------------------------
   # Handles updating from a client.
   # client - Client instance (from Client.rb)
   # Returns: Whether to stop check the message or not.
   #------------------------------------------------------------------
   def self.client_update(client)
     instance_id = RMXOS::InstanceMaps.INST.STRT + @inst_incr
     @inst_incr += 1
     @instance_maps[instance_id] = real_id
     
       case client.message
       when /\AINSTN\t(\d\d\d)\Z/ # match INSTN at beginning of the string followed by a map id then the end of the string
           #create new instance for map ID $1.to_i << capture group
           return true #the message was process by this extention, return true to prevent others form processing it
       when /\AINSTM\t(\d+)\Z/
           #return the map ID of teh passed instance ID ie ID 1002 is map 3 etc.
           client.send(sprintf('INSTM\t%03d\t%03d', instance_id, map_id)) #send back to the client the instance and map id pairing
           return true #the message was process by this extention, return true to prevent others form processing it
       end
       return false # the message was not processed by the extention, return false to allow others to process it.
   end
   
end
.to_i << capture group
           return true #the message was process by this extention, return true to prevent others form processing it
       when /\AINSTM\t(\d+)\Z/
           #return the map ID of teh passed instance ID ie ID 1002 is map 3 etc.
           client.send(sprintf('INSTM\t%03d\t%03d', instance_id, map_id)) #send back to the client the instance and map id pairing
           return true #the message was process by this extention, return true to prevent others form processing it
       end
       return false # the message was not processed by the extention, return false to allow others to process it.
   end
   
end


and now, as for the real ID, I'm not sure if this is the wrong way to do it? However here's my thought on how to do it, so for real_id, let's say I create an array in a module, inside the client side plugin, I would then see if the map you're transferring the player to was a number inside the array, and then send that number to the server? or is that wrong. or was this line of code the actual code I should use as is.
real_id = @instance_maps[instance_id]

if so I'm very confused on that ._.

Ryex

your getting closer, you only need to create a new instance when one is requested so that code should go in the when block for receiving the "INSTN" (instance_new) message

Code: ruby

module RMXOS
   
    #------------------------------------------------------------------
    # Passes the extension's main module to RMX-OS on the top
    # level so it can handle this extension.
    # Returns: Module of this extension for update.
    #------------------------------------------------------------------
    def self.load_current_extension
        return InstanceMaps
    end
   
end

#======================================================================
# module ExtensionSkeleton
#======================================================================

module InstanceMaps
   
    # extension version
    VERSION = 1.0
    # required RMX-OS version
    RMXOS_VERSION = 2.0
    # whether the server should update this extension in an idividual thread or not
    SERVER_THREAD = true
    # the extension's name/identifier
    IDENTIFIER = 'Instance_Maps'
   
    # :::: START Configuration
    #Instance start map
    INST_STRT = 1000
    # :::: END Configuration
   
    #------------------------------------------------------------------
    # Initializes the extension (i.e. instantiation of classes).
    #------------------------------------------------------------------
    def self.initialize
        # create mutex
        @mutex = Mutex.new
        @instance_maps = {}
        @inst_incr = 0
    end
    #------------------------------------------------------------------
    # Gets the local extension mutex.
    #------------------------------------------------------------------
    def self.mutex
        return @mutex
    end
    #------------------------------------------------------------------
    # Calls constant updating on the server.
    #------------------------------------------------------------------
    def self.main
        # while server is running
        while RMXOS.server.running
            @mutex.synchronize {
                self.server_update
            }
            sleep(0.1) # 0.1 seconds pause, decreases server load
        end
    end
    #------------------------------------------------------------------
    # Handles the server update.
    #------------------------------------------------------------------
    def self.server_update
      if @old_map != client.player.map_id
       
      end
    end
    #------------------------------------------------------------------
    # Handles updating from a client.
    # client - Client instance (from Client.rb)
    # Returns: Whether to stop check the message or not.
    #------------------------------------------------------------------
    def self.client_update(client)     
        case client.message
        when /\AINSTN\t(\d\d\d)\Z/ # match INSTN at beginning of the string followed by a map id then the end of the string
            #create new instance for map ID
module RMXOS
   
    #------------------------------------------------------------------
    # Passes the extension's main module to RMX-OS on the top
    # level so it can handle this extension.
    # Returns: Module of this extension for update.
    #------------------------------------------------------------------
    def self.load_current_extension
        return InstanceMaps
    end
   
end

#======================================================================
# module ExtensionSkeleton
#======================================================================

module InstanceMaps
   
    # extension version
    VERSION = 1.0
    # required RMX-OS version
    RMXOS_VERSION = 2.0
    # whether the server should update this extension in an idividual thread or not
    SERVER_THREAD = true
    # the extension's name/identifier
    IDENTIFIER = 'Instance_Maps'
   
    # :::: START Configuration
    #Instance start map
    INST_STRT = 1000
    # :::: END Configuration
   
    #------------------------------------------------------------------
    # Initializes the extension (i.e. instantiation of classes).
    #------------------------------------------------------------------
    def self.initialize
        # create mutex
        @mutex = Mutex.new
        @instance_maps = {}
        @inst_incr = 0
    end
    #------------------------------------------------------------------
    # Gets the local extension mutex.
    #------------------------------------------------------------------
    def self.mutex
        return @mutex
    end
    #------------------------------------------------------------------
    # Calls constant updating on the server.
    #------------------------------------------------------------------
    def self.main
        # while server is running
        while RMXOS.server.running
            @mutex.synchronize {
                self.server_update
            }
            sleep(0.1) # 0.1 seconds pause, decreases server load
        end
    end
    #------------------------------------------------------------------
    # Handles the server update.
    #------------------------------------------------------------------
    def self.server_update
      if @old_map != client.player.map_id
       
      end
    end
    #------------------------------------------------------------------
    # Handles updating from a client.
    # client - Client instance (from Client.rb)
    # Returns: Whether to stop check the message or not.
    #------------------------------------------------------------------
    def self.client_update(client)     
        case client.message
        when /\AINSTN\t(\d\d\d)\Z/ # match INSTN at beginning of the string followed by a map id then the end of the string
            #create new instance for map ID $1.to_i << capture group
            instance_id = RMXOS::InstanceMaps.INST.STRT + @inst_incr
            @inst_incr += 1
            @instance_maps[instance_id] = real_id
            return true #the message was process by this extention, return true to prevent others form processing it
        when /\AINSTM\t(\d+)\Z/
            #return the map ID of teh passed instance ID ie ID 1002 is map 3 etc.
            client.send(sprintf('INSTM\t%03d\t%03d', instance_id, map_id)) #send back to the client the instance and map id pairing
            return true #the message was process by this extention, return true to prevent others form processing it
        end
        return false # the message was not processed by the extention, return false to allow others to process it.
    end
   
end
.to_i << capture group
            instance_id = RMXOS::InstanceMaps.INST.STRT + @inst_incr
            @inst_incr += 1
            @instance_maps[instance_id] = real_id
            return true #the message was process by this extention, return true to prevent others form processing it
        when /\AINSTM\t(\d+)\Z/
            #return the map ID of teh passed instance ID ie ID 1002 is map 3 etc.
            client.send(sprintf('INSTM\t%03d\t%03d', instance_id, map_id)) #send back to the client the instance and map id pairing
            return true #the message was process by this extention, return true to prevent others form processing it
        end
        return false # the message was not processed by the extention, return false to allow others to process it.
    end
   
end


for the client side simply do this, when the player is transferred between maps you don't need to really do anything special. the game and server will take care of making sure the player is counted as being on the right map. It's when you go to display the map, and load the right map data you need to do some work. You'll need to check the ID the game thinks the player is on. if it's higher than the max map id you know your dealing with an instance and you need to ask the server what map ID to use when loading the map. to do this you simply send a "INSTM" (instance_map) message to the server the server as you have it set up should send back a "INSTM" message with the instance ID followed by the real ID. when you receive this message you can go and tell the map to finish loading useing the real ID.
I no longer keep up with posts in the forum very well. If you have a question or comment, about my work, or in general I welcome PM's. if you make a post in one of my threads and I don't reply with in a day or two feel free to PM me and point it out to me.<br /><br />DropBox, the best free file syncing service there is.<br />

chaucer

September 30, 2014, 11:20:38 pm #15 Last Edit: September 30, 2014, 11:36:42 pm by chaucer
Ahh cool haha I was close, and ok, I attempted to do as you said, I'm not sure if I got this exactly right? hopefully it's somewhat correct? I'm still not sure on how server/client messages work exactly, but hopefully I'm not too far off.


module MAP_SETUP
 INSTANCE_MAPS = [2, 4, 10]
end
class Interpreter
 def command_201_instance command_201
   alias command_201
   command_201_instance
   if MAP::SETUP.INSTANCE_MAPS.inculde?(@parameters[1])
     @real_map = @parameter[1]
   end
 end
end

class Instance_Maps
 def initialize
   case message
   when /\AINSTN\t(\d\d\d)\Z/
     @instance_id =  sprintf('INSTM%03d')
   end
   if $game_map.map_id > 999
     self.send("INSTM",@instance_id,@real_map)
   end
 end
end



edit: forgot to put the right script :p(I think I'm way off on this actually :( ) It's a bit late though I'll sleep soon, hopefully I get some free time to mess with this in the morning, With a less foggy mind.

Ryex

... I feel like you just ignored everything I just said.

the client side should have no configuration for instance maps, it has no way to determine what maps are instances and what maps are not aside from asking the server. Or at least tt shouldn't.

moving a player to an instance map should be done with a script call not a event command, otherwise you REALLY limit yourself. so messing with the event interpreter is not the right direction.

as for.. what ever it is you're doing there with the Instance_Maps class.. I dont even...

ok, I want you to read the RMX-OS source, not the manual, the source. the script itself. you dont have to understand everything but I want you to try and identify the section of the code in which the client receives and interprets messages from the server.

copy paste the what ever piece of code you think it is here. if you can find it we'll continue.

I hope you don't think I'm being too harsh here, I feel I've over estimated how much you understood. Honestly this is probably too complicated of a project for someone at your level. That not to say you can't do it, just that it will take a lot more learning than normal before you reach your goal. I'm willing to keep teaching you for as long as you keep trying. If you keep coming back here with wrong code or go in the wrong direction thats fine. I'll keep answering questions, and directing you to the tools and information you need. We'll get there eventually.
I no longer keep up with posts in the forum very well. If you have a question or comment, about my work, or in general I welcome PM's. if you make a post in one of my threads and I don't reply with in a day or two feel free to PM me and point it out to me.<br /><br />DropBox, the best free file syncing service there is.<br />

chaucer

September 30, 2014, 11:59:07 pm #17 Last Edit: October 01, 2014, 12:04:32 am by chaucer
Sorry :( I really didn't Ignore it in fact I read it several times, I've had a long day and it's a bit difficult to for me to intake information right now, My apologies if it seemed that way I meant no disrespect, I'll try harder for focus till i crash out.

I see, so then forget interpreter class, got it! and forget client side instance maps, done. I searched through RMX-OS and I believe this is where the client is obtaining and handling data sent from server..
Spoiler: ShowHide

#checks the game for messages received from server(I think...)
def check_game(message)
      #goes through and defines what happens for each message recieved.
     case message
      #to be honest these parts confuse me
      #mostly the /\A I know that \A and \Z defines the start and end of a string, don't know if this is  similar to that.
      #I understand the \t
      #the rest pretty lost on but I'll try reading more on those later on.
     when /\ACHT\t(.{6})\t(.+)\t(.+)/ # chat message

       # color encoded in hex

       c = [$1[0, 2].hex, $1[2, 2].hex, $1[4, 2].hex]

       self.add_message(eval($2), $3, Color.new(c[0], c[1], c[2]))

       return true



haha too harsh no no, I think you're spot on in thinking that, this probably is way above my level, but you never get better if you don't challenge yourself, also awesome any help would be greatly appreciated I've pretty much self taught myself when I get some free time by ruby-doc.org and a few other sites as well as analyzing other peoples scripts, and I'm willing to come back as often as I can, not just to get this script done, but as well to learn from it.

Blizzard

Haha, that's the spirit. I used to do the same thing when I was in the beginnings of scripting. I would always pick challenges that were just outside my league. But that's also how I became so good.
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

Ryex

Same here, I kept challenging myself and while it some time took me months to pull together something as simple as a CMS I kept learning.
I no longer keep up with posts in the forum very well. If you have a question or comment, about my work, or in general I welcome PM's. if you make a post in one of my threads and I don't reply with in a day or two feel free to PM me and point it out to me.<br /><br />DropBox, the best free file syncing service there is.<br />