Chaos Project

RPG Maker => RPG Maker Scripts => RMXP Script Database => Topic started by: Wizered67 on January 22, 2011, 01:36:40 am

Title: [XP] RMX-OS Daily Messages
Post by: Wizered67 on January 22, 2011, 01:36:40 am
RMX-OS Daily Messages
Authors: Wizered67
Version: 1.00
Type: Message of the day system
Key Term: RMX-OS Plugin



Introduction

This script adds a new feature to RMX-OS that allows a message to be displayed upon logging in. It's pretty much the same thing as a "message of the day", but I called it daily messages so that it's shorter.  :haha:
All you have to do is add the script and .rb extension and make a text file called "MOTD" (can be configured) that contains the message.


Features





Screenshots
None, its just a message....


Demo

N/A


Script
Client Side (RMX-OS 2.0 Compatible): ShowHide


#------------------------------------------------------------------------------#
#                  RMX-OS Daily Messages                                       #
#                     by Wizered67                                             #
#                          V 1.00                                              #
# All errors should be reported at www.chaos-project.com.                      #
#------------------------------------------------------------------------------#
class Scene_Loading < Scene_Network
 alias load_game_motd load_game
 def load_game
   $network.send('GDM')
  load_game_motd
   end
end




.rb extension: ShowHide
#------------------------------------------------------------------------------
#                  RMX-OS Daily Messages                                            
#                     by Wizered67                                                          
#                          V 1.00                                                              
# All errors should be reported at www.chaos-project.com.                  
#------------------------------------------------------------------------------
module RMXOS
 
 def self.load_current_extension
   return MOTD
 end
 
end

#======================================================================
# module MOTD
#======================================================================

module MOTD
 
 VERSION = 1.00
 RMXOS_VERSION = 1.15
 SERVER_THREAD = false
 FILE_NAME = './MOTD.txt'
 
 
 def self.initialize
 end
 
 
 def self.main
   while RMXOS.server.running
     self.server_update
     sleep(0.1)
   end
 end
 
 def self.server_update
 end
 
 def self.client_update(client)
   case client.message
 when /\AGDM\Z/
  #set the message to empty
  message = []
   #get message from file
   file = File.open(FILE_NAME , 'r')
   #add each line to the message array.  
   file.each_line {|line| message.push(line)
   }
     #close file
     file.close
  # prepare final message
   final_message = ''
  for i in 0...message.size
  final_message = final_message  + message[i]  
    end
    client.send("CHT#{RMXOS::Data::ColorInfo}\t0\tMOTD: #{final_message}")
    return true
    end
    return false
end
 
end

RMX-OS 2.0 Extension: 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 MOTD
end

end

#======================================================================
# module MOTD
#======================================================================

module MOTD

# 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 = 'MOTD'
FILE_NAME = './MOTD.txt'

# :::: 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 /\AGDM\Z/
   #set the message to empty
   message = []
    #get message from file
    file = File.open(FILE_NAME , 'r')
    #add each line to the message array. 
    file.each_line {|line| message.push(line)
    }
      #close file
      file.close
   # prepare final message
    final_message = ''
   for i in 0...message.size
   final_message = final_message  + message[i] 
     end
     client.send("CHT\t#{RMXOS::Data::ColorInfo}\t0\tMOTD: #{final_message}")
     return true
     end
     return false
end

end



Instructions

Place the script below RMX-OS and add the extension. Create a neq text document called MOTD in the
RMX-OS server folder with the message.


Compatibility

Requires RMX-OS. No other issues none.


Credits and Thanks




Author's Notes

The only error I couldn't fix had to do with multiple lines in the message. Therefore, keep the message only one line long until I get this fixed. Feel free to report errors. I know it's a small script, but enjoy.
Title: Re: RMX-OS Daily Messages
Post by: Ryex on January 22, 2011, 02:04:48 am
very good, and thank you for taking notice of the new key term and using it.
Title: Re: [XP] RMX-OS Daily Messages
Post by: Wizered67 on June 14, 2013, 06:20:56 pm
Updated for RMX-OS 2.0 :) Let me know if you have any problems with it.
Title: Re: [XP] RMX-OS Daily Messages
Post by: Sylphe on June 08, 2014, 08:09:10 am
Big Problem with this script, It comes from the extension in the server

it says

src/Client1.rb:234:in 'block in handle'
IDEM :233:in 'each_value'
IDEM 'handle'
Title: Re: [XP] RMX-OS Daily Messages
Post by: Blizzard on June 08, 2014, 08:43:22 am
The script needs to be updated for RMX-OS 2.0.