PtokaX forum

Archive => Archived 4.0 boards => Help with Lua 4 scripts => Topic started by: Robban on 18 September, 2004, 11:18:16

Title: Help whit prefix script
Post by: Robban on 18 September, 2004, 11:18:16
This script only let user to connect if they got [Prefix] in thier nick. But It got one little problem that I hope someone can correct for me.

I only want users whit nick [Prefix]Nickname to join. But now users whit nickname like Nickname[Prefix] can join.

I notice one more thing now... I want the Prefix that I added always should be at the first. I got a new user in my hub whit name [BBB][10Mbit]Nickname but I want the script to tell him thats wrong nickname and he most use [10Mbit] first.

-- Made by dEFiNE
BotName = "-Bot-"
ISP = {"[100Mbit]","[10Mbit]","[8Mbit]","[5Mbit]","[2.5Mbit]","[2Mbit]","[1Mbit]","[0.8Mbit]","[0.5Mbit]","[0.4Mbit]","[0.2Mbit]","[0.1Mbit]"}

-- Main Sub
function Main()
frmHub:RegBot(BotName)
end


function NewUserConnected(curUser)

for key, value in ISP do --Loop ISP Array
if (strfind(strlower(curUser.sName), strlower(value),1,1)) then  
x=1
break
else
x=0
end
end

if (x == 0) then
-- Kick user
curUser:SendPM(BotName, "")
curUser:SendPM(BotName, "Your nick should includ one of this [100Mbit] or [10Mbit] or [8Mbit] or [5Mbit] or [2.5Mbit] or [2Mbit] or [1Mbit] or [0.8Mbit] or [0.5Mbit] or [0.4Mbit] or [0.2Mbit] or [0.1Mbit]")
curUser:SendPM(BotName, "Change your nick so it display your upload speed. Like this [0.8Mbit]Nickname, Then you are welcome back!")
curUser:SendPM(BotName, "Not working? Look here - [URL]http://www.hompage.com[/URL] -")
curUser:Disconnect()
end

end

Title:
Post by: UwV on 18 September, 2004, 11:52:47
did you read this ?

http://board.univ-angers.fr/thread.php?threadid=763&boardid=4&styleid=1

tutorial by plop...
Title:
Post by: nErBoS on 18 September, 2004, 15:39:05
Hi,

Try out this...

-- Made by dEFiNE
-- Mod by nErBoS asked by Robban

BotName = "-Bot-"

ISP = {
"[100Mbit]",
"[10Mbit]",
"[8Mbit]",
"[5Mbit]",
"[2.5Mbit]",
"[2Mbit]",
"[1Mbit]",
"[0.8Mbit]",
"[0.5Mbit]",
"[0.4Mbit]",
"[0.2Mbit]",
"[0.1Mbit]"
}

function Main()
frmHub:RegBot(BotName)
end


function NewUserConnected(curUser)
if (ValidateNick(curUser) == 0) then
curUser:SendData(BotName, "Your nick should includ one of this [100Mbit] or [10Mbit] or [8Mbit] or [5Mbit] or [2.5Mbit] or [2Mbit] or [1Mbit] or [0.8Mbit] or [0.5Mbit] or [0.4Mbit] or [0.2Mbit] or [0.1Mbit]")
curUser:SendData(BotName, "Change your nick so it display your upload speed. Like this [0.8Mbit]Nickname, Then you are welcome back!")
curUser:SendData(BotName, "Not working? Look here - [URL]http://www.hompage.com[/URL] -")
curUser:Disconnect()
end
end

function ValidateNick(curUser)
if (strfind(curUser.sName, "%b[]%b[]%S+")) then
curUser:SendData(BotName, "You can't have two prefixes.")
return 0
else
for key, value in ISP do
if (strlen(curUser.sName) >= strlen(value) and strsub(strlower(curUser.sName),1,strlen(value)) == strlower(value)) then  
return 1
end
end
end
return 0
end

Best regards, nErBoS
Title: Or try this,
Post by: bastya_elvtars on 19 September, 2004, 09:43:53
this can do the job either...

-- NickLaw by bastya_elvtars (the rock n' roll doctor)
-- thx to Mutor for AllowNicks 1.0
-- ripped from LawMaker

---------- CONFIG PART

-- the next option defines who GET prefix checked, if checknick is set to 1.
cnlevel=3               -- 5:all users
                                -- 4 ops & below
                                -- 3 vips & below
                                -- 2 registered users & below
                                -- 1 guests only

--  what prefixes can be used?
-- format: [PREFIX] or (PREFIX) or {PREFIX}
-- note that check is case sensitive, so [hun] is not equal to [HUN]
-- don't forget the comma! "(blahblah)",

pref ={
"[HUN]",
"[EU]",
"(HUN)",
}

----------END OF CONFIG PART

function DataArrival(user,data)
if strsub(data, 1, 13) == "$ValidateNick" then
local sdata=strsub(data,1,strlen(data)-1)
local _,_,nm=strfind(sdata,"$ValidateNick%s+(%S+)")
determineprefix(nm)
end
end

function NewUserConnected(user)
if CheckUserLevel(user) <= cnlevel then
if checkprefix(user)=="shit" then return 1 end
end
end

function determineprefix(data)
_,_,prefix = strfind(data, "^([%[%{%(]%S+[%)%}%]])")
end


function checkprefix(user)
local p=function()
local mess="\r\n====================\r\n"
sort(pref)
for b=1,getn(pref)do
mess=mess..pref[b].."\r\n"
end
mess=mess.."====================\r\n\r\nNote that the check is case sensitive, a.k.a. [prefix] and [PREFIX] are different."
return mess
end
-- checks the prefix
if not prefix then
user:SendData("NickNameCheck", "\r\nNo prefix specified, use one of these:"..p())
user:Disconnect() return "shit"
end
end

function CheckUserLevel(user)
if user.iProfile==0 then
return 5
elseif user.iProfile==1 then
return 4
elseif user.iProfile==3 then
return 2
elseif user.iProfile==2 then
return 3
else
return 1
end
end
Title:
Post by: Robban on 19 September, 2004, 17:39:41
Thx for all repaly :)

I got another reqest for this script... If some wants to help to add slotrule for every prefix...

Like if someone have prefix [0.5Mbit] He is only allowed to have 3slots open... And if someone has prefix [10Mbit] he is only allowed to have 9slot open. If they break this they will be kicked. Only kicked not time ban or nothing. They should recoonect again it they have correct the problem.

Like this...

   [100Mbit] = 9slots
   [10Mbit] = 9slots
   [8Mbit] = 9slots
   [5Mbit] = 7slots
   [2.5Mbit] = 5slots
   [2Mbit] = 5slots
   [1Mbit] = 4slots
   [0.8Mbit] = 3slots
   [0.5Mbit] = 3slots
   [0.4Mbit] = 2slots
   [0.2Mbit] = 1slots
   [0.1Mbit] = 1slots
Title:
Post by: nErBoS on 19 September, 2004, 21:18:01
Hi,

Yes it can be made but a user can put in his tag [0.1Mbit] connection just to have 1 slot open and in the realaty he could have a [10Mbit] connection. Do you still want that mod ???

Best regards, nErBoS
Title:
Post by: Robban on 19 September, 2004, 21:53:13
Yes I still want it... It does not do anything if he has 1 slot open. If he has 1 slot open if will be hard to get slot from him but then someone get slot they will have full speed. The rules in my hub are

At least 1 slot hub, and max 3 hubs (Swedish hub = Fast connection = Low slotrules)

Hope you understand :)

This should only be whit regual users not VIP or above

And one more thing.. Your script didn't work any good. It will not leet VIP users loggin whit [VIP] in prefix. bastya_elvtars worked for a while but stopped working so I changde to Mutors script and it works really good.
Title:
Post by: nErBoS on 20 September, 2004, 00:43:45
Hi,

Try this then...

-- Made by dEFiNE
-- Mod by nErBoS asked by Robban

BotName = "-Bot-"

ISP = {
["[100Mbit]"] = 9,
["[10Mbit]"] = 9,
["[8Mbit]"] = 9,
["[5Mbit]"] = 7,
["[2.5Mbit]"] = 5,
["[2Mbit]"] = 5,
["[1Mbit]"] = 4,
["[0.8Mbit]"] = 3,
["[0.5Mbit]"] = 3,
["[0.4Mbit]"] = 2,
["[0.2Mbit]"] = 1,
["[0.1Mbit]"] = 1,
}

function Main()
frmHub:RegBot(BotName)
end


function NewUserConnected(curUser)
if (curUser.iProfile ~= 2) then
local val,slot = ValidateNick(curUser)
local s,e,slots = strfind(curUser.sMyInfoString, "S:(%d+)")
if (val == 0) then
curUser:SendData(BotName, "Your nick should includ one of this [100Mbit] or [10Mbit] or [8Mbit] or [5Mbit] or [2.5Mbit] or [2Mbit] or [1Mbit] or [0.8Mbit] or [0.5Mbit] or [0.4Mbit] or [0.2Mbit] or [0.1Mbit]")
curUser:SendData(BotName, "Change your nick so it display your upload speed. Like this [0.8Mbit]Nickname, Then you are welcome back!")
curUser:SendData(BotName, "Not working? Look here - [URL]http://www.hompage.com[/URL] -")
curUser:Disconnect()
elseif (slots ~= nil and slots > slot) then
curUser:SendData(BotName, "You can only open "..slot.." slots.")
curUser:SendData(BotName, "Kicked...")
curUser:TempBan()
end
end
end

function ValidateNick(curUser)
if (strfind(curUser.sName, "%b[]%b[]%S+")) then
curUser:SendData(BotName, "You can't have two prefixes.")
return 0
else
local value,slot
for value, slot in ISP do
if (strlen(curUser.sName) >= strlen(value) and strsub(strlower(curUser.sName),1,strlen(value)) == strlower(value)) then  
return 1,slot
end
end
end
return 0,0
end

Best regards, nErBoS
Title:
Post by: Robban on 20 September, 2004, 00:58:17
Can't get slotrules thing working :/ Nothing happen then I try to change slots whit a specific Prefix
Title:
Post by: nErBoS on 20 September, 2004, 01:59:49
Hi,

Try out this one...

-- Made by dEFiNE
-- Mod by nErBoS asked by Robban

BotName = "-Bot-"

ISP = {
["[100Mbit]"] = 9,
["[10Mbit]"] = 9,
["[8Mbit]"] = 9,
["[5Mbit]"] = 7,
["[2.5Mbit]"] = 5,
["[2Mbit]"] = 5,
["[1Mbit]"] = 4,
["[0.8Mbit]"] = 3,
["[0.5Mbit]"] = 3,
["[0.4Mbit]"] = 2,
["[0.2Mbit]"] = 1,
["[0.1Mbit]"] = 1,
}

function Main()
frmHub:RegBot(BotName)
end


function NewUserConnected(curUser)
if (curUser.iProfile ~= 2) then
local val,slot = ValidateNick(curUser)
local s,e,slots = strfind(curUser.sMyInfoString, "S:(%d+)")
if (val == 0) then
curUser:SendData(BotName, "Your nick should includ one of this [100Mbit] or [10Mbit] or [8Mbit] or [5Mbit] or [2.5Mbit] or [2Mbit] or [1Mbit] or [0.8Mbit] or [0.5Mbit] or [0.4Mbit] or [0.2Mbit] or [0.1Mbit]")
curUser:SendData(BotName, "Change your nick so it display your upload speed. Like this [0.8Mbit]Nickname, Then you are welcome back!")
curUser:SendData(BotName, "Not working? Look here - [URL]http://www.hompage.com[/URL] -")
curUser:Disconnect()
elseif (slots ~= nil and tonumber(slots) > tonumber(slot)) then
curUser:SendData(BotName, "You can only open "..slot.." slots.")
curUser:SendData(BotName, "Kicked...")
curUser:TempBan()
end
end
end

function DataArrival(curUser, data)
if (strsub(data,1,7) == "$MyINFO" and curUser.iProfile ~= 2 and not curUser.bOperator) then
local val,slot = ValidateNick(curUser)
local s,e,slots = strfind(data, "S:(%d+)")
if (val == 0) then
curUser:SendData(BotName, "Your nick should includ one of this [100Mbit] or [10Mbit] or [8Mbit] or [5Mbit] or [2.5Mbit] or [2Mbit] or [1Mbit] or [0.8Mbit] or [0.5Mbit] or [0.4Mbit] or [0.2Mbit] or [0.1Mbit]")
curUser:SendData(BotName, "Change your nick so it display your upload speed. Like this [0.8Mbit]Nickname, Then you are welcome back!")
curUser:SendData(BotName, "Not working? Look here - [URL]http://www.hompage.com[/URL] -")
curUser:Disconnect()
elseif (slots ~= nil and tonumber(slots) > tonumber(slot)) then
curUser:SendData(BotName, "You can only open "..slot.." slots.")
curUser:SendData(BotName, "Kicked...")
curUser:TempBan()
end
end
end

function ValidateNick(curUser)
if (strfind(curUser.sName, "%b[]%b[]%S+")) then
curUser:SendData(BotName, "You can't have two prefixes.")
return 0
else
local value,slot
for value, slot in ISP do
if (strlen(curUser.sName) >= strlen(value) and strsub(strlower(curUser.sName),1,strlen(value)) == strlower(value)) then  
return 1,slot
end
end
end
return 0,0
end

Best regards, nErBoS
Title:
Post by: Robban on 20 September, 2004, 03:24:41
Thx! This script works perfect now...