[XP] RMX-OS Reporting

Started by Wizered67, February 16, 2011, 11:22:43 am

Previous topic - Next topic

Wizered67

February 16, 2011, 11:22:43 am Last Edit: June 14, 2013, 06:56:43 pm by Wizered67
RMX-OS Reporting
Authors: Wizered67
Version: 1.01
Type: Reporting System
Key Term: RMX-OS Plugin



Introduction

Have you ever played a game where you see another player cheating? Normally in RMX-OS, a player can do nothing about players that are breaking rules. What this script adds is a "/report" command. The command has the parameters Player and Reason. The player's name does not have to be exact and they do not have to be logged on. Basically, the player and reason are sent to the server and kept in a log. That way admins can check the log and see if there is anyone they need to ban.


Features


  • Allows players to report other players that break rules.

  • Name does not need to be exact.

  • Server formats reports for you.

  • Can easily be used to report bugs in the game itself also.

  • Now features MySQL support




Screenshots

None but the log looks like this:
2011-02-15 18:29:04 UTC: Player 'Wizered67' was reported by 'beta46'. Reason: 'He was walking through walls' .


Demo

Sorry, no demo.


Script

Client Side: ShowHide

#------------------------------------------------------------------------------
#                  RMX-OS Reporting Players
#                     by Wizered67
#                          V 1.00
# All errors should be reported at www.chaos-project.com.
#------------------------------------------------------------------------------
module RMXOS
 module Documentation
 PARAMETERS['report']    = 'PLAYER REASON'  
 DESCRIPTIONS['report']    = 'Allows you to report a player that is breaking a rule.'
 end
 class Network
 def command_report(player, reason)
 $network.send("RPL#{player}\t#{reason}")
 end
 alias check_normal_commands_report_add check_normal_commands
 def check_normal_commands(message)
   case message
   when /\A\/report (\S+) (\S{1}.*)\Z/
    command_report($1, $2)
     return true
   end
   return check_normal_commands_report_add(message)
 end
end
end

Client Side for RMX-OS 2.0: ShowHide
#------------------------------------------------------------------------------
#                  RMX-OS Reporting Players
#                     by Wizered67
#                          V 1.00
# All errors should be reported at www.chaos-project.com.
#------------------------------------------------------------------------------
module RMXOS
  module Documentation
  PARAMETERS['report']    = 'PLAYER REASON' 
  DESCRIPTIONS['report']    = 'Allows you to report a player that is breaking a rule.'
  end
  class Network
  def command_report(player, reason)
  $network.send("RPL\t#{player}\t#{reason}")
  end
  alias check_normal_commands_report_add check_normal_commands
  def check_normal_commands(message)
    case message
    when /\A\/report (\S+) (\S{1}.*)\Z/
     command_report($1, $2)
      return true
    end
    return check_normal_commands_report_add(message)
  end
end
end


.rb add-on: ShowHide
#------------------------------------------------------------------------------
#                  RMX-OS Reporting Players
#                     by Wizered67
#                          V 1.00
# All errors should be reported at www.chaos-project.com.
#------------------------------------------------------------------------------
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 ReportPlayers
end

 module Data
 REPORT_TEXT = 'TIME: Player \'PLAYER\' was reported by \'REPORTER\'. Reason: \'REASON\'.'
 end
end

#======================================================================
# module ReportPlayers
#======================================================================

module ReportPlayers

# extension version
VERSION = 1.0
# required RMX-OS version
RMXOS_VERSION = 1.18
# whether the server should update this extension in an idividual thread or not
SERVER_THREAD = true

# :::: START Configuration
REPORT_LOG = './Extensions/reports.log'
# :::: END Configuration

#------------------------------------------------------------------
# Initializes the extension
#------------------------------------------------------------------
def self.initialize
end
#------------------------------------------------------------------
# Calls constant updating on the server.
#------------------------------------------------------------------
def self.main
# while server is running
while RMXOS.server.running
self.server_update
sleep(0.1)
end
end
#------------------------------------------------------------------
# Handles the server update.
#------------------------------------------------------------------
def self.server_update
 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 /\ARPL(.+)\t(.+)/
 player_reported = $1
 reason = $2
 reporter = client.player.username
 time = Time.now.getutc.to_s
message = RMXOS::Data::REPORT_TEXT.sub('TIME', time).sub('PLAYER', player_reported).sub('REASON', reason).sub('REPORTER', reporter)
 message = message + "\n"
 client.send("CHT#{RMXOS::Data::ColorInfo}\t0\tPlayer was reported.")
 self.log_report(message)
 return true
end
   return false

end
 
 
 def self.log_report(message)
   file = File.open(REPORT_LOG,'a')
   file.write(message)
   file.close
   end
end


.rb extension RMX-OS 2.0: 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 ReportPlayers
    end
   
    module Data
  REPORT_TEXT = 'TIME: Player \'PLAYER\' was reported by \'REPORTER\'. Reason: \'REASON\'.'
  end
   
end

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

module ReportPlayers
   
    # 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 = 'Report Players'
    REPORT_LOG = './Extensions/reports.log'
   
    # :::: 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 /\ARPL(.+)\t(.+)/
    player_reported = $1
    reason = $2
    reporter = client.player.username
    time = Time.now.getutc.to_s
    message = RMXOS::Data::REPORT_TEXT.sub('TIME', time).sub('PLAYER', player_reported).sub('REASON', reason).sub('REPORTER', reporter)
    message = message + "\n"
    client.send("CHT\t#{RMXOS::Data::ColorInfo}\t0\t Player was reported.")
    self.log_report(message)
    return true
        end
    return false
    end
   
    def self.log_report(message)
    file = File.open(REPORT_LOG,'a')
    file.write(message)
    file.close
    end
   
end


MySQL Code: ShowHide
CREATE TABLE IF NOT EXISTS `reports` (
 `id` int(11) NOT NULL AUTO_INCREMENT,
 `Time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'Zeit',
 `Reported_Player` varchar(50) COLLATE utf8_unicode_ci NOT NULL COMMENT 'Spieler der Gemeldet wird',
 `Reporter` varchar(50) COLLATE utf8_unicode_ci NOT NULL COMMENT 'Spieler der Gemeldet hat',
 `Reason` varchar(255) COLLATE utf8_unicode_ci NOT NULL COMMENT 'Grund',
 PRIMARY KEY (`id`),
 UNIQUE KEY `id` (`id`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ;

.rb for MySQL version: ShowHide
#------------------------------------------------------------------------------
#                  RMX-OS Reporting Players
#                     by Wizered67
#                  Modified by Midakox3
#                          V 1.01?
# All errors should be reported at www.chaos-project.com.
#------------------------------------------------------------------------------
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 ReportPlayers
   end

end

#======================================================================
# module ReportPlayers
#======================================================================

module ReportPlayers
   
   # extension version
   VERSION = 1.01
   # required RMX-OS version
   RMXOS_VERSION = 1.18
   # whether the server should update this extension in an idividual thread or not
   SERVER_THREAD = true
   
   #------------------------------------------------------------------
   # Initializes the extension
   #------------------------------------------------------------------
   def self.initialize
   end
   #------------------------------------------------------------------
   # Calls constant updating on the server.
   #------------------------------------------------------------------
   def self.main
       # while server is running
       while RMXOS.server.running
           self.server_update
           sleep(0.1)
       end
   end
   #------------------------------------------------------------------
   # Handles the server update.
   #------------------------------------------------------------------
   def self.server_update
 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 /\ARPL(.+)\t(.+)/
 player_reported = $1
 reason = $2
 reporter = client.player.username
 time = Time.now.getutc.to_s
 con = Mysql.new 'host', 'dbuser', 'dbpassword', 'rmxosdb'
 con.query("INSERT INTO reports(Time, Reported_Player, Reporter, Reason) VALUES ('" + time + "', '" + player_reported + "','" + reporter + "', '" + reason + "')")
 client.send("CHT#{RMXOS::Data::ColorInfo}\t0\tPlayer was reported.")
 return true
       end
   return false
   
   end
 
 

end

.rb for MySQL version RMX-OS 2.0 (untested): ShowHide
#------------------------------------------------------------------------------
#                  RMX-OS Reporting Players
#                     by Wizered67
#                  Modified by Midakox3
#                          V 1.01?
# All errors should be reported at www.chaos-project.com.
#------------------------------------------------------------------------------
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 ReportPlayers
   end

end

#======================================================================
# module ReportPlayers
#======================================================================

module ReportPlayers
   
   # extension version
   VERSION = 1.01
   # required RMX-OS version
   RMXOS_VERSION = 1.18
   # whether the server should update this extension in an idividual thread or not
   SERVER_THREAD = true
   
   #------------------------------------------------------------------
   # Initializes the extension
   #------------------------------------------------------------------
   def self.initialize
   end
   #------------------------------------------------------------------
   # Calls constant updating on the server.
   #------------------------------------------------------------------
   def self.main
       # while server is running
       while RMXOS.server.running
           self.server_update
           sleep(0.1)
       end
   end
   #------------------------------------------------------------------
   # Handles the server update.
   #------------------------------------------------------------------
   def self.server_update
 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 /\ARPL(.+)\t(.+)/
 player_reported = $1
 reason = $2
 reporter = client.player.username
 time = Time.now.getutc.to_s
 con = Mysql.new 'host', 'dbuser', 'dbpassword', 'rmxosdb'
 con.query("INSERT INTO reports(Time, Reported_Player, Reporter, Reason) VALUES ('" + time + "', '" + player_reported + "','" + reporter + "', '" + reason + "')")
 client.send("CHT\t#{RMXOS::Data::ColorInfo}\t0\tPlayer was reported.")
 return true
       end
   return false
   
   end
 
 

end



Instructions

Just put the script in and it should work. Note that if the reason is more than one word, you must separate the words with dashes or something else.
Now includes a MySQL version courtesy of Midakox3. To use the MySQL version, use the .rb file labeled "MySQL" and use the MySQL code on the database. If you are using RMX-OS 2.0, only use the scripts labeled as the 2.0 version.


Compatibility

Requires RMX-OS.


Credits and Thanks


  • Me

  • Blizzard for making RMX-OS and since I borrowed a lot from his User Logger script.

  • Midakox3 for his modification for MySQL




Author's Notes

Enjoy and report any bugs here. Remember to use the extension!

Griver03

My most wanted games...



Ryex

February 16, 2011, 04:41:08 pm #2 Last Edit: February 16, 2011, 06:13:21 pm by Ryex
combined with the RMXOS-GUI which allows you to search your user base and ban people this is a great tool
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 />

Midako

Quote from: Wizered67 on February 16, 2011, 11:22:43 am
RMX-OS Reporting with MySql
Authors: Wizered67
Modified by: Midakox3
Version: 1.01?
Type: Reporting System with MySQL
Key Term: RMX-OS Plugin



Introduction

see First Author


Features


  • Allows players to report other players that break rules.

  • Name does not need to be exact.

  • Server formats reports for you.

  • Can easily be used to report bugs in the game itself also.




Screenshots




Demo

Sorry, no demo.


Script

mysql code: ShowHide

CREATE TABLE IF NOT EXISTS `reports` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `Time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'Zeit',
  `Reported_Player` varchar(50) COLLATE utf8_unicode_ci NOT NULL COMMENT 'Spieler der Gemeldet wird',
  `Reporter` varchar(50) COLLATE utf8_unicode_ci NOT NULL COMMENT 'Spieler der Gemeldet hat',
  `Reason` varchar(255) COLLATE utf8_unicode_ci NOT NULL COMMENT 'Grund',
  PRIMARY KEY (`id`),
  UNIQUE KEY `id` (`id`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ;


.rb add-on: ShowHide
#------------------------------------------------------------------------------
#                  RMX-OS Reporting Players
#                     by Wizered67
#                  Modified by Midakox3
#                          V 1.01?
# All errors should be reported at www.chaos-project.com.
#------------------------------------------------------------------------------
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 ReportPlayers
    end

end

#======================================================================
# module ReportPlayers
#======================================================================

module ReportPlayers
   
    # extension version
    VERSION = 1.01
    # required RMX-OS version
    RMXOS_VERSION = 1.18
    # whether the server should update this extension in an idividual thread or not
    SERVER_THREAD = true
   
    #------------------------------------------------------------------
    # Initializes the extension
    #------------------------------------------------------------------
    def self.initialize
    end
    #------------------------------------------------------------------
    # Calls constant updating on the server.
    #------------------------------------------------------------------
    def self.main
        # while server is running
        while RMXOS.server.running
            self.server_update
            sleep(0.1)
        end
    end
    #------------------------------------------------------------------
    # Handles the server update.
    #------------------------------------------------------------------
    def self.server_update
  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 /\ARPL(.+)\t(.+)/
  player_reported = $1
  reason = $2
  reporter = client.player.username
  time = Time.now.getutc.to_s
  con = Mysql.new 'host', 'dbuser', 'dbpassword', 'rmxosdb'
  con.query("INSERT INTO reports(Time, Reported_Player, Reporter, Reason) VALUES ('" + time + "', '" + player_reported + "','" + reporter + "', '" + reason + "')")
  client.send("CHT#{RMXOS::Data::ColorInfo}\t0\tPlayer was reported.")
  return true
        end
    return false
   
    end
 
 

end



Instructions

Its MySql Based now


Compatibility

Requires RMX-OS.



Credits and Thanks


  • Wizered67

  • Blizzard for making RMX-OS and since Wizered67 borrowed a lot from his User Logger script.

  • Midakox3 for Modifing




Author's Notes
If you ask why MySQL its because i work on a Website for RMX-OS Script maybe there will be someday one Public with some Function ^-^
Enjoy and report any bugs here. Remember to use the extension!

Wizered67

I've added Midako's edit to the opening post, which will allow the reports to be saved in a MySQL database. I haven't actually tested it, but I'm sure it works as intended. I've also gone ahead and updated the main script to allow for the reason to be multiple words long. Let me know if there are any issues with that.

Wizered67

Updated for RMX-OS 2.0, let me know if there are any issues.