PtokaX forum

Development Section => Your Developing Problems => Topic started by: kepp on 09 November, 2003, 19:51:13

Title: Protect my op's
Post by: kepp on 09 November, 2003, 19:51:13
      elseif (cmd=="+ban") or (cmd=="?ban") then
              s,e,cmd,Name,reason = strfind(data,"%b<>%s+(%S+)%s+(%S+)%s*(.*)")
           rsn = reason

              if victim ~= nil then
                    SendToAll(BotName, user.sName.." banned "..victim.sName..", Reason: "..rsn)
            victim:SendPM(BotName, "You are banned by: "..user.sName..", Reason: "..rsn)
           victim:Ban() return 1
             else
     user:SendData("*** User is not in the list.") return 1 end

I want to protect OP's in this code from being banned...
Questions is: How would i do that...?
I've tried the same way as i did with if the user dosen't exist, but that will just block other things or nothing will happen at all.

Thanks
Title:
Post by: Neo on 12 November, 2003, 16:59:28
Try this:
elseif (cmd=="+ban") or (cmd=="?ban") then
              s,e,cmd,Name,reason = strfind(data,"%b<>%s+(%S+)%s+(%S+)%s*(.*)")
           rsn = reason
if victim~=nil then
if victim.bOperator then
user:SendData("*** You can't ban a OP")
victim:SendData("*** User "..user.sName.." has tried to ban you!!!")
return 1
else
                        SendToAll(BotName, user.sName.." banned "..victim.sName..", Reason: "..rsn)
            victim:SendPM(BotName, "You are banned by: "..user.sName..", Reason: "..rsn)
            victim:Ban() return 1
end
        else
      user:SendData("*** User is not in the list.") return 1
end
Title: :D
Post by: kepp on 15 November, 2003, 22:34:40
Thanks alot Neo!!
Title:
Post by: kepp on 15 November, 2003, 22:39:24
elseif (cmd=="?addmaster") or (cmd=="!addmaster") or (cmd=="+addmaster") then
          s,e,cmd,newuser,pass = strfind(data,"%b<>%s+(%S+)%s+(%S+)%s+(.+)")

      ProFile = GetProfileName(0)
      AddRegUser(newuser, pass, 0)
      user:SendData(BotName, newuser.." Was sucessfully added as a "..ProFile) return 1

How would i do to send a pm to the user that i added?
I tried, and it worked, Untill i tried with a user that was not there, And it gave me a nil value
Title: SIMPLE!!!
Post by: Neo on 17 November, 2003, 15:33:37
write this: (it's very simple)

SendPmToNick(newuser,BotName,"HERE MESSAGE")

where

newuser is the variable that you have spicified here :"s,e,cmd,newuser,pass = strfind(data,"%b<>%s+(%S+)%s+(%S+)%s+(.+)")"

BotName is your bot

"HERE MESSAGE" is the message you would send to.

Then syntax is :
SendPmToNick(whoto,from,mex)

Check scripting.txt in doc folder of ptokax...

Byez!!!
Title:
Post by: kepp on 17 November, 2003, 16:00:22
he he, Ok :)

Thanks alot!

I tried with:
newuser:SendPM(BotName, "Bla bla bla")

But SendPmToNick solved the problem! :D