Thread: Chat system
View Single Post
  #1  
Old 04-05-2007, 12:28 AM
Chandler Chandler is offline
Banned
Join Date: Jan 2007
Posts: 656
Chandler will become famous soon enough
Chat system

PHP Code:
function onActionServerside(currentOptionmessageData)
  if (
temp.currentOption == "sendMessage")
    {
    
findPlayer(temp.messageData[0]).addWeapon(this.name);
    
findPlayer(temp.messageData[0]).triggerclient("weapon"this.name"receiveMessage", {temp.messageData[1], player.accountplayer.nick});
    }   
//#CLIENTSIDE
function onPlayerChats()
  {
  if (
player.chat.starts(":sendim"))
    {
    if (
client.textAccounts.size() <= 3)
      
this.startConversation(player.chat.substring(7).trim());
    }
  elseif (
player.chat.starts(":viewblocked"))
    {
    
temp.newMessage "Currently Blocked accounts:\n";
    for (
temp.currentBlockedclient.cIgnore)
      
temp.newMessage @= (client.cIgnore.index(temp.currentBlocked) + 1) @",)" SPC temp.currentBlocked @"\n";
    
sendrpgmessage(temp.newMessage);
    
player.chat "Read your console log! [F2]";
    }
  elseif (
player.chat.starts(":unblock"))
    {    
    if (
client.cIgnore.index(player.chat.substring(8).trim()) == -1)
      
player.chat "That player isn't blocked!";
     else
      {
      
client.cIgnore.remove(player.chat.substring(8).trim());
      
player.chat "You've unblocked" SPC player.chat.substring(8).trim() @"!";
      }
    }
  }
    
function 
startConversation(playersAccount)
  {
  if (
client.textAccounts.index(temp.playersAccount) != -1)
    return 
false;
    
  if (!
findPlayer(temp.playersAccount).account)
    {
    
player.chat "That player isn't online!";
    return 
false;
    }
  
client.textAccounts.add(temp.playersAccount);
  if (
ChatBar.visible)
    
ChatBar.visible false;

  
temp.cimButtons = {
    {
"Clear"61429622},
    {
"Block"1011429622},
    {
"Close"1971429722}
  };
    
  (
"main_" temp.playersAccount).destroy();
  new 
GuiWindowCtrl("main_" temp.playersAccount
    {
    
profile "GuiBlueWindowProfile";
    
    
position = {00};
    
extent = {300170};
    
    
text "CIM -:" SPC temp.playersAccount;
    
canclose canfalse;
    
    new 
GuiScrollCtrl("messages_"temp.playersAccount)
      {
      
position = {623};
      
extent = {288100};

      
profile "GuiBlueScrollProfile";

      
horizSizing "width";
      
hScrollBar "alwaysOff";
    
      new 
GuiMLTextCtrl("messageBox_"temp.playersAccount)
        {
        
position = {00};
        
extent = {250100};

        
profile "GuiBlueMLTextProfile";
        
addText("<b>Starting conversation!</b>"true);
        }
      }
      new 
GuiTextEditCtrl("textBox_"temp.playersAccount
        {
        
profile GuiBlueTextEditProfile;
        
position = {6123};
        
extent = {28820};
        
thiso.catchEvent(this"onAction""sendMessage");
        }        
     for (
temp.currentButtontemp.cimButtons)
      new 
GuiButtonCtrl("buttons_"temp.playersAccount @"-"temp.currentButton[0]) 
        {
        
profile "GuiBlueButtonProfile";
        
position = {temp.currentButton[1], temp.currentButton[2]};
        
extent = {temp.currentButton[3], temp.currentButton[4]};
        
text temp.currentButton[0];
        
thiso.catchevent(this.name"onAction""buttonPressed");
        }        
    }
  }
function 
sendMessage(objectName)
  {
  
temp.accountWindow temp.objectName.substring(8);
  
this.drawText(temp.accountWindowplayer.nick SPC "says:");
  
this.drawText(temp.accountWindow"  "@ ("textBox_"temp.accountWindow).text);
  
triggerserver("weapon"this.name"sendMessage", {temp.accountWindow, ("textBox_"temp.accountWindow).text});
  (
"textBox_"temp.accountWindow).text "";
  (
"messageBox_"temp.accountWindow).scrollToBottom();
  }
function 
drawText(accountSendmessageText)
  (
"messageBox_"accountSend).addText("\n"temp.messageTexttrue);

function 
onActionClientside(curOptionmessageData)
  if (
temp.curOption == "receiveMessage")
    if (
client.cIgnore.index(temp.messageData[1]) == -1)
      {
      if (!(
"main_" temp.messageData[1]).visible)
        
this.startConversation(temp.messageData[1]);
      
this.drawText(temp.messageData[1], "<b>"messageData[2SPC "</b>says:");
      
this.drawText(temp.messageData[1], messageData[0]);
      (
"messageBox_"temp.messageData[1]).scrollToBottom();
      }
function 
buttonPressed(objectName)
  {
  
temp.buttonName objectName.tokenize("-")[1];
  
temp.accountName objectName.tokenize("_")[1].tokenize("-")[0];
  switch(
temp.buttonName)
    {
    case 
"Clear":  ("messageBox_"temp.accountName).settext("<b>Cleared conversation!</b>"); break;
    case 
"Block":  
      
client.cIgnore.add(temp.accountName); 
      
client.textAccounts.remove(temp.accountName);
      (
"main_" temp.accountName).destroy();
      
player.chat "You've blocked" SPC temp.accountName @"!";
    break;
    case 
"Close":
      
client.textAccounts.remove(temp.accountName);
      (
"main_" temp.accountName).destroy();
    break;
    }
  } 
Here's how it works:
:sendim [Account Name]
--Sends an IM to that account name
:viewBlocked
--shows the people that you've blocked
:unBlock [Account Name]
--Unblocks the account.

Here's a snapshot, will probably be released on Era.

Thinking of adding more features, but here's a basic that you can use!
Attached Thumbnails
Click image for larger version

Name:	graal_1175725655.png
Views:	333
Size:	129.6 KB
ID:	40422  
Reply With Quote