Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUSHclient ➜ VBscript ➜ Friends/Enemies list

Friends/Enemies list

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Penquin   (7 posts)  Bio
Date Sat 28 Aug 2004 06:22 AM (UTC)
Message
Hi agian, i am looking for a script or pluigin that will take the name of someone and put it into an array or fle, and every time it sees that name it will color it a diffrent color i want it to be able to automaticlyl add people from a certain channle so..
(channel) soandso says, "blahabhal." it should get the sosandso and add them to the list. can anyone help with this, thanks in advanced
Top

Posted by Flannel   USA  (1,230 posts)  Bio
Date Reply #1 on Mon 30 Aug 2004 03:34 AM (UTC)
Message
Make a trigger (two, one for friends, one for enemies) that matches on "(@!enemylist)" and another that matches on "(@!friendlist)" then you need to make that trigger regexp, expandvariables, and change its color.

Then you make a second set of triggers to catch the channel (the one that blocks people) and then send this (to script):
setvariable "friendlist", getvariable("friendlist") & "|%#"

where %# is the %1 or whatever that the name is.
Do that for enemies too, but change friendlist to enemylist.

You'll need to start the variable, with just a name.

The variable should be in the format of this:
name1|name2|name3|name4
however long you need it to be.

~Flannel

Messiah of Rose
Eternity's Trials.

Clones are people two.
Top

Posted by Penquin   (7 posts)  Bio
Date Reply #2 on Mon 13 Sep 2004 01:09 AM (UTC)
Message
Hello, i knida got the jist of what you are saying, however the Trigger(s) dont work. I did what you said, at least i think i did, do you think you can run it by me one step at a time eh? thanks
Top

Posted by Flannel   USA  (1,230 posts)  Bio
Date Reply #3 on Mon 13 Sep 2004 01:22 AM (UTC)
Message
heres an example:

<variables>
<variable name="friendlist">bob|joe</variable>
</variables>

<triggers>
<trigger
custom_colour="14"
enabled="y"
expand_variables="y"
ignore_case="y"
keep_evaluating="y"
match="(@!friendlist)"
regexp="y"
repeat="y"
sequence="100"
>
</trigger>
</triggers>

that will match (and change color, so you know) on joe or bob (and since its a simple regexp, itll match on joey, or bobo, but you can change the trigger to reflect real words. But just insert (@!friendlist) in a trigger (regexp, and expand variables) and itll act as if that variable is inside the trigger itself.

Then you just append "|friendname" to the end of your variable list:
setvariable "friendlist", getvariable("friendlist" & "|%1")

~Flannel

Messiah of Rose
Eternity's Trials.

Clones are people two.
Top

Posted by Metsuro   USA  (389 posts)  Bio
Date Reply #4 on Mon 13 Sep 2004 04:48 PM (UTC)
Message
While were on this subject, would it be possible to add a job to each name then check a who list to see if they are on or not, and if they are to display them on a note?

Everything turns around in the end
Top

Posted by Flannel   USA  (1,230 posts)  Bio
Date Reply #5 on Mon 13 Sep 2004 08:48 PM (UTC)
Message
Job... What do you mean?

But, yes, it is possible (even without really knowing what you mean). Just set the trigger to catch, and then note it. The trigger itself becomes a check (either it matches, or it doesnt).

~Flannel

Messiah of Rose
Eternity's Trials.

Clones are people two.
Top

Posted by Metsuro   USA  (389 posts)  Bio
Date Reply #6 on Mon 13 Sep 2004 10:46 PM (UTC)
Message
I meant, to assign each person somthing, like you have all the names it checks the name, and if they are on, to set them in a vairable with the job they do, or something like that the thing is to check the who see if someones on, then send a message back with all who are on with what they do.

blah tells you, "Merchwho."

You tell blah, "All merchants on right now and what they do are, Blah cook | Blah Smith." and so forth

Everything turns around in the end
Top

Posted by Metsuro   USA  (389 posts)  Bio
Date Reply #7 on Wed 20 Oct 2004 01:29 AM (UTC)
Message
Anyway to get an alias to be able to remove someones name from the list?

Everything turns around in the end
Top

Posted by Flannel   USA  (1,230 posts)  Bio
Date Reply #8 on Thu 21 Oct 2004 12:45 AM (UTC)

Amended on Thu 21 Oct 2004 04:47 AM (UTC) by Flannel

Message
You'd have to search through to find the person, and then remove them.
You could either code your own search (to find your |'s) and then pattern match, and use mid to cut the string into thirds (before, after, and then your target name) and then splice the first two together.
Or, you can use split to make an array out of them, find the value, and then recompile that array back into a pipe seperated list.

Edit:
You dont need to code your own search, you can use InStr.

~Flannel

Messiah of Rose
Eternity's Trials.

Clones are people two.
Top

Posted by Metsuro   USA  (389 posts)  Bio
Date Reply #9 on Sun 16 Jan 2005 06:39 AM (UTC)
Message
Well after trying and not figuring this out for quite some time now, i would like to ask for an example of this, of how to remove someone from the list if someone would be so kind.

Everything turns around in the end
Top

Posted by Ked   Russia  (524 posts)  Bio
Date Reply #10 on Mon 17 Jan 2005 04:51 AM (UTC)
Message
It's quite a pain to do in vbscript actually, so the best suggestion would be to use a language with decent string operations, dynamic list support, and slicing, Python will do :) But it would go somewhere along those lines (not so sure about syntax):


dim strText
strText = "Friend1|Friend2|Friend3|Friend4|Friend5"

function removeName(strName)
dim arrName, found, ind, i, arrFinal()
arrName = split(strText, "|")
found = vbFalse
ind = 0

for each i in arrName do
   if i = strName then
      found = vbTrue
   end if
   if not found then
      Redim Preserve arrFinal(ind)
      arrFinal(ind) = i
      ind = ind + 1
   end if
next

removeName = join(arrFinal, "|")
end function


I give no guarantees that this will work at all, but don't have time to test it. The basic idea is to use a static array filled with actual names (using split()) and a dynamic array, which is gradually expanded to include all names from the first array except the one you want to exclude. Once the dynamic array is full, and we've reached the end of the static one, we join the dynamic array back into a "|" separated string and return it. But as vbscript sucks really badly for these sorts of operations, you might have to tweak it to get it to work.
Top

Posted by Ked   Russia  (524 posts)  Bio
Date Reply #11 on Mon 17 Jan 2005 04:58 AM (UTC)

Amended on Mon 17 Jan 2005 05:00 AM (UTC) by Ked

Message
And oh, in Python the whole thing would've been:


strText = "Friend1|Friend2|Friend3|Friend4|Friend5"

def removeName(name): 
   arr = strText.split("|")
   if name in arr:
      return arr.remove(name).join("|")


Having tried to deal with strings in vbs, I just can't help but advertise ways to keep ones sanity intact.
Top

Posted by Flannel   USA  (1,230 posts)  Bio
Date Reply #12 on Mon 17 Jan 2005 05:04 AM (UTC)

Amended on Mon 17 Jan 2005 05:14 AM (UTC) by Flannel

Message
Instead of all of that, what about replacing the persons name with "" and then searching for double bars and replacing those with a single.

That solves the |name|. You'd end up with name1||name3 and that'd be replaced with name1|name3.

I suppose you'd have to check for a | on either end as well. Because name1|name2 would become |name2 or name1| which wouldn't work.

So, that would make it...

(assuming "search" is a VBscript variable for the thing to be searched for, and "list" is a vbscript variable of the list)

list = Replace(list,search,"")
list = Replace(list,"||","|")
If (Left(list,1) = "|")
list = Right(list,Len(list)-1)
End If
If (Right(list,1) = "|")
list = Left(list,Len(list)-1)
End If

Think that's right. Let me know if it isn't.

~Flannel

Messiah of Rose
Eternity's Trials.

Clones are people two.
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


32,414 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.