Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   Code Gallery (https://forums.graalonline.com/forums/forumdisplay.php?f=179)
-   -   Yet Another Chat System (https://forums.graalonline.com/forums/showthread.php?t=73291)

Rapidwolve 04-05-2007 03:39 AM

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.account, params[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(from, to, message){
 
temp.phead = findPlayer(temp.from).headimg;
 
findPlayer(temp.to).triggerClient("gui", name, "ReceivedMessage", temp.from, temp.message, temp.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 = {350, 300};
    
canResize = canMaximize = false;
    
title = true;
    
text = "Instant Message - " @ temp.recipient;
    
visible = true;
    
    new 
GuiScrollCtrl("IMScroll_" @ temp.recipient){
      
profile = format("%sScrollProfile", thiso.defaultprofile);
      
position = {6, 24};
      
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.recipient, getRealTime(0, 1, 0)[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.i = 0; temp.i < 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()) + (i * (thiso.buttonextent + thiso.buttondistance))), (this.parent.height - 31.5)};
       
extent = {thiso.buttonextent, 25};
       
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.text, temp.recipient);
  
triggerServer("gui", name, "SendMessage", temp.recipient, temp.control.text);
  
temp.control.text = "";
}

function 
drawText(text, recipient){
  if (
temp.text.length() < 1) return;
   
temp.window = makevar("IMWindow_" @ temp.recipient);
   
temp.control = makevar("IMText_" @ temp.recipient);
  if (!
temp.window.visible) drawWindow(temp.recipient);
   
temp.control.addText("\n" SPC temp.text, true);
   
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.

Rapidwolve 04-09-2007 10:14 PM

1 Attachment(s)
Major Update

Next im going to disable all html tags and create a custom text editor and smiley inserter, not gonna release the script until its done because there are a couple minor (but annoying) bugs.

Chandler 04-09-2007 10:15 PM

Haha, that does look pretty nifty, hehe

Gambet 04-09-2007 11:31 PM

That looks very nice, though I fear it's rather unecessary and won't be used.



Great job on it so far, by all means don't quit, but personally, I don't even like using Client-RC for the mere fact that it's stuck to my client. The last thing I would want is a custom PM system that takes up space in my screen.


But, just a personal opinion. Regardless, you should finish it :)

Chandler 04-10-2007 07:41 AM

Quote:

Originally Posted by Gambet (Post 1298529)
That looks very nice, though I fear it's rather unecessary and won't be used.



Great job on it so far, by all means don't quit, but personally, I don't even like using Client-RC for the mere fact that it's stuck to my client. The last thing I would want is a custom PM system that takes up space in my screen.


But, just a personal opinion. Regardless, you should finish it :)

You're wrong.

contiga 04-10-2007 08:02 AM

Quote:

Originally Posted by Gambet (Post 1298529)
That looks very nice, though I fear it's rather unecessary and won't be used.

I like it very much and I think it IS going to be used, it's easy for instant-talking to a player in some other level without having to double click a player in the playerlist, type, click send OR having to rightclick, click: history to see what you've said. It's all in one small window inside screen now which is easy for when you're fullscreen for example.

smirt362 04-10-2007 08:32 AM

I like it very much, I would like to see it implemented on some of the main servers.

Novo 04-10-2007 02:14 PM

:cool: Thumbs up here!

DustyPorViva 04-10-2007 02:25 PM

Custom transparency :) And perhaps have a GAT make a less 'bulky' gui graphic than the default.

Chandler 04-10-2007 06:25 PM

I'd use this on Era :)

cbk1994 04-11-2007 01:18 AM

This is VERY NICE! I love it! Keep up the good work, I may have to make something similar. Good use of GUIs.

Rapidwolve 04-11-2007 01:57 AM

Quote:

Originally Posted by smirt362 (Post 1298681)
I like it very much, I would like to see it implemented on some of the main servers.

Quote:

Originally Posted by Chandler (Post 1298771)
I'd use this on Era :)

I would love to see me log on a server and its there, thats why once its done I will release everything.

Next on my list is to add text manipulation functions, replace icons, a more graal friendly GUI profile, and create a smiley set (I was going to use graal's PM default but I changed my mind), but I need to find a Graphics Designer for most of those.

Rapidwolve 04-13-2007 04:29 AM

Released a preview build on Zodiac.

Snapshot:
http://img407.imageshack.us/img407/3756/untitledef6.png

xXziroXx 04-13-2007 04:42 AM

Ahahaha! You just HAD to get a screenie of me exploiting HTML tags didnt you?

Bl0nkt 04-13-2007 06:38 AM

how do u get rid of this?

Rapidwolve 04-30-2007 03:39 AM

I got tired of scripting this. I disabled it off Zodiac because of an html bug. Can easily be fixed though.
PHP Code:

function onActionServerside(action){
  switch (
action){
    case 
"unblockPlayer":
    
player.clientr.messaging_blocked.remove(params[1]);
    
player.chat = "Unblocked [" @ params[1] @ "]";
    break;
    
    case 
"SendMessage":
    
findPlayer(params[1]).addweapon(name);
    
SendMessage(params[1], params[2], params[3], params[4]);    
    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(to, message, font, fontsize){
 
findPlayer(temp.to).triggerClient("gui", name, "ReceivedMessage", player.account, temp.message, player.nick, temp.font, temp.fontsize);
}
//#CLIENTSIDE
function onCreated()
  
CreateVariables();
  
function 
CreateVariables(){
  
this.defaultprofile = "GuiBlue";
  
this.buttons = {"Buddy Info", "Block", "Warn"};
  
this.buttonextent = {65, 23};
  
this.font_list = {"Verdana", "Times New Roman", "Tempus Sans ITC", "Arial"};
  
this.buttondistance = 2;
  
this.mainwin_width = 350;
  
this.mainwin_height = 330; 
}

function 
onActionClientside(action){
  switch (
action){
    case 
"ReceivedMessage":
    
drawText(format("<b><font color=\"red\">%s says:</b></font>", params[3]), params[1]);
    
drawText(format("<font color=\"black\" face=%s size=%s> %s </font>", params[4], params[5], params[2]), params[1]);
    break;
  }
}

function 
onPlayerChats()
{
  switch (
player.chat)
  {
    case 
":viewblocked": GetBlockedList(); break;
    case 
":disableim": client.disableim = true; break;
    case 
":enableim": client.disableim = false; break;
  }
  
  if (
player.chat.starts(":block"))
    
BlockBuddy(player.chat.substring(7));
  
  if (
player.chat.starts(":unblock")){
    
temp.otherplayer = player.chat.substring(9);
    
unblockPlayer(temp.otherplayer);
  }
  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 && client.disableim == false) ? true : false);
  
temp.canIM = (temp.notBlocked && temp.isOnline);
  return 
temp.canIM;
}

function 
unblockPlayer(player)
  
triggerServer("weapon", name, "unblockPlayer", temp.player);

function 
GetBlockedList(){
  if (!
clientr.messaging_blocked) return echo("You haven't blocked anybody");
  
  for (
temp.i: clientr.messaging_blocked)
    echo(
temp.i);
    
  
player.chat = "Press [F2] to view your blocked list.";
  echo(
"Say :unblock <account> to unblock an account");
}

function 
drawWindow(recipient){
  new 
GuiWindowCtrl("IMWindow_" @ temp.recipient){
    
profile = format("%sWindowProfile", thiso.defaultprofile);
    
extent = {thiso.mainwin_width, thiso.mainwin_height};
    
canResize = canMaximize = canClose = false;
    
title = true;
    
text = "Instant Message with " @ temp.recipient;
    
visible = true;
    
bringToFront();
    
    new 
GuiMenuCtrl("IMMenu_" @ temp.recipient){
      
profile = format("%sTextEditProfile", thiso.defaultprofile);
      
extent = {(thiso.mainwin_width - 12), 22};
      
position = {6, 24};
      
horizSizing = "width";
      
setIconSize(16, 16);
      
clearmenus();
      
      
with (addMenu("File")){
        
icon.drawimagestretched(0, 0, 16, 16, "fileicon_nw.png", 0, 0, 16, 16);
        
profile = format("%sPopUpMenuProfile", thiso.defaultprofile);
        
textprofile = format("%sTextListProfile", thiso.defaultprofile);
        
addRow(0, "New IM");
        
addRow(-1, "-");
        
addRow(1, "Close");
      }
      
      
with (addMenu("Edit")){
        
icon.drawimagestretched(0, 0, 16, 16, "fileicon_txt.png", 0, 0, 16, 16);
        
profile = format("%sPopUpMenuProfile", thiso.defaultprofile);
        
textprofile = format("%sTextListProfile", thiso.defaultprofile);
        
addRow(0, "Find");
       }
       
      
with (addMenu("Tools")){
        
icon.drawimagestretched(0, 0, 16, 16, "fkwarper.png", 0, 0, 32, 32);
        
profile = format("%sPopUpMenuProfile", thiso.defaultprofile);
        
textprofile = format("%sTextListProfile", thiso.defaultprofile);
        
addRow(0, "Text");
        
addRow(1, "Smileys");
        
addRow(-1, "-");
        
addRow(2, "Preferences");
        
addRow(3, "Options");
        }
        
      
with (addMenu("Help")){
        
icon.drawimagestretched(0, 0, 16, 16, "sign.png", 0, 0, 32, 32);
        
profile = format("%sPopUpMenuProfile", thiso.defaultprofile);
        
textprofile = format("%sTextListProfile", thiso.defaultprofile);
        
addRow(0, "Report a bug");
        
addRow(-1, "-");
        
addRow(1, "About");
       }
       
       
thiso.catchevent(this.name, "onSelect", "MenuSelect");
    }
    
    new 
GuiScrollCtrl("IMScroll_" @ temp.recipient){
      
profile = format("%sScrollProfile", thiso.defaultprofile);
      
position = {6, 46};
      
hScrollBar = "dynamic";
      
vScrollbar = "dynamic";
      
extent = {(thiso.mainwin_width - 12), (thiso.mainwin_height - 130)};
      
visible = true;
      
      new 
GuiMLTextCtrl("IMText_" @ temp.recipient)
      {
        
profile = format("%sTextProfile", thiso.defaultprofile);
        
extent = {((thiso.mainwin_width - 12) - 1), 0};
        
text = format("<body bgcolor=\"lightgray\"><font color=\"black\" face=\"verdana\"><b> Instant Message with %s</b></font>", temp.recipient);
      }
    }
    
    new 
GuiPopUpMenuCtrl("IMTextSizeList_" @ temp.recipient)
    {
      
profile = format("%sPopUpMenuProfile", thiso.defaultprofile);
      
textprofile = format("%sTextListProfile", thiso.defaultprofile);
      
scrollprofile = format("%sScrollProfile", thiso.defaultprofile);
      
position = {107, (thiso.mainwin_height - 81)};
      
extent = {45, 25};
      
clearrows();
      for (
temp.i = 8; temp.i <= 20; temp.i++)
        
addRow(0, temp.i);
      
setSelectedRow(0);
    }
    new 
GuiPopUpMenuCtrl("IMFontList_" @ temp.recipient)
    {
      
profile = format("%sPopUpMenuProfile", thiso.defaultprofile);
      
textprofile = format("%sTextListProfile", thiso.defaultprofile);
      
scrollprofile = format("%sScrollProfile", thiso.defaultprofile);
      
position = {6, (thiso.mainwin_height - 81)};
      
extent = {100, 25};
      
clearrows();
      for (
temp.i: thiso.font_list)
        
addRow(0, temp.i);
      
setSelectedRow(0);
} 
    new 
GuiTextEditCtrl("IMTextEdit_" @ temp.recipient)
    {
      
profile = format("%sTextEditProfile", thiso.defaultprofile);
      
position = {6, (thiso.mainwin_height - 54)};
      
text = "";
      
tabCompete = true;
      
extent = {(thiso.mainwin_width - 12), 25}; 
      
thiso.catchevent(this.name, "onAction", "SendMessage");
      
historySize = 100;
    }
    for (
temp.i = 0; temp.i < thiso.buttons.size(); temp.i++)
    {
      new 
GuiButtonCtrl("IMButton_" @ temp.recipient @ "_" @ thiso.buttons[temp.i]){
       
profile = format("%sButtonProfile", thiso.defaultprofile);
       
position = {(((thiso.buttonextent[0]) / thiso.buttons.size()) + (i * (thiso.buttonextent[0] + thiso.buttondistance)) + 50), (thiso.mainwin_height - 28.5)};
       
extent = {thiso.buttonextent[0], thiso.buttonextent[1]};
       
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)
 {
  if (
temp.control.text.length() < 1) return;
  
temp.recipient = temp.control.substring(("IMTextEdit_").length());
  
temp.textcontrol = makevar("IMText_" @ temp.recipient);
  
drawText(format("<b><font color=\"blue\">%s says:</b></font>", player.nick), temp.recipient);
  
drawText(format("<font color=\"black\" face=%s size=%s> %s </font>", onGetFontFace(temp.recipient), onGetFontSize(temp.recipient), temp.control.text), temp.recipient);
  
triggerServer("gui", name, "SendMessage", temp.recipient, temp.control.text, onGetFontFace(temp.recipient), onGetFontSize(temp.recipient));
  
temp.control.text = "";
}

function 
onGetFontFace(recipient)
  return (
"IMFontList_" @ temp.recipient).getSelectedText();

function 
onGetFontSize(recipient)
  return ((
"IMTextSizeList_" @ temp.recipient).getSelectedText() * 2);

function 
MenuSelect(menuname, tabname, id, selectedindex)
{
  switch (
temp.tabname)
  {
    case 
"File":
      switch (
temp.selectedindex)
      {
        case 
"Close":
        
ButtonClose(temp.menuname.parent);
        break; 
      }
    break;
  }
}

function 
drawText(text, recipient)
{
  if (
temp.text.length() > 0)
  {
    
temp.window = makevar("IMWindow_" @ temp.recipient);
      if (!
temp.window.visible) drawWindow(temp.recipient);
    
temp.control = makevar("IMText_" @ temp.recipient);
    
temp.control.addText("\n" SPC temp.text, true);
    
temp.control.scrolltoBottom();
   }
}

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

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();
}  

function 
BlockBuddy(buddy)
  
triggerServer("weapon", name, "BlockBuddy", temp.buddy); 


TheJames 06-25-2007 02:18 AM

Don't mean to bring up a dead thread. But is there a version where the block works?


All times are GMT +2. The time now is 11:20 PM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.