[Home] [Downloads] [Search] [Help/forum]


Register forum user name Search FAQ

Gammon Forum

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  VBscript
. . -> [Subject]  Checking for names in a variable

Checking for names in a variable

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


Posted by Giz   (10 posts)  [Biography] bio
Date Thu 09 Aug 2007 01:15 AM (UTC)
Message
Hi Im quite new to scripting been doing it awhile and i've managed to get what i needed working but now i run into a wall.

what i want to do is with a script cast def spells on people comming and asking for it but only to people in the variable

this is what i've been trying to do but it wont work:
sub doRess (name, output, argv)

Dim who
Dim friends
Dim friendlist

who = argv(1)
friends = World.getVariable ("friends")
friendlist = Split(friends,"|")

if who = ("friendlist") then
World.Send "cast summon player ghost " & who & " "
World.doAfter 3, "cast resurrect " & who & " "
World.doAfter 5.2, "cast lolths sanctification " & who & " "

else
world.send "tell " & whot & " sorry no ress"
End if
End sub

any suggestions?


/Giz
[Go to top] top

Posted by David Haley   USA  (3,881 posts)  [Biography] bio
Date Reply #1 on Thu 09 Aug 2007 01:25 AM (UTC)
Message
One thing that would be helpful is to explain more precisely why it's not working; just saying "it doesn't work" doesn't let us help you very, well, helpfully. :)

You should try looking into the InStr function to see if one string is in another, though.

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
[Go to top] top

Posted by Nick Gammon   Australia  (22,989 posts)  [Biography] bio   Forum Administrator
Date Reply #2 on Thu 09 Aug 2007 05:59 AM (UTC)
Message
Your variable friendlist is an array, after you create it with Split.

Thus, you want something along these lines to see if a name is in it:


isfriend = vbFalse

For Each name In friendlist
  If who = name Then
    isfriend = vbTrue
  EndIf
Next

If isfriend Then
  Send "cast summon player ghost " & who & " "
  DoAfter 3, "cast resurrect " & who & " "
  DoAfter 5.2, "cast lolths sanctification " & who & " "
Else
  Send "tell " & who & " sorry no ress"
EndIf


- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Giz   (10 posts)  [Biography] bio
Date Reply #3 on Thu 09 Aug 2007 11:52 AM (UTC)
Message
That works perfectly thanks nick


/Giz
[Go to top] 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.


11,543 views.

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

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

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

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at HostDash]