PtokaX forum

Development Section => Your Developing Problems => Topic started by: rstandley on 25 March, 2004, 23:48:09

Title: my bot
Post by: rstandley on 25 March, 2004, 23:48:09
i have been reading through the how to make your own bot threads and have come to some problems i have made my basic bot with basic kick and ban commands but.... how do i make it so only an op can use them and see the commands as any old user can kick at the moment
Title:
Post by: kepp on 25 March, 2004, 23:55:08
by using if user.iProfile

Each profile has an identical index, such as an OP has 1
Master has 0
VIP has 2
Reg has 3
unreg has -1

so, to prevent other users from being able to use your commands, you can check it with

if user.iProfile ~= 0 or user.iProfile ~= 1 then
    user:SendData("YOu are not allowed to use this command")
else
    --// Todo
end

"==" <-- Equal   "~="   <--- The opposit, Not equal

Have Fun ;)
Title:
Post by: rstandley on 26 March, 2004, 00:08:09
ok that looks like it makes sence but as im still newbie at this.... you say i need that in my script but do i need that in each section of kick ban and temp

elseif (cmd==prefix.."kick") then
         s,e,cmd,whotokick = strfind(data,"%s+(%S+)%s+(%S+)")
         if whotokick == nil then
            return 1
         else
            user = GetItemByName(whotokick)
            user:Disconnect() --without tempban
         end
      elseif (cmd==prefix.."temp") then
         s,e,cmd,whotokick = strfind(data,"%s+(%S+)%s+(%S+)")
         if whotokick == nil then
            return 1
         else
            user = GetItemByName(whotokick)
            user:TimeBan(TimeToBan) --ban for specified
         end
      elseif (cmd==prefix.."ban") then
         s,e,cmd,whotokick = strfind(data,"%s+(%S+)%s+(%S+)")
         if whotokick == nil then
            return 1
         else
            user = GetItemByName(whotokick)
            user:Ban() --perm ban




thats what i have for kick commands so would i need your command in each section or?????
Title:
Post by: kepp on 26 March, 2004, 06:34:02
I hope this helps you a little bit on the way

suppose you have something like this..

function DataArrival(user, data)
if strsub(data,1,1)=="<" then
data=strsub(data,1,strlen(data)-1)
s,e,cmd = strfind(data,"%b<>%s+(%S+)")
if user.bOperator then --This line here would now be used +kick and +ban
if (cmd=="+kick") then
--// Todo
elseif (cmd=="+ban") then
--Todo
end
end
if user.iProfile == 2 or user.iProfile == 3 then
if (cmd=="+lol") then
--//todo
elseif (cmd=="+hehe") then
--//todo
end
end
end
end
Title:
Post by: rstandley on 26 March, 2004, 09:25:00
thats done the trick thanx mate
Title:
Post by: gazzer on 26 March, 2004, 17:12:55
oh great gods of lua (i mean r-standishley)
now ya mastering lua with aid from these cool guys.
how about fixing the damm triv bot lol