PtokaX forum

Archive => Archived 4.0 boards => Help with Lua 4 scripts => Topic started by: kazi on 20 October, 2004, 21:55:24

Title: line errors in script
Post by: kazi on 20 October, 2004, 21:55:24
function Main()
    frmHub:EnableFullData(1)

    Levels = {
        Master = "1",
        Operator = "1",
        VIP = "1",
        Reg = "0",
        Default = "0"
    }

end

function DataArrival(curUser, data)


    if (strsub(data, 1, 15) == "$RevConnectToMe" and curUser.iProfile == -1) then
        local _,_,towho = strfind(data, "$RevConnectToMe%s+%S+%s+(%S+)|")

        if isEnabled(GetProfileName(GetItemByName(towho).iProfile))=="1" then
            curUser:SendData("*** You must get registered to be able to download from Me so contact an OP to get Registered")    
        end

        return 1

    elseif (strsub(data, 1, 12) == "$ConnectToMe" and curUser.iProfile == -1) then
        local _,_,towho = strfind(data, "$ConnectToMe%s+(%S+)%s+.*|")
       
        if isEnabled(GetProfileName(GetItemByName(towho).iProfile))=="1" then
            curUser:SendData("*** You must get registered to be able to download from Me so contact an OP to get Registered")    
        end

        return 1
    end

end


function isEnabled(profile)
    ret = "0"
    if profile then
        for i, v in Levels do        
            if ( i == profile ) then
                ret = v
            end
        end

**Trying to get this script working in ptokax 0.3.3.0 but i get all kinda line erros , need this script to be modified for ptokax 0330?


**errormessage: Syntax error: `end' expected (to close `function' at line 37);
  last token read: `' at line 45 in string "function Main()   ..."

thanx in advance
Title:
Post by: Themaster on 20 October, 2004, 22:06:44
plz make [ C O D E] [ / C O D E] and make that line is error color so it easy to see
Title:
Post by: kazi on 20 October, 2004, 22:13:05
Sorry mate.. didn t know how to do that.. tx. hope its clear now.
Title:
Post by: Themaster on 20 October, 2004, 22:19:48
what is the line 37 ???
Title:
Post by: kazi on 20 October, 2004, 22:23:33
[COLOR=green]end [/COLOR]  


function isEnabled(profile)
    ret = "0"
    if profile then
        for i, v in Levels do        
            if ( i == profile ) then
                ret = v
            end
        end

I think its the "green" end  I think the script sees it as end of all functions? but a new function is started underneith.
Title:
Post by: Psycho_Chihuahua on 20 October, 2004, 22:29:36
perhaps this works, have NOT tested

function Main()
    frmHub:EnableFullData(1)
    Levels = {Master = "1",Operator = "1",VIP = "1",Reg = "0",Default = "0"}
end
function DataArrival(curUser, data)
    if (strsub(data, 1, 15) == "$RevConnectToMe" and curUser.iProfile == -1) then
        local _,_,towho = strfind(data, "$RevConnectToMe%s+%S+%s+(%S+)|")
    if isEnabled(GetProfileName(GetItemByName(towho).iProfile))=="1" then
            curUser:SendData("*** You must get registered to be able to download from Me so contact an OP to get Registered")    
        end
        return 1
    elseif (strsub(data, 1, 12) == "$ConnectToMe" and curUser.iProfile == -1) then
        local _,_,towho = strfind(data, "$ConnectToMe%s+(%S+)%s+.*|")
         if isEnabled(GetProfileName(GetItemByName(towho).iProfile))=="1" then
            curUser:SendData("*** You must get registered to be able to download from Me so contact an OP to get Registered")    
        end
        return 1
    end
end
function isEnabled(profile)
    ret = "0"
    if profile then
        for i, v in Levels do        
            if ( i == profile ) then
                ret = v
            end
        end
end
end
Title:
Post by: Themaster on 20 October, 2004, 22:31:40
function isEnabled(profile)
   ret = "0"
   if profile then
      for i, v in Levels do        
         if ( i == profile ) then
               ret = v
         end
      end
   end
end

try this
Title:
Post by: kazi on 20 October, 2004, 22:53:56
many thanx Psycho_Chihuahua

the script is accepted by hubsoftware, the only thing is non regged users who try to dl form vip, op  or master  dont get the message :(

this error is see in ptokax now

stack traceback:
   1:  function `DataArrival' at line 14 [file `...iles\Ptokax 0.330
Title:
Post by: Psycho_Chihuahua on 20 October, 2004, 23:17:00
try changing
if isEnabled(GetProfileName(GetItemByName(towho).iProfile))=="1" then to if isEnabled(GetProfileName(GetItemByName(towho).iProfile))=="-1" then
not sure if oit's correct thoug, just a wild guess  :D
Title:
Post by: kazi on 21 October, 2004, 06:08:55
ok, have done that, the error message is not appearing anymore.

ok what happens now  is this:

if users are not regged  they cant dl nothing  not even filelists of anyone,  they get from everyone  con
nection timeout.   as soon as they enter the hub as a reg user  they can dl everything of everybody.

there are two things in my opinion that is not good:

1) they dont get the message
2) they should be able to download filelists from other NON regged users.  but as far as I can see now  all connections are blocked.

at the bottom at this script  it says

function isEnabled(profile)
    ret = "0"
    if profile then
        for i, v in Levels do        
            if ( i == profile ) then
                ret = v
            end
        end
end
end
   the ret = "0"     what does that mean?  

thanks again