Tell.rb
RubyMud/Commands/Tell.rb · 1.1 KB
From the archive rbmud-0.1rc2.tar.gz
Download the archive « Back to the archive contents
require "Command.rb"
require "Commands.rb"
require "Players.rb"
module RubyMud
class Tell < Command
def words
return ["tell"]
end
def initialize()
super()
end
def execute(clientConnection,string)
tokens = string.split(' ')
# If only look is on the command line
if (tokens.length < 3)
clientConnection.send("You need to type in the person's name and text to send him\r\n")
return
end
# Get the text player to send to
personToSendTo = tokens[1]
tokens.delete_at(0)
tokens.delete_at(0)
textToSend = tokens.join(" ")
# Find the player to send to
to = Players.find(personToSendTo)
if (to == nil)
clientConnection.send("Cannot find "+personToSendTo+" on this plain\r\n")
return
end
if (to.clientConnection() == nil)
clientConnection.send(personToSendTo+" is not connected\r\n")
return
end
to.clientConnection().send(clientConnection.player.name+" tells you: \""+textToSend+"\"\r\n")
clientConnection.send("You tell "+personToSendTo+": \""+textToSend+"\"\r\n")
end
end
# Create the instance, it adds itself to the commands list
Tell.new()
end #module