def onWorldSave(): if ENABLEDFANCYSTATUS: # Creating Dialog dialog = cGump(nomove=1, nodispose=1, x=150, y=150) dialog.setType( 0x98FA2C10 ) # NEVER change this Type or Gump will not be closed in the end of save dialog.addResizeGump(0, 0, 9200, 291, 90) dialog.addCheckerTrans(0, 0, 291, 90) dialog.addText(47, 19, tr("WORLDSAVE IN PROGRESS"), 2122) dialog.addText(47, 37, tr("Saving %i items.") % (wolfpack.itemcount()), 2100) dialog.addText(47, 55, tr("Saving %i characters.") % (wolfpack.charcount()), 2100) dialog.addTilePic(3, 25, 4167) # Sending to players worldsocket = wolfpack.sockets.first() while worldsocket: dialog.send(worldsocket) worldsocket = wolfpack.sockets.next()
def handleStatus(socket, packet): statusPacket = 1 for i in range(0, packet.size): if packet.getbyte(i) != statusRequest[i]: statusPacket = 0 break if statusPacket: status = 'olfpack, Clients=%i, Items=%i, Chars=%i, Version="%s"' % ( wolfpack.sockets.count(), wolfpack.itemcount(), wolfpack.charcount(), wolfpack.serverversion()) packet = wolfpack.packet(87, len(status) + 2) packet.setascii(1, status) packet.send(socket) socket.log(LOG_MESSAGE, "Sent status information.\n") return statusPacket
def onWorldSave(): if ENABLEDFANCYSTATUS: # Creating Dialog dialog = cGump( nomove=1, nodispose=1, x=150, y=150 ) dialog.setType( 0x98FA2C10 ) # NEVER change this Type or Gump will not be closed in the end of save dialog.addResizeGump( 0, 0, 9200, 291, 90 ) dialog.addCheckerTrans( 0, 0, 291, 90 ) dialog.addText( 47, 19, tr( "WORLDSAVE IN PROGRESS" ), 2122 ) dialog.addText( 47, 37, tr( "Saving %i items." )%( wolfpack.itemcount() ), 2100 ) dialog.addText( 47, 55, tr( "Saving %i characters." )%( wolfpack.charcount() ), 2100 ) dialog.addTilePic( 3, 25, 4167 ) # Sending to players worldsocket = wolfpack.sockets.first() while worldsocket: dialog.send( worldsocket ) worldsocket = wolfpack.sockets.next()
def handleStatus(socket, packet): statusPacket = 1 for i in range(0, packet.size): if packet.getbyte(i) != statusRequest[i]: statusPacket = 0 break if statusPacket: status = 'olfpack, Clients=%i, Items=%i, Chars=%i, Version="%s"' % (wolfpack.sockets.count(), wolfpack.itemcount(), wolfpack.charcount(), wolfpack.serverversion()) packet = wolfpack.packet(87, len(status) + 2) packet.setascii(1, status) packet.send(socket) socket.log(LOG_MESSAGE, "Sent status information.\n") return statusPacket
def serverinfo(socket, command, arguments): global initialized if not initialized: initializeValues() char = socket.player version = wolfpack.serverversion() uptime = wolfpack.time.currenttime() / 1000 upseconds = uptime upminutes = (uptime / 60) upseconds -= (upminutes * 60) if upseconds <= 9: upseconds = '0%s' % (upseconds) uphours = (upminutes / 60) upminutes -= (uphours * 60) if upminutes <= 9: upminutes = '0%s' % (upminutes) if uphours <= 9: uphours = '0%s' % (uphours) timestring = '%s:%s:%s' % (uphours, upminutes, upseconds) onlinecount = wolfpack.sockets.count() accountcount = 0 admincount = 0 gmcount = 0 seercount = 0 counselorcount = 0 playercount = 0 acclist = wolfpack.accounts.list for i in acclist(): record = wolfpack.accounts.find(i) accountcount += 1 if record.acl == 'admin': admincount += 1 if record.acl == 'gm': gmcount += 1 if record.acl == 'seer': seercount += 1 if record.acl == 'counselor': counselorcount += 1 if record.acl == 'player': playercount += 1 gump = cGump(x=30, y=30) gump.addBackground(id=0x2436, width=280, height=400) # Basic Info text = '<basefont color="#FFFF00"><center><h3>%s Shard Status</h3></center><br />' % ( shardname) text += '<basefont color="#FEFEFE">' text += ' Version: %s<br />' % (version) text += ' Uptime: %s<br />' % (timestring) # Account Info text += '<basefont color="#FFFF00"><center><h3>Account Information</h3></center><br />' text += '<basefont color="#FEFEFE">' text += ' Online Accounts: <basefont color="#00FFFF">%i <basefont color="#FEFEFE">/ <basefont color="#00FFFF">%i<br />' % ( onlinecount, accountcount) text += '<basefont color="#FEFEFE">' text += ' Total Admins: <basefont color="#00FF00">%i<br />' % ( admincount) text += '<basefont color="#FEFEFE">' text += ' Total Seers: <basefont color="#00FF00">%i<br />' % ( seercount) text += '<basefont color="#FEFEFE">' text += ' Total Counselors: <basefont color="#00FF00">%i<br />' % ( counselorcount) text += '<basefont color="#FEFEFE">' text += ' Total Players: <basefont color="#00FF00">%i<br />' % ( playercount) text += '<basefont color="#FEFEFE">' text += ' Total Characters: <basefont color="#00FF00">%i<br />' % ( wolfpack.charcount()) text += '<basefont color="#FEFEFE">' text += ' Total Items: <basefont color="#00FF00">%i<br />' % ( wolfpack.itemcount()) # Hardware Info text += '<basefont color="#FFFF00"><center><h3>Server Information</h3></center><br />' text += '<basefont color="#FEFEFE">' text += ' OS: %s<br />' % (operatingsystem) text += ' Processor: %s<br />' % (processor) text += ' Memory: %s<br />' % (memory) gump.addHtmlGump(x=20, y=20, width=240, height=360, html=text) gump.send(char) return
def WritePage(status='Online'): global processthread console.log(LOG_MESSAGE, "Generating Shard Status Page.\n") # Default/Static Information if status != 'Online' and status != 'Offline': status = "Unknown" #Prepare Information uptime = wolfpack.time.currenttime() / 1000 # Build an uptime: upseconds = 0 upminutes = 0 uphours = 0 updays = 0 upseconds = uptime upminutes = uptime / 60 upseconds -= upminutes * 60 if upseconds <= 9: upseconds = '0%s' % upseconds uphours = upminutes / 60 upminutes -= uphours * 60 if upminutes <= 9: upminutes = '0%s' % upminutes if uphours <= 9: uphours = '0%s' % uphours #Make a time string timestring = '%s:%s:%s' % (uphours, upminutes, upseconds) # Account Counting accountcount = 0 admincount = 0 gmcount = 0 seercount = 0 counselorcount = 0 playercount = 0 players = "" # ACC List for i in accounts.list(): record = accounts.find(i) if record.acl == 'admin': admincount += 1 elif record.acl == 'gm': gmcount += 1 elif record.acl == 'seer': seercount += 1 elif record.acl == 'counselor': counselorcount += 1 elif record.acl == 'player': playercount += 1 #Write the page file = open(output_file, 'w') outputtext = "<div class='box' style='min-width:480px;width:90%;'>\n" outputtext += "<table class='contentinfo' style='width:100%;' cellpadding='0' cellspacing='0'>\n" outputtext += "<caption>Rayonnant Server Status [ <?=$phase?> ]</caption>\n" outputtext += "<tr><td style='width:90px;text-align:right;'>" outputtext += "<span style='font-weight:bold;'>Server Address:</span> </td>" outputtext += "<td> <span class='server_good'>%s</span></td></tr>\n" % ( address) outputtext += "<tr><td style='width:90px;text-align:right;'>" outputtext += "<span style='font-weight:bold;'>Server Status:</span> </td>" if status == 'Online': outputtext += "<td> <span class='server_good'>%s</span></td></tr>\n" % ( status) outputtext += "<tr><td style='width:90px;text-align:right;'>" outputtext += "<span style='font-weight:bold;'>Server Uptime:</span> </td>" outputtext += "<td> <span class='server_good'>%s</span></td></tr>\n" % ( timestring) elif status == 'Offline': outputtext += "<td> <span class='server_bad'>%s</span></td></tr>\n" % ( status) outputtext += "<tr><td style='width:90px;text-align:right;'>" outputtext += "<span style='font-weight:bold;'>Previous Uptime:</span> </td>" outputtext += "<td> <span class='server_bad'>%s</span></td></tr>\n" % ( timestring) else: outputtext += "<td> <span class='server_neutral'>%s</span></td></tr>\n" % ( status) outputtext += "<tr><td style='width:90px;text-align:right;'>" outputtext += "<span style='font-weight:bold;'>Server Uptime:</span> </td>" outputtext += "<td> <span class='server_neutral'>%s</span></td></tr>\n" % ( timestring) outputtext += "<tr><td style='width:90px;'>" outputtext += "<span style='font-weight:bold;'>Server Version:</span> </td>" outputtext += "<td> <span class='server_good'>%s</span></td></tr>\n" % ( wolfpack.serverversion()) if status == 'Online': outputtext += "<tr><td style='width:90px;text-align:right;'>" outputtext += "<span style='font-weight:bold;'>Accounts:</span> </td><td></td></tr>\n" outputtext += "<tr><td style='width:90px;text-align:right;'>" outputtext += "<span class='server_neutral'>%s</span> / <span class='server_good'>%s</span></td>" % ( wolfpack.sockets.count(), wolfpack.accounts.count()) outputtext += "<td style='text-indent:1em;'> Online / Total Accounts</td></tr>\n" outputtext += "<tr><td style='width:90px;text-align:right;'>" outputtext += "<span class='server_neutral'>%s</span> </td>" % ( admincount) outputtext += "<td style='text-indent:1em;'> Admin Accounts</td></tr>\n" outputtext += "<tr><td style='width:90px;text-align:right;'>" outputtext += "<span class='server_neutral'>%s</span> </td>" % ( gmcount) outputtext += "<td style='text-indent:1em;'> GM Accounts</td></tr>\n" outputtext += "<tr><td style='width:90px;text-align:right;'>" outputtext += "<span class='server_neutral'>%s</span> </td>" % ( seercount) outputtext += "<td style='text-indent:1em;'> Seer Accounts</td></tr>\n" outputtext += "<tr><td style='width:90px;text-align:right;'>" outputtext += "<span class='server_neutral'>%s</span> </td>" % ( counselorcount) outputtext += "<td style='text-indent:1em;'> Counselor Accounts</td></tr>\n" outputtext += "<tr><td style='width:90px;text-align:right;'>" outputtext += "<span class='server_neutral'>%s</span> </td>" % ( playercount) outputtext += "<td style='text-indent:1em;'> Player Accounts</td></tr>\n" # Statistics Item/Char Totals outputtext += "<tr><td style='width:90px;text-align:right;'>" outputtext += "<span style='font-weight:bold;'>Statistics:</span> </td><td></td></tr>\n" outputtext += "<tr><td style='width:90px;text-align:right;'>" outputtext += "<span class='server_neutral'>%s</span> </td>" % ( wolfpack.playercount()) outputtext += "<td style='text-indent:1em;'> Total Players</td></tr>\n" outputtext += "<tr><td style='width:90px;text-align:right;'>" outputtext += "<span class='server_neutral'>%s</span> </td>" % ( wolfpack.itemcount()) outputtext += "<td style='text-indent:1em;'> Total Items</td></tr>\n" outputtext += "<tr><td style='width:90px;text-align:right;'>" outputtext += "<span class='server_neutral'>%s</span> </td>" % ( wolfpack.npccount()) outputtext += "<td style='text-indent:1em;'> Total NPCs</td></tr>\n" outputtext += "</table>\n" outputtext += "</div>\n" file.write(outputtext) file.close() wolfpack.addtimer(1000, autostatuswrapper) processthread.mutex.acquire() processthread.processed = True processthread.mutex.release() return True
def serverinfo( socket, command, arguments ): global initialized if not initialized: initializeValues() char = socket.player version = wolfpack.serverversion() uptime = wolfpack.time.currenttime() / 1000 upseconds = uptime upminutes = ( uptime / 60 ) upseconds -= ( upminutes * 60 ) if upseconds <= 9: upseconds = '0%s' % ( upseconds ) uphours = ( upminutes / 60 ) upminutes -= ( uphours * 60 ) if upminutes <= 9: upminutes = '0%s' % ( upminutes ) if uphours <= 9: uphours = '0%s' % ( uphours ) timestring = '%s:%s:%s' % ( uphours, upminutes, upseconds ) onlinecount = wolfpack.sockets.count() accountcount = 0 admincount = 0 gmcount = 0 seercount = 0 counselorcount = 0 playercount = 0 acclist = wolfpack.accounts.list for i in acclist(): record = wolfpack.accounts.find( i ) accountcount += 1 if record.acl == 'admin': admincount += 1 if record.acl == 'gm': gmcount += 1 if record.acl == 'seer': seercount += 1 if record.acl == 'counselor': counselorcount += 1 if record.acl == 'player': playercount += 1 gump = cGump( x=30, y=30) gump.addBackground( id=0x2436, width=280, height=400 ) # Basic Info text = '<basefont color="#FFFF00"><center><h3>%s Shard Status</h3></center><br />' % ( shardname ) text += '<basefont color="#FEFEFE">' text += ' Version: %s<br />' % ( version ) text += ' Uptime: %s<br />' % ( timestring ) # Account Info text += '<basefont color="#FFFF00"><center><h3>Account Information</h3></center><br />' text += '<basefont color="#FEFEFE">' text += ' Online Accounts: <basefont color="#00FFFF">%i <basefont color="#FEFEFE">/ <basefont color="#00FFFF">%i<br />' % ( onlinecount, accountcount ) text += '<basefont color="#FEFEFE">' text += ' Total Admins: <basefont color="#00FF00">%i<br />' % ( admincount ) text += '<basefont color="#FEFEFE">' text += ' Total Seers: <basefont color="#00FF00">%i<br />' % ( seercount ) text += '<basefont color="#FEFEFE">' text += ' Total Counselors: <basefont color="#00FF00">%i<br />' % ( counselorcount ) text += '<basefont color="#FEFEFE">' text += ' Total Players: <basefont color="#00FF00">%i<br />' % ( playercount ) text += '<basefont color="#FEFEFE">' text += ' Total Characters: <basefont color="#00FF00">%i<br />' % ( wolfpack.charcount() ) text += '<basefont color="#FEFEFE">' text += ' Total Items: <basefont color="#00FF00">%i<br />' % ( wolfpack.itemcount() ) # Hardware Info text += '<basefont color="#FFFF00"><center><h3>Server Information</h3></center><br />' text += '<basefont color="#FEFEFE">' text += ' OS: %s<br />' % ( operatingsystem ) text += ' Processor: %s<br />' % ( processor ) text += ' Memory: %s<br />' % ( memory ) gump.addHtmlGump( x=20, y=20, width=240, height=360, html=text ) gump.send( char ) return
def WritePage( status='Online' ): global processthread console.log(LOG_MESSAGE, "Generating Shard Status Page.\n") # Default/Static Information if status != 'Online' and status != 'Offline': status = "Unknown" #Prepare Information uptime = wolfpack.time.currenttime() / 1000 # Build an uptime: upseconds = 0 upminutes = 0 uphours = 0 updays = 0 upseconds = uptime upminutes = uptime / 60 upseconds -= upminutes * 60 if upseconds <= 9: upseconds = '0%s' % upseconds uphours = upminutes / 60 upminutes -= uphours * 60 if upminutes <= 9: upminutes = '0%s' % upminutes if uphours <= 9: uphours = '0%s' % uphours #Make a time string timestring = '%s:%s:%s' % ( uphours, upminutes, upseconds ) # Account Counting accountcount = 0 admincount = 0 gmcount = 0 seercount = 0 counselorcount = 0 playercount = 0 players = "" # ACC List for i in accounts.list(): record = accounts.find( i ) if record.acl == 'admin': admincount += 1 elif record.acl == 'gm': gmcount += 1 elif record.acl == 'seer': seercount += 1 elif record.acl == 'counselor': counselorcount += 1 elif record.acl == 'player': playercount += 1 #Write the page file = open( output_file, 'w' ) outputtext = "<div class='box' style='min-width:480px;width:90%;'>\n" outputtext += "<table class='contentinfo' style='width:100%;' cellpadding='0' cellspacing='0'>\n" outputtext += "<caption>Rayonnant Server Status [ <?=$phase?> ]</caption>\n" outputtext += "<tr><td style='width:90px;text-align:right;'>" outputtext += "<span style='font-weight:bold;'>Server Address:</span> </td>" outputtext += "<td> <span class='server_good'>%s</span></td></tr>\n" % ( address ) outputtext += "<tr><td style='width:90px;text-align:right;'>" outputtext += "<span style='font-weight:bold;'>Server Status:</span> </td>" if status == 'Online': outputtext += "<td> <span class='server_good'>%s</span></td></tr>\n" % ( status ) outputtext += "<tr><td style='width:90px;text-align:right;'>" outputtext += "<span style='font-weight:bold;'>Server Uptime:</span> </td>" outputtext += "<td> <span class='server_good'>%s</span></td></tr>\n" % ( timestring ) elif status == 'Offline': outputtext += "<td> <span class='server_bad'>%s</span></td></tr>\n" % ( status ) outputtext += "<tr><td style='width:90px;text-align:right;'>" outputtext += "<span style='font-weight:bold;'>Previous Uptime:</span> </td>" outputtext += "<td> <span class='server_bad'>%s</span></td></tr>\n" % ( timestring ) else: outputtext += "<td> <span class='server_neutral'>%s</span></td></tr>\n" % ( status ) outputtext += "<tr><td style='width:90px;text-align:right;'>" outputtext += "<span style='font-weight:bold;'>Server Uptime:</span> </td>" outputtext += "<td> <span class='server_neutral'>%s</span></td></tr>\n" % ( timestring ) outputtext += "<tr><td style='width:90px;'>" outputtext += "<span style='font-weight:bold;'>Server Version:</span> </td>" outputtext += "<td> <span class='server_good'>%s</span></td></tr>\n" % ( wolfpack.serverversion() ) if status == 'Online': outputtext += "<tr><td style='width:90px;text-align:right;'>" outputtext += "<span style='font-weight:bold;'>Accounts:</span> </td><td></td></tr>\n" outputtext += "<tr><td style='width:90px;text-align:right;'>" outputtext += "<span class='server_neutral'>%s</span> / <span class='server_good'>%s</span></td>" % ( wolfpack.sockets.count(), wolfpack.accounts.count() ) outputtext += "<td style='text-indent:1em;'> Online / Total Accounts</td></tr>\n" outputtext += "<tr><td style='width:90px;text-align:right;'>" outputtext += "<span class='server_neutral'>%s</span> </td>" % ( admincount ) outputtext += "<td style='text-indent:1em;'> Admin Accounts</td></tr>\n" outputtext += "<tr><td style='width:90px;text-align:right;'>" outputtext += "<span class='server_neutral'>%s</span> </td>" % ( gmcount ) outputtext += "<td style='text-indent:1em;'> GM Accounts</td></tr>\n" outputtext += "<tr><td style='width:90px;text-align:right;'>" outputtext += "<span class='server_neutral'>%s</span> </td>" % ( seercount ) outputtext += "<td style='text-indent:1em;'> Seer Accounts</td></tr>\n" outputtext += "<tr><td style='width:90px;text-align:right;'>" outputtext += "<span class='server_neutral'>%s</span> </td>" % ( counselorcount ) outputtext += "<td style='text-indent:1em;'> Counselor Accounts</td></tr>\n" outputtext += "<tr><td style='width:90px;text-align:right;'>" outputtext += "<span class='server_neutral'>%s</span> </td>" % ( playercount ) outputtext += "<td style='text-indent:1em;'> Player Accounts</td></tr>\n" # Statistics Item/Char Totals outputtext += "<tr><td style='width:90px;text-align:right;'>" outputtext += "<span style='font-weight:bold;'>Statistics:</span> </td><td></td></tr>\n" outputtext += "<tr><td style='width:90px;text-align:right;'>" outputtext += "<span class='server_neutral'>%s</span> </td>" % ( wolfpack.playercount() ) outputtext += "<td style='text-indent:1em;'> Total Players</td></tr>\n" outputtext += "<tr><td style='width:90px;text-align:right;'>" outputtext += "<span class='server_neutral'>%s</span> </td>" % ( wolfpack.itemcount() ) outputtext += "<td style='text-indent:1em;'> Total Items</td></tr>\n" outputtext += "<tr><td style='width:90px;text-align:right;'>" outputtext += "<span class='server_neutral'>%s</span> </td>" % ( wolfpack.npccount() ) outputtext += "<td style='text-indent:1em;'> Total NPCs</td></tr>\n" outputtext += "</table>\n" outputtext += "</div>\n" file.write( outputtext ) file.close() wolfpack.addtimer( 1000, autostatuswrapper ) processthread.mutex.acquire() processthread.processed = True processthread.mutex.release() return True