[XP] RMX-OS Online List

Started by Wizered67, December 20, 2010, 09:03:27 pm

Previous topic - Next topic

Wizered67

December 20, 2010, 09:03:27 pm Last Edit: December 28, 2010, 07:10:52 pm by game_guy
RMX-OS Online List
Authors: Wizered67
Version: 1.00
Type: RMX-OS Add-on
Key Term: RMX-OS Plugin



Introduction

Adding this script will add a new command for RMX-OS called "/online". By using this command it will give the player a list of all players online. This script requires Blizzard's User Logger for RMX-OS.


Features


  • Simple add-on that is easy to use

  • Makes it easy for any player to find out who is online.




Screenshots
Spoiler: ShowHide



Demo
N/A


Script

Script: ShowHide

#------------------------------------------------------------------------------
#                  RMX-OS Online List
#                     by Wizered67
#                          V 1.00
# All errors should be reported at www.chaos-project.com.
#------------------------------------------------------------------------------
module RMXOS
 module Documentation
 PARAMETERS['online']    = 'none'  
 DESCRIPTIONS['online']    = 'Shows the amount of players online.'
 end
 class Network
 alias check_normal_commands_online_add check_normal_commands
 def check_normal_commands(message)
   case message
   when /\A\/online\Z/
    $network.send('POL')
     return true
   end
   return check_normal_commands_online_add(message)
 end
end
end


.rb server extension

.rb add-on: ShowHide

module RMXOS
 
 def self.load_current_extension
   return PlayersOnline
 end
 
end

#======================================================================
# module PlayersOnline
#======================================================================

module PlayersOnline
 
 VERSION = 1.01
 RMXOS_VERSION = 1.08
 SERVER_THREAD = false
 #This will not work if the user logger isn't listed before this.
 LOG_LOCATION = UserLogger::ONLINELIST_FILENAME
 
 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 /\APOL\Z/
   #set @players_online to equal an empty array
   @players_online = []
   #get info from the user logger log.
   file = File.open(LOG_LOCATION , 'r')
   #add each line to the @players_online array.  Each line is a different user.
   file.each_line {|line| @players_online.push(line)
   }
     #close file
     file.close
     #define a new variable, at first being equal to an empty string.
     @players_on = ''
    for i in 0...@players_online.size
    #makes @players_on equal to the current @players_on plus the players that are online.
    @players_on = @players_online[i] + @players_on
   end
    #sends final message
    client.send("CHT#{RMXOS::Data::ColorInfo}\t0\tPlayers Online: #{@players_on}")
    return true
    end
    return false
end
 
end




Instructions
Just put in the script below RMX-OS and add the .rb add-on to extension to the extensions list.
Make sure it comes after the user logger in  the server config.


Compatibility

Requires RMX-OS and Blizzard's User Logger.


Credits and Thanks


  • Wizered67

  • Blizzard for making RMX-OS and his user logger.




Author's Notes

If you have any problems, just report them. I may have missed something.

Blizzard

Quote from: Wizered67 on December 20, 2010, 09:03:27 pm
Authors:Wizered67


Quote from: Blizzard on January 07, 2008, 08:51:26 pm
Authors: <AUTHORS, NO SPECIAL THANKS HERE>


Play VERY close attention to the template. There is a space between : and the name of the authors.
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.

Wizered67

Sorry about that. I fixed it.

Blizzard

Please try to pay more attention in the future. Thanks.
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.

Griver03

i got this error with rmx-os 1.17 with 1.15 all wotks fine ...
http://img827.imageshack.us/i/onlinelisterror.png/
thx in advance
My most wanted games...



Wizered67

When do you get that error? I need more information to help you.

Griver03

when i wrote the command "online" and ten press enter the error message comes up  :???:
My most wanted games...



Wizered67

Is there an error in the server log? Also, make sure you have the extension for this and blizzards user logger.

Griver03

no there are now errors with the user logger so idk with 1.15 it works with 1.17 not ...
My most wanted games...



Wizered67

I can try to help you, but off of what you've given me, I don't know what I can do to help.

Ryex

at some point in a recent version of RMX-OS Blizz changed how communication worked. that is likely the root of this problem.
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 />

Blizzard

When I take a look at this script, you should be able to make this a lot easier. Just iterate through the $clients hash.

usernames = []
$clients.each_value {|c| usernames.push(c.player.username) if c.player.user_id > 0}
onlinelist = usernames.join(',')


Then just send onlinelist over the network. This should work.
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.

Griver03

hmmm so its actually a bug right?! do you change it pls  :roll:
My most wanted games...



ForeverZer0

Not really a bug, just something that may need to be added to accomodate for a new version of RMX-OS. It would only have to be a if..else statement to check for the RMX-OS version, or if Blizzard's suggestion works with all versions, simply replace the troublesome part with the error-safe way.
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

Wizered67

Okay, so its caused by changes in RMX-OS. I'll try to update this script as soon as I can. What exactly was wrong with the old version though that made it not work with the new RMX-OS?

Blizzard

I'm not even sure. Your code looks alright to me at first sight.
You should check the methods you have aliased. One may be called now differently or something like that.
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.

Wizered67

I just tested this with the new RMX-OS and had no problems. That leads me to believe you are doing something wrong. Make sure you have the extension for this and the user logger. That's all I can think would be wrong.

Vaelen

Hello my Heros ;)

I get the same error if i use /online.

Error Log:
Spoiler: ShowHide
Quote2011-06-04 04:31:30 UTC; 2 (test) - Error:
No such file or directory -
./Extensions/OnlineList.rb:40:in `initialize'
G:/RPG Maker/Tools/RMX-OS 1.18/RMX-OS Server/Extensions/OnlineList.rb:40:in `open'
G:/RPG Maker/Tools/RMX-OS 1.18/RMX-OS Server/Extensions/OnlineList.rb:40:in `client_update'
G:/RPG Maker/Tools/RMX-OS 1.18/RMX-OS Server/Data/Client.rb:43:in `block in handle'
G:/RPG Maker/Tools/RMX-OS 1.18/RMX-OS Server/Data/Client.rb:43:in `each_value'
G:/RPG Maker/Tools/RMX-OS 1.18/RMX-OS Server/Data/Client.rb:43:in `handle'
G:/RPG Maker/Tools/RMX-OS 1.18/RMX-OS Server/Data/Server.rb:272:in `block in run'


Thats my Extension Order:
GlobalDay-and-Night
GlobalSwitches
UserLogger
OnlineList
Report
Versioning

Screen of script editor (.[img] doesn'tshow the picture :/ )
http://imageshack.us/photo/my-images/163/screenxu.png/


I use rmxp 1.04 and the latest scripts. Hope you can find the bug.
thx blizz for the great work (I don't have to do) ;)
RMX-OS gonna be legen.... wait-for-it... www.youtube.com/watch?v=Dqf1BmN4Dag

ForeverZer0

The file OnlineList.rb is either mislabeled, not where it is supposed to be, or straight missing.
It should be named just like that and located in the Extensions folder.
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

Vaelen

June 04, 2011, 10:04:22 am #19 Last Edit: June 04, 2011, 07:52:06 pm by Vaelen
It is in the extension Folder.  But I give file names like I want.. (you see at the screenshot). All other Scripts are running so I don't think that the file name must be the same like the script name  :???:  and I write the file names in the Extension array (cfg.ini).
When I start the server the extensions are loaded correctly.

But I will check it again. I'm not home at the moment. Maybe I made a mistake.. it was 5am  :zzz:



Edit:
I checked all, the script is loaded after User Logger by the server. In rmxp the Script is below RMX-OS..  no errors. Then /online and crash.. its not working.. I don't think its my failure because all other extensions work.. the documentation is a bit short.. only that User Logger must load before.
thx blizz for the great work (I don't have to do) ;)
RMX-OS gonna be legen.... wait-for-it... www.youtube.com/watch?v=Dqf1BmN4Dag