PtokaX forum

Development Section => Your Developing Problems => Topic started by: Madman on 24 June, 2004, 21:16:57

Title: HowTo make a "Victim" function?
Post by: Madman on 24 June, 2004, 21:16:57
i want to know how to make a vitim function...
like the !kick command...

Something like
if !cmd then
SendToAll (Bot, " "..curUser.sName.." comands "...victim.sName.." to go to hell!")

Hope i Explained good.....It is a little hard to explain...

*edit*
forgot something... If the nick of the user is not writen exactly right the bot wont say anything....
Title:
Post by: plop on 24 June, 2004, 22:28:38
check the howto section of the board.
specialy the lessons.

plop
Title:
Post by: Troubadour on 25 June, 2004, 06:59:05
if (cmd == "!victim" ) then
_,_,cmd,vicname = strfind( data, "%b<>%s+(%S+)%s+(.+)" )
SendToAll (Botname, " "..user.sName.." commands "..vicname.." to go to hell!")
return 1

I did NOT check it (this is just an example)
Title:
Post by: [UK]Madman on 25 June, 2004, 14:21:49
GetIemByName(vicname)

Can check if username is currently online
Title:
Post by: NightLitch on 25 June, 2004, 14:46:10
--// call command
if cmd=="!anything" then
--// parse the data string to catch the "victim" nick
  local s,e,victim = strfind(data, "%b<>%s+%S+(%S+)")
--// if no victim nick entered then return syntax message
  if victim==nil then
    user:SendData(Bot, "Syntax: !anything ")
    return 1
  end
--// check if nick/user is online
  vUser = GetItemByName(victim)
  if not vUser then
    user:SendData(Bot, victim.." is not online or not wrong name...")
    return 1
  end
--// do the "warn" "kick" "ban" whatever code here...
  SendToAll(Bot, vUser.sName.." have benn banned by "..user.sName)
  vUser:SendData(Bot, You have been Banned!")
  vUser:Ban()
end

This should not be hard understanding...

/NL
Title:
Post by: Madman on 05 September, 2004, 18:47:31
First of all, thanks to NightLitch that gave me the code...
I have added some stuff to the code... Just thought i would share it... Maybe someone can find it usefull =)

--//User To send Text 2 (victim function)
-- 1=on / 0=off
SendTo = {
[0] = 0,   -- Masters
[1] = 1,   -- Operators
[2] = 1,   -- Vips
[3] = 1,   -- Regs
[4] = 0,   -- Moderator
[5] = 0,   -- NetFounder
[-1] = 1,  -- Users
}

--//victim funtion
--// call command
if cmd == "!throw" then
--// parse the data string to catch the "victim" nick
  local s,e,victim = strfind(data, "%b<>%s+%S+%s+(%S+)")
--// if no victim nick entered then return syntax message
  if victim == nil then
  curUser:SendData(Bot, "Syntax: !throw nick")
   return 1
  end
--// check if nick/user is online
  vUser = GetItemByName(victim)
  if not vUser then
    curUser:SendData(Bot, " *** " ..victim.." is not online or wrong name...")
    return 1
  end
  --//Check if you is victim
  if curUser.sName == vUser.sName then
  curUser:SendData(Bot, "Why throw your self?")
  return 1
  end
  --//Safe Function 4 Ops
if vUser.bOperator then
--//Send sendData To Users in Send To List (in the begining....)
if (SendTo[curUser.iProfile]==1) then
curUser:SendData(Bot, "You Are Not Allowd To Throw Ops!")
--//But if master or higher, throw user and skip above text... Mohaha! Evil!
elseif (curUser.iProfile == 0) and (vUser.bOperator) then
--// do the "Throw" code here...
SendToAll(Bot, vUser.sName.." has been thrown out of the hub by "..curUser.sName)
  vUser:SendData(Bot, "You have been thrown out of the hub by "..curUser.sName.."!")
  vUser:Disconnect()
  end
  --//End of Safe function
else
--// do the "Throw" code here...
SendToAll(Bot, vUser.sName.." has been thrown out of the hub by "..curUser.sName)
  vUser:SendData(Bot, "You have been thrown out of the hub by "..curUser.sName.."!")
  vUser:Disconnect()
end
end
--//End of vicim function