Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting > Code Gallery
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #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
  #2  
Old 04-05-2007, 12:35 AM
Rapidwolve Rapidwolve is offline
Registered User
Join Date: Jul 2006
Posts: 1,241
Rapidwolve is an unknown quantity at this point
Haha, this makes me feel like "why didn't i think of that"
Reply With Quote
  #3  
Old 04-05-2007, 12:39 AM
killerogue killerogue is offline
Registered Omega
killerogue's Avatar
Join Date: Apr 2006
Location: United States
Posts: 1,920
killerogue is on a distinguished road
Send a message via AIM to killerogue Send a message via MSN to killerogue
It really and truly does ^....

Good work Chandler!
__________________


REMEMBER, IF YOU REP ME, LEAVE A NAME!

Quote:
Originally Posted by haunter View Post
Graal admins don't die. They go to hell and regroup.
Quote:
Originally Posted by Inverness View Post
Without scripters, your graphics and levels wouldn't do anything but sit there and look pretty.
Reply With Quote
  #4  
Old 04-05-2007, 12:44 AM
Rapidwolve Rapidwolve is offline
Registered User
Join Date: Jul 2006
Posts: 1,241
Rapidwolve is an unknown quantity at this point
Look what you did Chandler, now I wanna go script a more advanced one. Like AIM =]

Also, never knew findPlayer worked clientside
Reply With Quote
  #5  
Old 04-05-2007, 12:46 AM
Inverness Inverness is offline
Incubator
Inverness's Avatar
Join Date: Aug 2004
Location: Houston, Texas
Posts: 3,613
Inverness is a jewel in the roughInverness is a jewel in the rough
Graal is an extremely good development platform for beginners like myself.
__________________
Reply With Quote
  #6  
Old 04-05-2007, 12:48 AM
Gambet Gambet is offline
Registered User
Join Date: Oct 2003
Posts: 2,712
Gambet is on a distinguished road
I think Joey made something similar or was working on something similar?


It's not the first time it's been done, but nice work!
Reply With Quote
  #7  
Old 04-05-2007, 12:49 AM
Rapidwolve Rapidwolve is offline
Registered User
Join Date: Jul 2006
Posts: 1,241
Rapidwolve is an unknown quantity at this point
Quote:
Originally Posted by Inverness View Post
Graal is an extremely good development platform for beginners like myself.
Whoa, I thought you were Yen for a minute...
Reply With Quote
  #8  
Old 04-05-2007, 07:55 AM
Chandler Chandler is offline
Banned
Join Date: Jan 2007
Posts: 656
Chandler will become famous soon enough
thank you!
Reply With Quote
  #9  
Old 04-05-2007, 01:37 PM
MysticX2X MysticX2X is offline
Prince
MysticX2X's Avatar
Join Date: Sep 2005
Posts: 2,529
MysticX2X will become famous soon enough
Nice work =o.
__________________
-Mystic

former acc: mystic2k


RIP Matt (NBK)
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 05:36 AM.


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