PtokaX forum

Archive => Archived 5.0 boards => Help with scripts => Topic started by: Psycho_Chihuahua on 24 April, 2005, 19:48:14

Title: need a touch
Post by: Psycho_Chihuahua on 24 April, 2005, 19:48:14
i have been trying to adapt my old "anti-openhub-script" to the new hubsoft and all i have atm is this

function NewUserConnected(user)
if user.iNormalHubs then
if user.iNormalHubs>0 then
user:SendData( "PtokaX", "You are in unregistered hubs. This is against our rules. You will now be disconnected!")
user:Disconnect()
end
end
end

Now, could someone adapt it a bit so that it checks in intervalls instead of only when someone connects? Please, i need this one quit urgently :D
Title:
Post by: jiten on 24 April, 2005, 22:31:48
Give this a try:
-- Timed Anti-openhub-script by jiten

RegCheck = {}

function Main()
SetTimer(10*60*1000) -- Default Checking Time set for 10 minutes
StartTimer()
end

function NewUserConnected(user)
if user.iNormalHubs then
RegCheck[user.sName] = 1
if user.iNormalHubs>0 then
user:SendData( "PtokaX", "You are in unregistered hubs. This is against our rules. You will now be disconnected!")
user:Disconnect()
end
end
end

-- OpConnected = NewUserConnected

function OnTimer()
for i,v in RegCheck do
local nick = GetItemByName(i)
if GetItemByName(i).iNormalHubs > 0 then
nick:SendData( "PtokaX", "You are in unregistered hubs. This is against our rules. You will now be disconnected!")
nick:Disconnect()
end
end
end

function UserDisconnected(user)
if user.iNormalHubs and RegCheck[user.sName] ~= nil then
RegCheck[user.sName] = nil
end
end

-- OpDisconnected = UserDisconnected
*EDIT* Changed some code
Cheers
Title:
Post by: Dessamator on 24 April, 2005, 22:50:42
yikes, do my eyes deceive me, jiten, first script thats not a mod, :D
Title:
Post by: plop on 24 April, 2005, 23:07:00
why not like this??
function MyINFOArrival(user)
if user.iNormalHubs then
if user.iNormalHubs>0 then
user:SendData( "PtokaX", "You are in unregistered hubs. This is against our rules. You will now be disconnected!")
user:Disconnect()
end
end
end

plop
Title:
Post by: Dessamator on 24 April, 2005, 23:20:55
hmm plop, because of this::

QuoteNow, could someone adapt it a bit so that it checks in intervalls instead of only when someone connects? Please, i need this one quit urgently :D

in intervals,  ;)
Title:
Post by: Psycho_Chihuahua on 25 April, 2005, 02:50:00
Thnx a lot jiten, seems to be working ( i assume the SetTimer(10000) is 10 minutes, so i gotta wait a bit
Title:
Post by: jiten on 25 April, 2005, 14:05:30
QuoteOriginally posted by Dessamator
yikes, do my eyes deceive me, jiten, first script thats not a mod,
Indeed :D
QuoteOriginally posted by Psycho_Chihuahua
Thnx a lot jiten, seems to be working ( i assume the SetTimer(10000) is 10 minutes, so i gotta wait a bit
yw m8...
Btw, changed the script so now it checks in an interval of 10 minutes.
The "1000" meant 10 seconds ;)
Cheers
Title:
Post by: plop on 25 April, 2005, 17:23:06
QuoteOriginally posted by Dessamator
hmm plop, because of this::

QuoteNow, could someone adapt it a bit so that it checks in intervalls instead of only when someone connects? Please, i need this one quit urgently :D

in intervals,  ;)
ok, i take that as a nice excuse. lol

btw what if a user is in a so called open hub while entering.
but then he sees the rules and closes the open hub.
the user would still get kicked.
and for some users it might take 10 mins, while others could get kicked within 10 seconds.

plop
Title:
Post by: Herodes on 25 April, 2005, 17:59:07
maybe this ? tBadOnes = {}
iTimeAfter = 15 -- how many seconds before disconnecting

function Main()
SetTimer( 1000 )
StartTimer()
end

function NewUserConnected(user)
if user.iNormalHubs then
if user.iNormalHubs > 0 then
tBadOnes[user.sName] = iTimeAfter
user:SendData( "PtokaX", "You are in unregistered hubs. This is against our rules. You will be disconnected in "..iTimeAfter.." seconds from now!")
end
end
end

function OnTimer()
for nick, v in tBadOnes do
local user = GetItemByName( nick )
if user.iNormalHubs then
if user.iNormalHubs == 0 then
tBadOnes[nick] = nil
user:SendData( "PtokaX", "Thanks for adjusting your unregistered hubs so that it conforms with our rules." )
elseif user.iNormalHubs > 0 then
tBadOnes[nick] = tBadOnes[nick] - 1
if tBadOnes[nick] == 0 then
tBadOnes[nick] = nil
user:SendData( "PtokaX", "You are being disconnected because you didn't conform to the hub rules. You were in unregistered hubs." )
user:Disconnect()
elseif tBadOnes[nick] == math.floor( iTimeAfter / 2 ) then
user:SendData ( "PtokaX", "You should really disconnect from the hubs that you aren't registered. it is not allowed in this hub. You have "..math.floor( iTimeAfter / 2 ).." seconds left disconnection follows after that.." )
end
end
end
end
end

function UserDisconnected(user)
if tBadOnes[user.sName] then
tBadOnes[user.sName] = nil
collectgarbage();
end
end
Title:
Post by: plop on 27 April, 2005, 23:09:01
yea that looks like it.

plop
Title:
Post by: Psycho_Chihuahua on 27 April, 2005, 23:33:33
seems to be working ^^ thnx alot herodes
Title:
Post by: Herodes on 27 April, 2005, 23:43:16
QuoteOriginally posted by Psycho_Chihuahua
seems to be working ^^ thnx alot herodes
you are welcome Psycho ;)
Title:
Post by: kunal on 16 September, 2005, 16:46:35
is it possible to allow someusers by the cmd !allow [nick] to not pass this check
Title:
Post by: bastya_elvtars on 16 September, 2005, 18:31:45
QuoteOriginally posted by kunal
is it possible to allow someusers by the cmd !allow [nick] to not pass this check

Some users or certain user classes?

Only non-ops get checked.
Title:
Post by: kunal on 17 September, 2005, 05:46:17
not certain user class but some users.
Title:
Post by: kunal on 19 September, 2005, 16:04:31
can someone add a immune function for this script