PtokaX forum

Archive => Archived 4.0 boards => Help with Lua 4 scripts => Topic started by: Snoris on 23 July, 2004, 12:39:27

Title: Prefixes
Post by: Snoris on 23 July, 2004, 12:39:27
Sorry but I must be dumb =)

prefix = "!","+","?","?"
if cmd==""..prefix.."myip" then
user:SendData("Power?","Your IP is: "..user.sIP.."")
return 1
end


How do I make this thing working??
Wanna have multiple prefixes for the whole script...So its not just this little part...Just so ANYONE can help me with this =)

Also tried with
prefix = {"!","+","?","?"}
if cmd==prefix.."myip" then
user:SendData("Power?","Your IP is: "..user.sIP.."")
return 1
end
But that didnt work either...As I said...I must be dumb =)
Plz help me
Title:
Post by: nErBoS on 23 July, 2004, 14:34:33
Hi,

It should be the second one, but you need to run all array and find the prefix used by the user for eg...

prefix = { "!", "+", "?", "?" }

for i = 1, getn(prefix) do
if cmd==prefix[i].."myip" then
user:SendData("Power?", "Your IP is: "..user.sIP)
return 1
end
end

Best regards, nErBoS
Title:
Post by: Typhoon on 23 July, 2004, 20:43:29
this one does the same ..
cheers to plop for the help a while back with this

just ripped from my script but you'll get the idea ..


Tprefix = { ["+"]=1 , ["!"]=1 , ["-"]=1 } --- you know ;)


-- command part now !
local s,e,prefix = strfind(data, "%b<>%s*(%S)")
if Tprefix[prefix] then
   local s,e,cmd=strfind(data, "%b<>%s*%S(%S+)")
   if cmd == "myip" then
           user:SendData(BotName, "Your IP is *** "..user.sIP)
   end  
end


-Typhoon?