Joined: 03 Apr 2005 Posts: 26 Location: Hertfordshire, England
Posted: Tue Apr 05, 2005 8:15 am Post subject:
People normally download Maya 4 and think.. wheres the Chat room.
Well i have found a Code for the chat room.
Code:
if ($msg eq "chat") {<br /> if (!exists $msn->{chatroom})<br /> {<br /> $msn->{chatroom} = $self;<br /> &send($self, "Welcome to the ChatRoom, $username");<br /> }<br /> elsif ($self eq $msn->{chatroom})<br /> {<br /> &send($self, "You are Already in the chat room!");<br /> }<br /> else<br /> {<br /> $msn->{chatroom}->invite($username);<br /> &send($self, "Waiting to go in the Chat Room...");<br /> } <br />}
EDIT: I am having some problems with the code, when everyone leaves the chat if you want to get back in you cant because it says "Waiting to go in" and it dosnt go to the right Socket. Anyone know how to solve this? [Bit like Calums post]
$msn->{chatroom} is a refrence to self, so self being the chatroom wene someone types !chat it sends from that socket: CAL \r\n in switchboard.pm inviting them to teh convo..
Look in msn.pm docs and add the RoomClosed hadndler check if the convo was chat and if so delete it
Or even better, make it a p4 chat.... Well better for msn client user....Other wise 'change' it so that non people without p4 capability can use it just as well;)
You could use the Games::Manager module to make a P4 chat room (and later, to make multiplayer games if you want to).
Code:
# Up right after creating $msn....<br />use Games::Manager;<br />$msn->{games} = new Games::Manager (debug => 1);<br />$msn->{games}->setHandler (broadcast => \&broadcast);<br /><br /># Games::Manager broadcast.<br />sub broadcast {<br /> my (%data) = @_;<br /> my $to = $data{to};<br /> my $msg = $data{message};<br /><br /> # Call them.<br /> $msn->call ($to, $msg);<br />}<br /><br />#......................................<br /><br />if ($msg eq "chat") {<br /> # See if the chat exists.<br /> if ($msn->{games}->queryGame ('chat') != 1) {<br /> # Create and add the first chat member.<br /> $msn->{games}->create (<br /> id => 'chat',<br /> name => 'P4 Chat Room',<br /> );<br /> $msn->{games}->addPlayer ('chat', $username);<br /> &send ($self, "Chat room created. Welcome!");<br /> }<br /> elsif ($msn->{games}->queryPlayer ('chat',$username)) {<br /> &send ($self, "You are already in the chat room!");<br /> }<br /> else {<br /> # Add this user to the chat.<br /> $msn->{games}->addPlayer ('chat', $username);<br /> $msn->{games}->broadcast ('chat', "$username has joined the room.");<br /> }<br />}
It's a kind of codey way to do it, but Games::Manager can handle chat rooms (you can even use Games::Manager to allow users to create their own rooms, you just have to know how to handle the ID's right so each room gets a unique ID)
I attached Manager.pm, extract to a lib/Games/ folder if you intend to use it. _________________ Current Site (2008) http://www.cuvou.com/
Joined: 03 Apr 2005 Posts: 26 Location: Hertfordshire, England
Posted: Wed Apr 06, 2005 12:35 pm Post subject:
QUOTE(Cer @ Apr 5 2005, 10:48 AM)
You could use the Games::Manager module to make a P4 chat room (and later, to make multiplayer games if you want to).
Code:
# Up right after creating $msn....<br />use Games::Manager;<br />$msn->{games} = new Games::Manager (debug => 1);<br />$msn->{games}->setHandler (broadcast => \&broadcast);<br /><br /># Games::Manager broadcast.<br />sub broadcast {<br /> my (%data) = @_;<br /> my $to = $data{to};<br /> my $msg = $data{message};<br /><br /> # Call them.<br /> $msn->call ($to, $msg);<br />}<br /><br />#......................................<br /><br />if ($msg eq "chat") {<br /> # See if the chat exists.<br /> if ($msn->{games}->queryGame ('chat') != 1) {<br /> # Create and add the first chat member.<br /> $msn->{games}->create (<br /> id => 'chat',<br /> name => 'P4 Chat Room',<br /> );<br /> $msn->{games}->addPlayer ('chat', $username);<br /> &send ($self, "Chat room created. Welcome!");<br /> }<br /> elsif ($msn->{games}->queryPlayer ('chat',$username)) {<br /> &send ($self, "You are already in the chat room!");<br /> }<br /> else {<br /> # Add this user to the chat.<br /> $msn->{games}->addPlayer ('chat', $username);<br /> $msn->{games}->broadcast ('chat', "$username has joined the room.");<br /> }<br />}
It's a kind of codey way to do it, but Games::Manager can handle chat rooms (you can even use Games::Manager to allow users to create their own rooms, you just have to know how to handle the ID's right so each room gets a unique ID)
I attached Manager.pm, extract to a lib/Games/ folder if you intend to use it. [right][snapback]47541[/snapback][/right]