PtokaX forum

Development Section => Your Developing Problems => Topic started by: Typhoon on 09 July, 2004, 00:55:40

Title: login problem :)
Post by: Typhoon on 09 July, 2004, 00:55:40
hey again guys i am trying to make this work with an allowed tags table, but i am screwing it up or am being to tired atm. someone please show or hint me or help me fix it :) thx in advance...


RedirectOnFailed = 1 -- nil or 1 to redirect when user fails to meet the Log-In Check criteria (not for Forbiddenwords)
useTempBan = nil -- nil or 1 to TempBan users when they don't meet the criteria.

allowed = {
["++"]=1,
["oDC"]=1,
["DCGUI"]=1
}


--// This function is fired when a new user finishes the login

function CheckMyInfo( user, myinfo )
if RedirectOnFailed then
user.FailedLogin = function( o )
local addr = frmHub:GetRedirectAddress()
local warning = gsub( GU11.." [H]", "%[H%]", addr, 1 )
WarnMess = gsub( GU12.." {[H]} "..OP3 , "%[H%]", addr, 1 )
o:SendPM( BotNameName, warning )
o:SendData( "$ForceMove "..addr )
if useTempBan then
o:TempBan()
else
o:Disconnect()
end
end
else
if useTempBan then
user.FailedLogin = user.TempBan
WarnMess = GU9
else
user.FailedLogin = user.Disconnect
WarnMess = GU10
end
end
--// get needed info from string
if allowed[T] then
local ret,c,T,V,M,H,S,O,speed,share = strfind( myinfo,
--     V:0123 M:P|A H:0-99    S:0-99    O:0-99   speed         share
"<([^<> ]+) V:([^,]+),M:(.),H:([^,]+),S:([^,]+),O:([^,>]+).*>$ $([^$]*)%$[^$]*%$(%d+)%$$" ) -- dc++, with O
if not ret then
ret,c,T,V,M,H,S,speed,share = strfind( myinfo,
--     V:0123 M:P|A H:0-99    S:0-99  speed       share
"<([^<> ]+) V:([^,]+),M:(.),H:([^,]+),S:([^,>]+).*>$ $([^$]*)%$[^$]*%$(%d+)%$$" ) -- dc++, without O
end
if not ret then
ret,c,share = strfind( myinfo,
-- share
"%$(%d+)%$$" ) -- nmdc/other, non <++ V:
end
if not ret then
user:SendPM( BotNameName, GU7 )
user:FailedLogin()
SendToFollow("<"..user.sName.."> "..WarnMess.." "..GU8)
return
end
--// fix new DC024 H:x/y/z notation
if H then
local Hn = {0} -- crappy-ass lua4 workaround
gsub( H, "(%d+)", function( x ) %Hn[1] = %Hn[1] + tonumber( x ) end, hubCheckMethod )
H = Hn[1]
end
--// fix slots while we're at it, no need for multiple tonumber()'s
if S then
S = tonumber( S )
end
local userShare = tonumber(share)
local minShare = tonumber(frmHub:GetMinShare()*1024*1024)
local minShareGB = (frmHub:GetMinShare()/1024)
local userShareGB = format("%0.2f", tonumber(share)/1024/1024/1024)
--// check for NMDC / Version / Share / MaxSlots / MaxHubs / MinSlots / MinSlotsPrHub
if not allowed[T] then
user:SendPM( BotName, GU1)
user:FailedLogin()
SendToFollow("<"..user.sName.."> "..WarnMess.." "..GU2)
return
elseif allowed[T] and minVersion then
local n = tonumber( V )
if not n then
SendPmToOps( BotName,GU3.." V:"..V.." "..GU4.." <"..user.sName.."> -- "..GU5 )
elseif n < minVersion then
local warning = gsub( GU6.." [V]", "%[V%]", tostring( minVersion ), 1 )
user:SendPM( BotName, warning )
user:FailedLogin()
SendToFollow("<"..user.sName.."> "..WarnMess.." "..GU13.." ["..n.."] - { "..GU14.." ["..minVersion.."] }")
return
end
elseif userShare < minShare then
user:SendPM(BotName, GU15.." "..minShareGB.." GB. "..GU16.." ("..userShareGB..") GB")
user:FailedLogin()
SendToFollow("<"..user.sName.."> "..WarnMess.." ("..userShareGB..") GB "..GU17.." - { "..GU18.." ("..minShareGB..") GB "..GU17..". }")
return
elseif H and S then
if maxSlots and S > maxSlots then
user:SendPM(BotName, GU19.." ("..maxSlots..") "..GU16.." ("..S..") "..GU20)
user:FailedLogin()
SendToFollow("<"..user.sName.."> "..WarnMess.." ("..S..") "..GU21.." - { Maximum ("..maxSlots..") "..GU20..". }")
return
elseif maxHubs and H > maxHubs then
user:SendPM(BotName, GU22.." ["..maxHubs.."] "..GU23.." ["..H.."] "..GU24)
user:FailedLogin()
SendToFollow("<"..user.sName.."> "..WarnMess.." ("..H..") "..GU25.." - { Maximum ["..maxHubs.."] "..GU24..". }")
return
elseif minSlotsPerHub and S < ( H * minSlotsPerHub )+ExtraSlots then
user:SendPM(BotName, GU26.." ("..(minSlotsPerHub*H)+ExtraSlots.."/"..H..") "..GU16.." ("..S.."/"..H..") "..GU27)
user:FailedLogin()
SendToFollow("<"..user.sName.."> "..WarnMess.." ("..S.."/"..H..") "..GU27.."  - { "..GU18.." ("..(minSlotsPerHub*H)+ExtraSlots.."/"..H..") "..GU27..". }")
return
elseif minSlots and S < minSlots then
user:SendPM(BotName, GU28.." ("..minSlots..") "..GU16.." ("..S..") "..GU29)
user:FailedLogin()
SendToFollow("<"..user.sName.."> "..WarnMess.." ("..S..") "..GU21.."! - { "..GU18.." ("..minSlots..") "..GU29..". }")
return
end
end
--// Connection Speed vs Slots.
if speed and SlotsVsSpeedCheck then
local speed = strsub(speed,1,strlen(speed)-1)
if SlotsVsSpeed[speed] and S > SlotsVsSpeed[speed] then
user:SendPM(BotName, GU30.." ("..SlotsVsSpeed[speed]..") "..GU16.." ("..S..") "..GU29)
user:FailedLogin()
SendToFollow("<"..user.sName.."> "..WarnMess.." ["..speed.."] "..OP22.." ("..S..") "..GU29.."! - { "..GU31.." ("..SlotsVsSpeed[speed]..") "..GU29..". }")
end
end
end
end


-Typhoon?
Title:
Post by: Typhoon on 09 July, 2004, 15:38:04
above post updated sorry for the miss :)
Title:
Post by: Typhoon on 10 July, 2004, 11:35:44
well , i have the check in dataarrival with a level select, so certain levels like ops dont get checked..
and the problem of mine is the table part i tryed to play with it but no luck at all.. , and i really think a update of the function are about time

* Typhoon?