PtokaX forum

Archive => Archived 4.0 boards => Request for Lua 4 scripts => Topic started by: VERMiN on 02 November, 2003, 10:47:30

Title: Check ISP in NickName?
Post by: VERMiN on 02 November, 2003, 10:47:30
I have script that check every newuser that their nickname include a proper ISP. The format is [ISP]NickName. But I only know how to check the string for the word (example) [TELIA] and _not_ that it really begins with it.

--->

for key, value in GOODISP do

   if (strfind(strlower(curUser.sName), strlower(value),1,1)) then
         x=1
         break
            else
            x=0
      end
   end

--->

so if a user logs-in with EvilTerry[TELIA] he will be accepted :(

So how can I check that a nickname BEGINS with [ISP] ?

"GOODISP" is a string containing about 15 different ISP names.
Title:
Post by: tezlo on 02 November, 2003, 13:58:48
GOODISP looks more like a table..
if it were associative this could be easier

local s, e, tag = strfind(user.sName, "^(%b[])")
if tag then
   tag = strlower(tag)
   for id, name in GOODISP do
      if tag == name then return end
   end user:SendData("*** Invalid tag")
end user:SendData("*** No tag")
user:Disconnect()