Chaos Project

RPG Maker => RPG Maker Scripts => RMXP Script Database => Topic started by: Wizered67 on December 20, 2010, 09:03:27 pm

Title: [XP] RMX-OS Online List
Post by: Wizered67 on December 20, 2010, 09:03:27 pm
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




Screenshots
Spoiler: ShowHide
(http://i55.tinypic.com/2ikcvit.png)



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




Author's Notes

If you have any problems, just report them. I may have missed something.
Title: Re: RMX-OS Online List
Post by: Blizzard on December 21, 2010, 02:27:18 am
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.
Title: Re: RMX-OS Online List
Post by: Wizered67 on December 21, 2010, 11:03:18 am
Sorry about that. I fixed it.
Title: Re: [XP] RMX-OS Online List
Post by: Blizzard on December 21, 2010, 01:18:31 pm
Please try to pay more attention in the future. Thanks.
Title: Re: [XP] RMX-OS Online List
Post by: Griver03 on February 11, 2011, 09:16:45 am
i got this error with rmx-os 1.17 with 1.15 all wotks fine ...
http://img827.imageshack.us/i/onlinelisterror.png/ (http://img827.imageshack.us/i/onlinelisterror.png/)
thx in advance
Title: Re: [XP] RMX-OS Online List
Post by: Wizered67 on February 11, 2011, 10:24:32 am
When do you get that error? I need more information to help you.
Title: Re: [XP] RMX-OS Online List
Post by: Griver03 on February 11, 2011, 11:17:20 am
when i wrote the command "online" and ten press enter the error message comes up  :???:
Title: Re: [XP] RMX-OS Online List
Post by: Wizered67 on February 11, 2011, 03:35:49 pm
Is there an error in the server log? Also, make sure you have the extension for this and blizzards user logger.
Title: Re: [XP] RMX-OS Online List
Post by: Griver03 on February 13, 2011, 10:38:56 am
no there are now errors with the user logger so idk with 1.15 it works with 1.17 not ...
Title: Re: [XP] RMX-OS Online List
Post by: Wizered67 on February 13, 2011, 11:01:44 am
I can try to help you, but off of what you've given me, I don't know what I can do to help.
Title: Re: [XP] RMX-OS Online List
Post by: Ryex on February 13, 2011, 03:42:43 pm
at some point in a recent version of RMX-OS Blizz changed how communication worked. that is likely the root of this problem.
Title: Re: [XP] RMX-OS Online List
Post by: Blizzard on February 13, 2011, 04:29:20 pm
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.
Title: Re: [XP] RMX-OS Online List
Post by: Griver03 on February 14, 2011, 10:00:51 am
hmmm so its actually a bug right?! do you change it pls  :roll:
Title: Re: [XP] RMX-OS Online List
Post by: ForeverZer0 on February 14, 2011, 12:27:14 pm
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.
Title: Re: [XP] RMX-OS Online List
Post by: Wizered67 on February 14, 2011, 01:22:05 pm
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?
Title: Re: [XP] RMX-OS Online List
Post by: Blizzard on February 14, 2011, 01:26:35 pm
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.
Title: Re: [XP] RMX-OS Online List
Post by: Wizered67 on February 14, 2011, 11:29:59 pm
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.
Title: Re: [XP] RMX-OS Online List
Post by: Vaelen on June 04, 2011, 12:44:34 am
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.
Title: Re: [XP] RMX-OS Online List
Post by: ForeverZer0 on June 04, 2011, 02:22:38 am
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.
Title: Re: [XP] RMX-OS Online List
Post by: Vaelen on June 04, 2011, 10:04:22 am
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.
Title: Re: [XP] RMX-OS Online List
Post by: exile360 on May 13, 2013, 11:28:02 am
This thread is pretty old, but I hope it's still fine that I'm posting, as I have a problem. Namely, the exact same problem as everyone else in this thread. I've triple checked and everything is correct, extension is there, added in the config, it loads after user logger, names are correct and exactly the same everywhere (even the script in the project), but it keeps giving me this error. Not sure what's wrong. I saw this working fine in Pokemon Remexos. :< Any developments on this that haven't been posted?
Title: Re: [XP] RMX-OS Online List
Post by: Wizered67 on May 13, 2013, 06:43:25 pm
I believe Blizzard made a script with this functionality that I would advise using, as he is the master  ;)
http://forum.chaos-project.com/index.php/topic,13074.0.html

However, should you still want to use this one for any reason, I think I have an updated version I haven't posted that should work.
Title: Re: [XP] RMX-OS Online List
Post by: exile360 on May 13, 2013, 07:07:29 pm
Ah, I see. Silly me, I was actually going to use that script, but as it only works with RMXOS 1.3 and I've yet to update to that one (figured it's not worth the hassle as Blizz is working on 2.0 already) I forgot about it. I'll just keep waiting, thanks!  :P