 |
trpstrife Novice
Joined: 26 Jul 2005 Posts: 34
|
Posted: Mon Sep 26, 2005 7:49 pm
attempting to make a buddy list |
Ok Basicly what I'm trying to is create a buddy list built right into zmud.
What I need is a way that the user to can add a person to a list of other people.
EX add player3 to buddy list
This would add a third player to a list of players.
The other catch is showing them on or offline. which would be done thru a trigger like
Inform: player 3 has entered Merentha.
or
Inform: player 3 has left Merentha.
How would i go about creating this list so people can easily be added/removed to it thru an alias or trigger, without overwritting all the previous information? |
|
|
 |
Vijilante SubAdmin

Joined: 18 Nov 2001 Posts: 5182
|
Posted: Mon Sep 26, 2005 8:52 pm |
#ALIAS BudAdd {#ADDITEM BuddyList {%-1}
I am not really sure where your going with the online.offline thing as this is likely to require a method of first synchonising the list of online persons. After that you can simply trigger to #ADDITEM or #DELTITEM from the online list. |
|
_________________ The only good questions are the ones we have never answered before.
Search the Forums |
|
|
 |
MattLofton GURU
Joined: 23 Dec 2000 Posts: 4834 Location: USA
|
Posted: Mon Sep 26, 2005 9:04 pm |
I'd use a datarecord variable and use #addkey/#delkey.
#variable buddylist {}
#trigger {Inform: (*) has entered Merentha.} {#if (%iskey(@buddylist,%1)) {#addkey buddylist %1 "online";Showbuddies}}
#trigger {Inform: (*) has left Merentha.} {#if (%iskey(@buddylist,%1)) {#addkey buddylist %1 "offline";Showbuddies}}
Then you can use an alias to show the buddylist in another window (I don't think you'd want to have it spam the main window):
#alias ShowBuddies {:BuddyListWindow:#clr;:BuddyListWindow:#say Buddies in Merentha;#loopdb @BuddyList {#if (%val = "online") {:BuddyListWindow:%key}};:BuddyListWindow:#cr;:BuddyListWindow:#say Buddies not in Merentha;#loopdb @BuddyList {#if (%val = "offline") {:BuddyListWindow:%key}}}
ShowBuddies will display all your buddies in two groups (those online, and those offline).
To add and remove buddies, you can use a couple aliases:
#alias AddBuddy {#if (%iskey(@buddylist,%1)) {#say This person is already on your buddy list!} {#say %1 added to your buddy list;#addkey buddylist %1 %2;Showbuddies}}
#alias RemoveBuddy {#forall %replace(%1," ","|");#if (%iskey(@buddylist,%i)) {#say This person is not on your buddy list!} {#say %1 removed from your buddy list;#delkey buddylist %i;Showbuddies}}
AddBuddy will only let you add one person at a time, while RemoveBuddy will allow you to remove multiple people at a time. Also, AddBuddy requires you to specify the status of the buddy to be added. |
|
_________________ EDIT: I didn't like my old signature |
|
|
 |
trpstrife Novice
Joined: 26 Jul 2005 Posts: 34
|
Posted: Mon Sep 26, 2005 9:30 pm |
Very cool. Regreatably the remove buddies doesn't seem to work. it also does the show buddies even if it isn't a buddy that logs on.
|
|
|
 |
MattLofton GURU
Joined: 23 Dec 2000 Posts: 4834 Location: USA
|
Posted: Tue Sep 27, 2005 1:53 am |
I'm thinking you didn't copy the entire line for each trigger. Simply move the ShowBuddies alias from outside of the curly brackets to the inside like I had them:
#IF (condition to check) {
#ADDKEY stuff
ShowBuddies
}
If that's how it looks already, seems there's a bug with %iskey() |
|
_________________ EDIT: I didn't like my old signature |
|
|
 |
trpstrife Novice
Joined: 26 Jul 2005 Posts: 34
|
Posted: Tue Sep 27, 2005 1:44 pm |
ok really stupid question. is their a code that can take a variable, record its value so so permenantly stored somehow but still allow the variable to change? kinda like if the varaible is a counting up. each time it goes up it saves the number somehow but continues to count up?
Or is it possible to have a variable store more than one value such as
a name, a number, and a word. |
|
|
 |
MattLofton GURU
Joined: 23 Dec 2000 Posts: 4834 Location: USA
|
Posted: Tue Sep 27, 2005 8:56 pm |
Yep, it's possible. It's called a stringlist, and it can be the value of a datarecord key. They're a bit harder to work with if you want information out of them, though.
|
|
_________________ EDIT: I didn't like my old signature |
|
|
 |
|
|