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
  #16  
Old 04-30-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
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(tomessagefontfontsize){
 
findPlayer(temp.to).triggerClient("gui"name"ReceivedMessage"player.accounttemp.messageplayer.nicktemp.fonttemp.fontsize);
}
//#CLIENTSIDE
function onCreated()
  
CreateVariables();
  
function 
CreateVariables(){
  
this.defaultprofile "GuiBlue";
  
this.buttons = {"Buddy Info""Block""Warn"};
  
this.buttonextent = {6523};
  
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.iclientr.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_widththiso.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 = {624};
      
horizSizing "width";
      
setIconSize(1616);
      
clearmenus();
      
      
with (addMenu("File")){
        
icon.drawimagestretched(001616"fileicon_nw.png"001616);
        
profile format("%sPopUpMenuProfile"thiso.defaultprofile);
        
textprofile format("%sTextListProfile"thiso.defaultprofile);
        
addRow(0"New IM");
        
addRow(-1"-");
        
addRow(1"Close");
      }
      
      
with (addMenu("Edit")){
        
icon.drawimagestretched(001616"fileicon_txt.png"001616);
        
profile format("%sPopUpMenuProfile"thiso.defaultprofile);
        
textprofile format("%sTextListProfile"thiso.defaultprofile);
        
addRow(0"Find");
       }
       
      
with (addMenu("Tools")){
        
icon.drawimagestretched(001616"fkwarper.png"003232);
        
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(001616"sign.png"003232);
        
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 = {646};
      
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 = {4525};
      
clearrows();
      for (
temp.8temp.<= 20temp.i++)
        
addRow(0temp.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 = {10025};
      
clearrows();
      for (
temp.ithiso.font_list)
        
addRow(0temp.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.0temp.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()) + (* (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.recipienttemp.control.textonGetFontFace(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(menunametabnameidselectedindex)
{
  switch (
temp.tabname)
  {
    case 
"File":
      switch (
temp.selectedindex)
      {
        case 
"Close":
        
ButtonClose(temp.menuname.parent);
        break; 
      }
    break;
  }
}

function 
drawText(textrecipient)
{
  if (
temp.text.length() > 0)
  {
    
temp.window makevar("IMWindow_" temp.recipient);
      if (!
temp.window.visibledrawWindow(temp.recipient);
    
temp.control makevar("IMText_" temp.recipient);
    
temp.control.addText("\n" SPC temp.texttrue);
    
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); 
Reply With Quote
  #17  
Old 06-25-2007, 02:18 AM
TheJames TheJames is offline
Atrius Manager
TheJames's Avatar
Join Date: Dec 2004
Posts: 581
TheJames can only hope to improve
Don't mean to bring up a dead thread. But is there a version where the block works?
__________________
Contact me on Skype: "skype.sam.lorenz"

James,
Manager of Atrius
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 12:06 PM.


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