Module: Frostbitten::Methods::NormalCommands
- Included in:
- Client
- Defined in:
- lib/frostbitten/methods/normal.rb
Overview
Methods not requiring admin rcon priveleges
Instance Method Summary collapse
-
#auth(password = nil) ⇒ Object
Authenticate connection using password or pregiven password in uri.
-
#players(list = "all") ⇒ Object
Lists players and will return list of players.
-
#serverinfo ⇒ Object
General server information.
Instance Method Details
#auth(password = nil) ⇒ Object
Authenticate connection using password or pregiven password in uri.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/frostbitten/methods/normal.rb', line 7 def auth(password=nil) unless password raise ArgumentError, "No password supplied" unless self.server and self.server.password end password = password ? password : self.server.password data = send("login.hashed") salt = [data.first].pack("H*") hashed = Digest::MD5.hexdigest("#{salt}#{password}") if send(["login.hashed", hashed.upcase]) @logged_in = true else @logged_in = false end return self end |
#players(list = "all") ⇒ Object
Lists players and will return list of players
28 29 30 31 32 33 |
# File 'lib/frostbitten/methods/normal.rb', line 28 def players(list="all") data = send(['listPlayers', list]) if data return Player.players_from_list(data,0) end end |
#serverinfo ⇒ Object
General server information
36 37 38 39 40 41 42 43 44 |
# File 'lib/frostbitten/methods/normal.rb', line 36 def serverinfo score_data = send("serverinfo") score_data.insert(7,Frostbitten::Score.scores_from_list(score_data,7)) return Server.new {}.tap do |hash| score_data.to_enum.with_index(1).each do |value,key| hash["data#{key}"] = value end end end |