PtokaX forum

Archive => Archived 5.0 boards => Request for scripts => Topic started by: Loading on 03 July, 2005, 19:13:41

Title: User alert
Post by: Loading on 03 July, 2005, 19:13:41
hello ppl
i have a question can you make this script

just to detect who try to enter whinthout the min.slots ,
min. share , min. client ?

a message like this :

Bot - The user (Username) just tried to enter in the hub but don't have the (min.slots ,
min. share , min. client ) and is disconected

and send a pm to masters and netfounders ?

The script is this one:
   -- Unreg Alert v1

    -- By Dessamator



    function Main()

    tImmune ={}

    if io.open("immune.tbl") then dofile("immune.tbl") end

    end



    function OnExit()

    SaveToFile("immune.tbl" , tImmune , "tImmune")

    end



    function SupportsArrival(user, data)

    if not user.bRegistered and not tImmune[user.sIP] then

    SendToOps("botname",user.sName.." with "..user.sIP.." was not registered and tried to login")

    end

    end



    function ChatArrival(user,data)

    data=string.sub(data,1,-2)

    local s,e,cmd = string.find(data,"%b<>%s+(%S+)")

    local _,__,ip = string.find(data,"%b<>%s+%S+%s+(%S+)")

    if cmd =="!immune" then

    tImmune[(ip)] = 1

    user:SendData(frmHub:GetHubBotName(),"Done!, that ip has been immuned")

    return 1

    elseif cmd =="!delimmune" then

    tImmune[(ip)] = nil

    user:SendData(frmHub:GetHubBotName(),"Done!, that ip is no longer immune")

    return 1

    elseif cmd=="!showimmune" then

    local temp="\r\n\t\Immuned IPs:\r\n"..string.rep("??",12).."\r\n"

    for i,v in tImmune do

    temp=temp.."\t•"..i.."\r\n"

    end

    user:SendData(frmHub:GetHubBotName(),temp)

    return 1

    end

    end





    function Serialize(tTable, sTableName, sTab)

    assert(tTable, "tTable equals nil");

    assert(sTableName, "sTableName equals nil");



    assert(type(tTable) == "table", "tTable must be a table!");

    assert(type(sTableName) == "string", "sTableName must be a string!");



    sTab = sTab or "";

    sTmp = ""



    sTmp = sTmp..sTab..sTableName.." = {\n"



    for key, value in tTable do

    local sKey = (type(key) == "string") and string.format("[%q]",key) or string.format("[%d]",key);



    if(type(value) == "table") then

    sTmp = sTmp..Serialize(value, sKey, sTab.."\t");

    else

    local sValue = (type(value) == "string") and string.format("%q",value) or tostring(value);

    sTmp = sTmp..sTab.."\t"..sKey.." = "..sValue

    end



    sTmp = sTmp..",\n"

    end



    sTmp = sTmp..sTab.."}"

    return sTmp

    end



    function SaveToFile(file , table , tablename)

    local handle = io.open(file,"w+")

    handle:write(Serialize(table, tablename))

    handle:flush()

    handle:close()

    end

can anyone hellp me ? with this script ?


Best regards


Loading
Title:
Post by: Dessamator on 03 July, 2005, 19:56:47
min share and min slots are easy to do,  but the min client is a bit messy, first of all there are quite a few clients, and ud need to set the min client for each etc etc etc
Title:
Post by: Loading on 03 July, 2005, 20:01:16
ok

forget the min client

can you make for min slots and min share ?


best regards
Title:
Post by: Loading on 04 July, 2005, 22:08:35
hi Dessamator

Can you makethe script just for min slots and min share ?


Best regards

Loading
Title:
Post by: Dessamator on 04 July, 2005, 22:50:59

  -- checker v1a
  -- By Dessamator

minshare = 20 --(in gb)
minslots = 3
sBot="botname"

    function Main()
    frmHub:RegBot(sBot)
    tImmune ={}
   if io.open("immune.tbl") then dofile("immune.tbl") end
    end

    function OnExit()
   SaveToFile("immune.tbl" , tImmune , "tImmune")
    end

    function NewUserConnected(user)
local share= string.format("%0.2f",user.iShareSize/1024^3)
if not tImmune[user.sIP] then
  if  user.iSlots < minslots then
           SendPmToOps(sBot,user.sName.." with "..user.sIP.." tried to login with insuficient slots")
   elseif tonumber(share) < minshare then
       SendPmToOps(sBot,user.sName.." with "..user.sIP.." tried to login with insuficient share")
   end
end
    end

    function ChatArrival(user,data)
    local s,e,cmd = string.find(data,"%b<>%s+(%S+)|")
    local _,__,ip = string.find(data,"%b<>%s+%S+%s+(%S+)|")
   if cmd =="!immune" then
   tImmune[(ip)] = 1
   user:SendData(frmHub:GetHubBotName(),"Done!, that ip has been immuned")
     return 1
   elseif cmd =="!delimmune" then
   tImmune[(ip)] = nil
   user:SendData(frmHub:GetHubBotName(),"Done!, that ip is no longer immune")
   return 1
   elseif cmd=="!showimmune" then
   local temp="\r\n\t\Immuned IPs:\r\n"..string.rep("??",12).."\r\n"
               for i,v in tImmune do
   temp=temp.."\t•"..i.."\r\n"
   end
   user:SendData(frmHub:GetHubBotName(),temp)
   return 1
   end
    end


    function Serialize(tTable, sTableName, sTab)
    assert(tTable, "tTable equals nil");
    assert(sTableName, "sTableName equals nil");

    assert(type(tTable) == "table", "tTable must be a table!");
    assert(type(sTableName) == "string", "sTableName must be a string!");

    sTab = sTab or "";
    sTmp = ""

    sTmp = sTmp..sTab..sTableName.." = {\n"

    for key, value in tTable do
    local sKey = (type(key) == "string") and string.format("[%q]",key) or string.format("[%d]",key);

    if(type(value) == "table") then
    sTmp = sTmp..Serialize(value, sKey, sTab.."\t");
    else
    local sValue = (type(value) == "string") and string.format("%q",value) or tostring(value);
    sTmp = sTmp..sTab.."\t"..sKey.." = "..sValue
    end

    sTmp = sTmp..",\n"
    end

    sTmp = sTmp..sTab.."}"
    return sTmp
    end

function SaveToFile(file , table , tablename)
    local handle = io.open(file,"w+")
    handle:write(Serialize(table, tablename))
    handle:flush()
    handle:close()
end


Done !
Title:
Post by: Loading on 05 July, 2005, 00:26:46
hi
tnks for the script

but it works just one time :(

and can you make 3 modifications ?

1? make the script send a pm to ops ( it sends a message to mainchat)

2? make 2 distinguish messages one for min slots like:

"botname",user.sName.." with "..user.sIP.." was didnt have sufficient slots"

and other to min share like :

"botname",user.sName.." with "..user.sIP.." was didnt have sufficient Share"

( i tried to modificate but it don't work , lol )

3? can you make this script with a bot name ?

tanks for the help

Best regards

Loading
Title:
Post by: Dessamator on 05 July, 2005, 11:33:49
done!
Title:
Post by: Loading on 05 July, 2005, 21:02:17
hi dessamator

tanks for the modification

but i tried to enter in mu hub with another nick ( profile = User ) with 0 slots ( the minimum in my hub is 3

and the script don't detect the user , and with the min. Share is the same thing

the first checker v1a script you posted for me works just one time and don't work anymore

can you see the error ?

Best Regards

Loading
Title:
Post by: Dessamator on 05 July, 2005, 22:13:26
fixed, i guess
Title:
Post by: Loading on 05 July, 2005, 23:09:16
hi dessamator

i know why the script don't work

is because the robocop

i stop the robocop script and the this script work perfetly

do you know how to make this script full working with robocop script ?


best regards

Loading
Title:
Post by: Dessamator on 05 July, 2005, 23:47:03
sure, put it ontop of robocop in the script order
Title:
Post by: Loading on 05 July, 2005, 23:53:40
sorry

not understand what you mean

?????
Title:
Post by: ??????Hawk?????? on 06 July, 2005, 00:00:30
goto the script editor on Ptokax  ..  Highlight the script and Move it up in the list
Title:
Post by: Loading on 06 July, 2005, 00:09:41
hi

i put user alert.lua in 1? of all

and roboccop in last of all

but don't work
:(


best regards

Loading
Title:
Post by: Loading on 06 July, 2005, 05:09:38
can anyone help me ????



best regards


Loading
Title:
Post by: Dessamator on 06 July, 2005, 08:39:49
I just tested it with robo, and it worked perfectly,

did u set the min slots in the script, in ptokax, or in robo?
maybe that is what is causing the trouble .
Title:
Post by: Loading on 06 July, 2005, 14:11:41
i set the slots and the share in robo


i don't now wath is the problem with tis script ?

anyone know a solution for this problem ?



best regards

Loading
Title:
Post by: Dessamator on 06 July, 2005, 19:03:00
well, if u set it in robocop, u also have to set it in the script, the same values
Title:
Post by: Loading on 06 July, 2005, 20:32:20
it works

tanks man for te help

works fine now

Best regards

Loading
Title:
Post by: Dessamator on 06 July, 2005, 21:14:31
at last !

Ur welcome
Title:
Post by: Loading on 06 July, 2005, 21:24:24
lololol

tanks