RMX-OS extension help(resolved)

Started by nathmatt, October 06, 2010, 06:01:16 pm

Previous topic - Next topic

nathmatt

October 06, 2010, 06:01:16 pm Last Edit: October 07, 2010, 01:35:22 pm by nathmatt
ok im making an extension that when activated will send a message every sec to all players telling them the server will be shutting down but it never runs the msg heres my extension.rb and yes i added it to the config

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 Server_Calls
   end
 
end

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

module Server_Calls
   
   # extension version
   VERSION = 1.0
   # required RMX-OS version
   RMXOS_VERSION = 1.11
   # whether the server should update this extension in an idividual thread or not
   SERVER_THREAD = true
   
   #------------------------------------------------------------------
   # Initializes the extension (i.e. instantiation of classes).
   #------------------------------------------------------------------
   def self.initialize
   @countdown = false
   @timer = 30
   @frames = 0
   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
   if @countdown
     @frames += 1
   end
       if @frames == 40
     @frames = 0
     message = 'The server will be shutting down in ' + @timer
     puts message
     @client.sender.send_to_all("CHT#{RMXOS::Data::ColorInfo}\t0\t#{message}")
     @timer -= 1
     if @timer == 0
       @timer = 30
       @countdown = false
       RMXOS.server.shutdown
       RMXOS.server.force_shutdown
     end
   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 /\SDT(.+)/
     if client.player.usergroup == RMXOS::GROUP_ADMIN
       @countdown = true
       @type = $1.to_i
       @client = client
     else
       message = 'Sorry only Admins can shut down the server'
       client.send("CHT#{RMXOS::Data::ColorInfo}\t0\t#{message}")
     end
     return true
   end
       return false
   end
   
end
Join Dead Frontier
Sorry, I will no longer be scripting for RMXP. I may or may not give support for my scripts. I don't have the will to script in RGSS anymore.
My script


Blizzard

*scratches head* Why don't you just send a global message as moderator/admin?
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.

nathmatt

October 07, 2010, 08:03:22 am #2 Last Edit: October 07, 2010, 01:35:04 pm by nathmatt
i would but i want it to send it every second so that it can keep warning ppl be4 it shuts down

edit wow i was doing it the hard way looked at the auto restart timer and did it the same way also i think the problem was the send_to_all i didn't realize there was a send to me condition btw is there a way to have the server send a msg the way it is now if i log out before the timer finished it causes a error which is fine just wondering if i could do it through the server
Join Dead Frontier
Sorry, I will no longer be scripting for RMXP. I may or may not give support for my scripts. I don't have the will to script in RGSS anymore.
My script