View Single Post
  #1  
Old 04-05-2007, 03:39 AM
Rapidwolve Rapidwolve is offline
Registered User
Join Date: Jul 2006
Posts: 1,241
Rapidwolve is an unknown quantity at this point
Yet Another Chat System

I just started on this. I'll probobly be done with everything by tommorow

PHP Code:
function onActionServerside(action){
  switch (
action){
    case 
"SendMessage":
    
SendMessage(player.accountparams[1], params[2]);
    break;
    
    case 
"BlockBuddy":
      if (
player.clientr.messaging_blocked.index(params[1]) < 0){
        
player.clientr.messaging_blocked.add(params[1]);
        
player.addMessage(format(_("%s was added to your block list"), params[1]));
      }
    break;
   }
}

public function 
SendMessage(fromtomessage){
 
temp.phead findPlayer(temp.from).headimg;
 
findPlayer(temp.to).triggerClient("gui"name"ReceivedMessage"temp.fromtemp.messagetemp.phead);
}
//#CLIENTSIDE
function onCreated()
  
CreateVariables();
  
function 
CreateVariables(){
join("functions_system");
this.defaultprofile "GuiBlue";
this.buttons = {"BuddyInfo""Block""Warn"};
this.buttonextent 60;
this.buttondistance 2;
}

function 
onActionClientside(action){
  switch (
action){
    case 
"ReceivedMessage":
    
drawText(format(/*"<%img src=%s offsetx=3 offsety=69 height=32 width=32 />*/"<b><font color=\"red\">%s:</b></font>"/*params[3],*/ params[1]), params[1]);
    
drawText(params[2], params[1]);
    break;
  }
}

function 
onPlayerChats(){
  if (
player.chat.starts(":im")){
    
temp.recipient player.chat.substring(4);
      if (
GetStatus(temp.recipient)){
        
drawWindow(temp.recipient);
    }
  }
}

function 
GetStatus(recipient){
  
temp.notBlocked = ((findPlayer(temp.recipient).clientr.messaging_blocked.index(player.account)) < 0);
  
temp.isOnline = (findPlayer(temp.recipient).account true false);
  
temp.canIM = (temp.notBlocked && temp.isOnline);
  return 
temp.canIM;
}

function 
drawWindow(recipient){
  if (
temp.recipient.length() < 2) return player.chat "Error";
  if ((
"IMWindow_" temp.recipient).visible) return;
  new 
GuiWindowCtrl("IMWindow_" temp.recipient){
    
profile format("%sWindowProfile"thiso.defaultprofile);
    
extent = {350300};
    
canResize canMaximize false;
    
title true;
    
text "Instant Message - " temp.recipient;
    
visible true;
    
    new 
GuiScrollCtrl("IMScroll_" temp.recipient){
      
profile format("%sScrollProfile"thiso.defaultprofile);
      
position = {624};
      
hScrollBar "alwaysOff";
      
vScrollbar "dynamic";
      
extent = {(this.parent.width 12), (this.parent.height 57)};
    
      new 
GuiMLTextCtrl("IMText_" temp.recipient){
        
profile format("%sTextProfile"thiso.defaultprofile);
        
extent = {(parent.width 6), 0};
        
text format("<b> Chat with %s, Started %i:%i:%i. All times are GMT</b>"temp.recipientgetRealTime(010)[0], getRealTime()[1], getRealTime()[2]);
      }
    }
    
    new 
GuiTextEditCtrl("IMTextEdit_" temp.recipient){
      
profile format("%sTextEditProfile"thiso.defaultprofile);
      
position = {6, (this.parent.height 31.5)};
      
text "";
      
extent = {((this.parent.width) - (20 thiso.buttons.size() * thiso.buttonextent thiso.buttondistance)), 25}; 
      
thiso.catchevent(this.name"onAction""SendMessage");
      
historySize 100;
    }
    for (
temp.0temp.thiso.buttons.size(); temp.i++){
      new 
GuiButtonCtrl("IMButton_" temp.recipient "_" thiso.buttons[temp.i]){
       
profile format("%sButtonProfile"thiso.defaultprofile);
       
position = {(((this.parent.width 60 thiso.buttonextent)/ thiso.buttons.size()) + (* (thiso.buttonextent thiso.buttondistance))), (this.parent.height 31.5)};
       
extent = {thiso.buttonextent25};
       
text thiso.buttons[temp.i];
       
thiso.catchevent(this.name"onAction""ButtonPressed");
      }
    }
  }
}

function 
ButtonPressed(){
  
temp.buttonName params[0].substring(params[0].positions("_")[params[0].positions("_").size()-1] + 1);
  
temp.buttonParent params[0].parent;
  (
"Button" temp.buttonName)(temp.buttonParent);
}

function 
SendMessage(control) {
  
temp.textcontrol makevar("IMText_" temp.recipient);
    if (
temp.control.text.length() < 1) return;
  
temp.recipient temp.control.substring(("IMTextEdit_").length());
  
drawText(format(/*"<img src=%s offsetx=3 offsety=69 width=26 height=23 />*/"<b><font color=\"blue\">%s:</b></font>"/*player.headimg,*/ player.account), temp.recipient);
  
drawText(temp.control.texttemp.recipient);
  
triggerServer("gui"name"SendMessage"temp.recipienttemp.control.text);
  
temp.control.text "";
}

function 
drawText(textrecipient){
  if (
temp.text.length() < 1) return;
   
temp.window makevar("IMWindow_" temp.recipient);
   
temp.control makevar("IMText_" temp.recipient);
  if (!
temp.window.visibledrawWindow(temp.recipient);
   
temp.control.addText("\n" SPC temp.texttrue);
   
temp.control.scrolltoBottom();
}

function 
ButtonClose(window)
  (
temp.window).destroy();

function 
ButtonWarn(window)
  return;

function 
BuddyInfo()
  return;

function 
ButtonBlock(window){
  
temp.recipientName temp.window.substring(("IMWindow_").length());
    if (
temp.recipientName == player.account) return player.addMessage("You cannot block yourself");
  
triggerServer("gui"name"BlockBuddy"temp.recipientName);
  (
temp.window).destroy();

Ever since I saw Chandlers I realized how much I wanted to make my own lol,
anyways I removed displaying of heads as it was buggy. Just say :im <acc>
to start a conversation, make sure they have the weapon.
Reply With Quote