PtokaX forum

Archive => HOW-TO's => Archived 5.1 boards => Old HOW-TO's => Topic started by: ??']['??l? on 23 August, 2006, 12:31:13

Title: How to make protection table to scripts??
Post by: ??']['??l? on 23 August, 2006, 12:31:13
How can i add protection to lua 5.0x scripts like in robocop exe...
That you can choose which profile is allowed to use command to another profile!

for example netfounder is allowed to mute master..
but when master tries to mute netfounder, then that user gets message: You are not allowed to use this command to netfounders... or
                                                                                                   This user is too powerful to be (command you tried to use)

And it would be even better if that command would come back to that user who tried use it to higher or protected profile... :D :D :D
Title: Re: How to make protection table to scripts??
Post by: bastya_elvtars on 23 August, 2006, 12:45:47
If you have coding intent, check the LawMaker source code which has this kind of protection built-in (for instance the kickban plugin uses it a lot).
Title: Re: How to make protection table to scripts??
Post by: bINKbINK on 23 August, 2006, 13:04:08
have a look at FunnyChat script either
it has just the same protection system you're looking for ;) (view Settings.txt, for example)
you can choose who can mute or kennylize as well as who will be affected by the script and who not. of course with the notify as you described
Title: Re: How to make protection table to scripts??
Post by: Cêñoßy†ê on 23 August, 2006, 17:11:45
small example  ;D

Code (lua) Select
Command["kick"] = function(user,data,where)
local s,e,Name,rsn = string.find(data, "%b<>%s+%S+%s+(%S+)%s*(.*)")
if (rsn==nil or rsn == "") then rsn = "No reason given!" end
local victim = GetItemByName(Name)
if victim ~= nil then
if ProtectionTable[user.iProfile][victim.iProfile] == 0 then
user:SendData(Settings["Script"]["BotName"],"You silly mortal... you cant kick ["..ProfileName(victim.iProfile).."] with that profile!!!")
else
if KickTable[victim.sName] == 3-1 then
victim:SendData(Settings["Script"]["BotName"],"*** You are Permanently banned because: 3x Kicked !")
SendMessage("*** User "..victim.sName.." Banned because: 3x kicked !",SendWhere)
victim:Ban()
victim:NickBan()
victim:Disconnect()
KickTable[victim.sName]= nil
else
victim:SendPM(Settings["Script"]["BotName"],ProfileName(user.iProfile).." "..user.sName.." just kicked your silly ass Because: "..rsn)
SendMessage("*** "..victim.sName.." from "..victim.sIP.." got Kicked in the ass by "..ProfileName(user.iProfile).." "..user.sName.." Because: "..rsn,SendWhere)
UpdateBad(victim,KickTable)
victim:TimeBan(5)
victim:Disconnect()
end end end return 1 end



ProtectionTable = {
[0] = {
[0] = 1,
[1] = 1,
[2] = 1,
[3] = 1,
[4] = 1,
[5] = 1,
[6] = 0,
[-1] = 1,
},
[1] = {
[0] = 0,
[1] = 0,
[2] = 1,
[3] = 1,
[4] = 0,
[5] = 0,
[6] = 0,
[-1] = 1,
},
[2] = {
[0] = 0,
[1] = 0,
[2] = 0,
[3] = 0,
[4] = 0,
[5] = 0,
[6] = 0,
[-1] = 0,
},
[3] = {
[0] = 0,
[1] = 0,
[2] = 0,
[3] = 0,
[4] = 0,
[5] = 0,
[6] = 0,
[-1] = 0,
},
[-1] = {
[0] = 0,
[1] = 0,
[2] = 0,
[3] = 0,
[4] = 0,
[5] = 0,
[-1] = 0,
},
}