Chaos Project

RPG Maker => RPG Maker Scripts => Script Requests => Topic started by: edwardthefma on May 19, 2010, 11:03:12 pm

Title: simple server status script
Post by: edwardthefma on May 19, 2010, 11:03:12 pm
i need a simple server status script that will wright online to a log and wen  the server is started and offline wen it is closed
out
Title: Re: simple server status script
Post by: nathmatt on May 20, 2010, 08:04:34 am
 i made an extension but the only way it will work right is if you always use ctrl + c to shut down the server if you just close it it wont run the offline code

you load this the same way as all other extensions

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

end

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

module Server_States

# 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

# :::: START Configuration
# - YOUR CONFIGURATION HERE
# :::: END Configuration

#------------------------------------------------------------------
# Initializes the extension (i.e. instantiation of classes).
#------------------------------------------------------------------
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) # 0.1 seconds pause, decreases server load
end
    file = File.open('server_status.txt', 'wb')
    file.write("Offline\r\n")
    file.close
end
#------------------------------------------------------------------
# Handles the server update.
#------------------------------------------------------------------
def self.server_update
file = File.open('server_status.txt', 'wb')
    file.write("Online\r\n")
    file.close
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)
# - YOUR CLIENT MESSAGE CODE HERE
return false
end

end

Title: Re: simple server status script
Post by: G_G on May 20, 2010, 08:10:35 am
I'm gonna test a few things with PHP and RMX-OS. I think I might be able to pull it off.
Title: Re: simple server status script
Post by: edwardthefma on May 20, 2010, 09:23:25 am
sounds cool XD btw i got my game reg working thru a web sight