Checking for names in a variable

Posted by Giz on Thu 09 Aug 2007 01:15 AM — 4 posts, 16,736 views.

#0
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
USA #1
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.
Australia Forum Administrator #2
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

#3
That works perfectly thanks nick


/Giz