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-21-2009, 08:57 AM
Gambet Gambet is offline
Registered User
Join Date: Oct 2003
Posts: 2,712
Gambet is on a distinguished road
Buddy Communication System

I made a system similar to something that was suggested here: http://forums.graalonline.com/forums....php?p=1485077

Basically, the system allows you to send mass messages to only your online buddies (same server) by either the gui-based method or the chat-based method. For the gui-based method, you will need to have the scripted playerlist enabled.

To enable the scripted playerlist:

F3 --> General --> Player list Options --> Check the box that reads "Use in-game playerlist"


If you have the scripted playerlist enabled, then simply right-click on any entry in the playerlist to bring up a new option for your popup menu: Message All Buddies

Click on this button to bring up a window similar to the mass-message window. Currently, only the 'Close' and 'Send' buttons work, the 'History' button does nothing but is there to make it easier to add functionality to it in the future. Simply type your message and press send.

For the chat-based method, simply say "tobuddies: <message here>" (without the braces) and your message will have sent.

I also added two separate features, which are a cooldown system to prevent spamming (currently a 15 second cooldown in-between messages which can be easily changed) and an ignoring feature that allows you to ignore all buddy mass messages.

Command for ignoring/allowing mass buddy messages: /bmsg ignore

Important Note: This system uses the NPC-Server to send messages between players so it requires you to not have the NPC-Server on ignore. Also, when installing this system, you will need to customize the onCreated() portion to your Control-NPC for when a player logs in since the scripted playerlist automatically removes any new rows that are not a part of the default system when you first log on. It is important that you do this or else the row will not appear when the player right-clicks someone on their playerlist.

PHP Code:
/*
 *Buddy Communication System
 *@author Gambet
 *NOTE: Requires the scripted playerlist
*/

function onActionServerSide(commandbuddyListmessagesender)
{
 if (
command == "sendBuddyMessage")
  {
   for (
pallplayers)
    {
     if (
p.account in buddyList)
      {
       if (
p.level.name != NULL)
        {
         if (
p.client.bmsg_ignore == false//Send message only if user allows mass buddy messages
           
p.sendPM("\nBuddy Message From" SPC sender ":\n\n" replaceText(message"\\n""#b"));
        }
      }
    }
  }
}

function 
replaceText(txtab//replaceText parser-function by DustyPorViva
{
 if (
txt.pos(a) < 0) return txt;
 
 
temp.txtpos txt.positions(a);
 
temp.newtxt txt.substring(0txtpos[0]);
 
 for (
temp.0txtpos.size(); i++) 
  {
   
newtxt @= b;
   
newtxt @= txt.substring(txtpos[i]+a.length(), txt.substring(txtpos[i]+a.length()).pos(a));
  }
  
 return 
newtxt;
}  

//#CLIENTSIDE
function onCreated()
{
 
this.customMenuEntry "Message All Buddies"//Row title
 
 
if (PlayerList_Menu.findtext(this.customMenuEntry) == -1)
  (
"-Playerlist").addCustomMenuEntry(1this.customMenuEntry);   
}

function 
onPlayerChats()
{
 if (
player.chat == "/bmsg ignore"//Toggle between allowing and ignoring mass buddy messages
  
{
   
client.bmsg_ignore = !client.bmsg_ignore;
   
player.chat "Mass Buddy Messages: " @ (client.bmsg_ignore == false "Allowed" "Ignored"); 
  }
 else if (
player.chat.starts("tobuddies:")) //Chat-based mass buddy messages
  
{
   if (
this.bmsg_cooldown <= timevar2)
    {
     
temp.messageToSend player.chat.substring(10);   
     
triggerserver("gui"name"sendBuddyMessage"findPlayerBuddies(), messageToSendplayer.account);
     
player.chat "";
     
this.bmsg_cooldown timevar2 15;
    }
   else
    {
     
player.chat "You can't send another buddy mass for another" SPC int(this.bmsg_cooldown timevar2SPC "second(s)!";
    }
  }
}

function 
PlayerList_Menu.onSelect(entryidtext
{
 if (
text == this.customMenuEntrytoBuddyGUI(); //If user selects 'Message All Buddies'
}

function 
toBuddyGUI()
{
 new 
GuiWindowCtrl("ToBuddy_Window")  
  { 
   
profile GuiBlueWindowProfile
   
= (screenwidth/100); 
   
= (screenheight/2-100); 
   
width 425
   
height 370
   
canclose "false";
   
text "Message To Buddies"
   new 
GuiScrollCtrl("ToBuddy_Scroll")  
    { 
      
profile GuiBlueScrollProfile
      
5
      
22
      
width 413
      
height 305
      
hScrollBar "alwaysOff"
      
vScrollBar "dynamic"
     new 
GuiMLTextEditCtrl("ToBuddy_ScrollText")  
      { 
        
useownprofile true
        
profile "GuiBlueTextProfile"
        
8
        
5
        
height 40
        
width 405
      } 
    }
    new 
GuiButtonCtrl("ToBuddy_CloseButton")  
    { 
     
profile GuiBlueButtonProfile
     
20
     
335
     
width 90
     
height 25
     
text "Close"
    }  
    new 
GuiButtonCtrl("ToBuddy_HistoryButton")  
    { 
     
profile GuiBlueButtonProfile
     
117
     
335
     
width 90
     
height 25
     
text "History"
    }  
    new 
GuiButtonCtrl("ToBuddy_SendButton")  
    { 
     
profile GuiBlueButtonProfile
     
305
     
335
     
width 97
     
height 25
     
text "Send"
    }  
  }
}

function 
ToBuddy_CloseButton.onAction()
{
 
ToBuddy_Window.destroy();
}

function 
ToBuddy_SendButton.onAction()
{
 
temp.messageToSend ToBuddy_ScrollText.text;
 
ToBuddy_Window.destroy();
 
 if (
this.bmsg_cooldown <= timevar2)
  {
   
triggerserver("gui"name"sendBuddyMessage"findPlayerBuddies(), messageToSendplayer.account);
   
this.bmsg_cooldown timevar2 15;
  }
 else
  {
   
player.chat "You can't send another buddy mass for another" SPC int(this.bmsg_cooldown timevar2SPC "seconds!";
  }
}

function 
findPlayerBuddies()
{
 
temp.buddiesOnline ""
 
 for (
pallplayers)
  {
   if (
p.isbuddy)
    {
     if (
buddiesOnline.index(p.account) == -1)
      
buddiesOnline.add(p.account); //Array of user's online buddies
    
}
  }
 
 return 
buddiesOnline;


Edit: Here are some screenshots:




Feel free to customize it as you please.
Attached Thumbnails
Click image for larger version

Name:	bcsscreenshot1.png
Views:	276
Size:	11.0 KB
ID:	48188   Click image for larger version

Name:	bcsscreenshot2.png
Views:	254
Size:	43.9 KB
ID:	48189   Click image for larger version

Name:	bcsscreenshot3.png
Views:	251
Size:	45.0 KB
ID:	48190  

Last edited by Gambet; 04-21-2009 at 06:58 PM.. Reason: There is no reason to link to imageshack
Reply With Quote
  #2  
Old 04-21-2009, 09:10 AM
napo_p2p napo_p2p is offline
oh snaps
napo_p2p's Avatar
Join Date: Sep 2003
Location: Pismo Beach, California
Posts: 2,118
napo_p2p has a spectacular aura aboutnapo_p2p has a spectacular aura about
Send a message via AIM to napo_p2p Send a message via MSN to napo_p2p
I haven't tried it out, but it looks legit to me.

Nice .
__________________
Scito hoc super omnia.
Haec vita est tua una sola.
Dum vita superest, utere maxime quoque puncto, momento, et hora quae habes.
Tempus neminem non manet.
Noli manere tempus.
Carpe Diem

Seize the Day.
Reply With Quote
  #3  
Old 04-21-2009, 09:12 AM
Gambet Gambet is offline
Registered User
Join Date: Oct 2003
Posts: 2,712
Gambet is on a distinguished road
I added some screenshots of the gui-based aspect for people to see what it looks like.
Reply With Quote
  #4  
Old 04-21-2009, 09:55 AM
Tigairius Tigairius is offline
The Cat
Tigairius's Avatar
Join Date: Jan 2007
Location: Missouri, USA
Posts: 4,240
Tigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant future
Cool
__________________


“Shoot for the moon. Even if you miss, you'll land among the stars.”
Reply With Quote
  #5  
Old 04-21-2009, 12:28 PM
fragman85 fragman85 is offline
Banned
Join Date: Mar 2009
Location: Switzerland
Posts: 261
fragman85 is on a distinguished road
Nice, but the problem is that the NPC-Server sends them.
Still, I know, there's no other way
Reply With Quote
  #6  
Old 04-21-2009, 12:37 PM
xXziroXx xXziroXx is offline
Malorian
xXziroXx's Avatar
Join Date: May 2004
Posts: 5,289
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
Or, you could just, hold shift to select all buddies then press enter to send the selected buddies a mass message?
__________________
Follow my work on social media post-Graal:Updated august 2025.
Reply With Quote
  #7  
Old 04-21-2009, 12:45 PM
fragman85 fragman85 is offline
Banned
Join Date: Mar 2009
Location: Switzerland
Posts: 261
fragman85 is on a distinguished road
Quote:
Originally Posted by xXziroXx View Post
Or, you could just, hold shift to select all buddies then press enter to send the selected buddies a mass message?
A lot of my buddys have Mass Messages off

Well, this is no place for this discussion :o
Reply With Quote
  #8  
Old 04-21-2009, 02:30 PM
Unkownsoldier Unkownsoldier is offline
Ignorance has no future
Join Date: Sep 2008
Posts: 1,287
Unkownsoldier is on a distinguished road
That's why if you use, tobuddies: message here, it gives the message to all of them
__________________
Look beyond the monitor.
Reply With Quote
  #9  
Old 04-21-2009, 03:14 PM
fragman85 fragman85 is offline
Banned
Join Date: Mar 2009
Location: Switzerland
Posts: 261
fragman85 is on a distinguished road
Quote:
Originally Posted by Unkownsoldier View Post
That's why if you use, tobuddies: message here, it gives the message to all of them
Could you please first read then post?
Thank you.
Reply With Quote
  #10  
Old 04-21-2009, 03:58 PM
xXziroXx xXziroXx is offline
Malorian
xXziroXx's Avatar
Join Date: May 2004
Posts: 5,289
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
Quote:
Originally Posted by fragman85 View Post
A lot of my buddys have Mass Messages off
So basically it's a script that overrides peoples settings just so you can annoy them with meaningless messages?
__________________
Follow my work on social media post-Graal:Updated august 2025.
Reply With Quote
  #11  
Old 04-21-2009, 04:05 PM
Unkownsoldier Unkownsoldier is offline
Ignorance has no future
Join Date: Sep 2008
Posts: 1,287
Unkownsoldier is on a distinguished road
Quote:
Originally Posted by fragman85 View Post
A lot of my buddys have Mass Messages off

Well, this is no place for this discussion :o

Can you read, I was explaining that there is no reason to give your buddies a mass message when you can do tobuddies:
__________________
Look beyond the monitor.
Reply With Quote
  #12  
Old 04-21-2009, 04:27 PM
fragman85 fragman85 is offline
Banned
Join Date: Mar 2009
Location: Switzerland
Posts: 261
fragman85 is on a distinguished road
I thought you were answering my post, sorry.

Quote the person you're talking to next time
Reply With Quote
  #13  
Old 04-21-2009, 06:18 PM
Gambet Gambet is offline
Registered User
Join Date: Oct 2003
Posts: 2,712
Gambet is on a distinguished road
Quote:
Originally Posted by xXziroXx View Post
Or, you could just, hold shift to select all buddies then press enter to send the selected buddies a mass message?
Quote:
Originally Posted by xXziroXx View Post
So basically it's a script that overrides peoples settings just so you can annoy them with meaningless messages?

You can do the exact same thing to send mass messages but there's a mass message button for mere convenience. This system also has its own ignoring feature to where you can disable the messages yourself if you find them annoying, and it has chat-based functionality if you feel like sending quick messages (aside from the gui-based functionality). With this system, you can ignore mass messages but allow buddy-mass messages so that your buddies can communicate with you more easily and you don't have to worry about having unknown players spamming your messages with useless masses.

Some players requested a system like this and so I made it, I don't see where the attitude is coming from and quite frankly I would expect so much more from you. Please stop derailing the thread from its original intentions, the code itself has a lot of nice pointers that people could use to learn from.

Last edited by Gambet; 04-21-2009 at 07:01 PM..
Reply With Quote
  #14  
Old 04-21-2009, 07:28 PM
Elizabeth Elizabeth is offline
a/s/l
Elizabeth's Avatar
Join Date: Jul 2006
Location: Canada
Posts: 5,018
Elizabeth has much to be proud ofElizabeth has much to be proud ofElizabeth has much to be proud ofElizabeth has much to be proud ofElizabeth has much to be proud ofElizabeth has much to be proud of
Send a message via AIM to Elizabeth
Quote:
Originally Posted by xXziroXx View Post
Or, you could just, hold shift to select all buddies then press enter to send the selected buddies a mass message?
i agree. there's no need for a buddy mass messaging system.
__________________
<3
Reply With Quote
  #15  
Old 04-21-2009, 08:02 PM
Loriel Loriel is offline
Somewhat rusty
Loriel's Avatar
Join Date: Mar 2001
Posts: 5,059
Loriel is a name known to allLoriel is a name known to allLoriel is a name known to allLoriel is a name known to all
It is basically like a reverse twitter
Reply With Quote
  #16  
Old 04-21-2009, 09:12 PM
xXziroXx xXziroXx is offline
Malorian
xXziroXx's Avatar
Join Date: May 2004
Posts: 5,289
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
Quote:
Originally Posted by Gambet View Post
Some players requested a system like this and so I made it
That's fine and all, but...

Quote:
Originally Posted by Gambet View Post
I don't see where the attitude is coming from and quite frankly I would expect so much more from you. Please stop derailing the thread from its original intentions, the code itself has a lot of nice pointers that people could use to learn from.
... I'm still entitled to my own opinion, and I still think this is quite useless. Stop getting so defensive for getting some critique, not everyone is forced to agree with you or approve things you create.
__________________
Follow my work on social media post-Graal:Updated august 2025.
Reply With Quote
  #17  
Old 04-21-2009, 09:25 PM
Gambet Gambet is offline
Registered User
Join Date: Oct 2003
Posts: 2,712
Gambet is on a distinguished road
Quote:
Originally Posted by xXziroXx View Post
... I'm still entitled to my own opinion, and I still think this is quite useless. Stop getting so defensive for getting some critique, not everyone is forced to agree with you or approve things you create.
There's a difference between constructive criticism and derailment and how you chose to word your opinion was out-of-line. I don't need you to approve of the system nor would I care for your approval, I simply made it because some players requested it and figured it wouldn't hurt to give them what they wanted.

The Mass PM button is useless in your standards but is there for convenience. I never stated that this was a necessity but more a commodity that shouldn't bother anyone and definitely shouldn't be shot down because there are some players that would find it beneficial.

Things don't always have to benefit you in particular to be considered useful and it's a shame that you aren't looking at things in context of the players that actually would use it, instead of simply stating that you would never use it and claiming it to be useless. There's nothing wrong with making it easier to do things you can currently do.
Reply With Quote
  #18  
Old 04-21-2009, 09:34 PM
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
Quote:
Originally Posted by xXziroXx View Post
Or, you could just...
Quote:
Originally Posted by xXziroXx View Post
So basically it's...
You're being a jerk.
__________________
Reply With Quote
  #19  
Old 04-21-2009, 11:20 PM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
Neat, never really looked into modifying the scripted Playerlist but I'm more of a external playerlist kinda guy.

There's this way as well (I'd name it.. /buddymass), so long as your buddies don't have mass ignored.

PHP Code:
//#CLIENTSIDE
function onBuddyMass() {
  for (
temp.pallplayers) {
    if (
temp.p.isbuddy)
     
temp.budz.add(temp.p);
  }
  (
"-Playerlist").openPMWindow(temp.budz,false);

__________________
Quote:
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:22 AM.


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