clearing a table
 

News:

29 December 2022 - PtokaX 0.5.3.0 (20th anniversary edition) released...
11 April 2017 - PtokaX 0.5.2.2 released...
8 April 2015 Anti child and anti pedo pr0n scripts are not allowed anymore on this board!
28 September 2015 - PtokaX 0.5.2.1 for Windows 10 IoT released...
3 September 2015 - PtokaX 0.5.2.1 released...
16 August 2015 - PtokaX 0.5.2.0 released...
1 August 2015 - Crowdfunding for ADC protocol support in PtokaX ended. Clearly nobody want ADC support...
30 June 2015 - PtokaX 0.5.1.0 released...
30 April 2015 Crowdfunding for ADC protocol support in PtokaX
26 April 2015 New support hub!
20 February 2015 - PtokaX 0.5.0.3 released...
13 April 2014 - PtokaX 0.5.0.2 released...
23 March 2014 - PtokaX testing version 0.5.0.1 build 454 is available.
04 March 2014 - PtokaX.org sites were temporary down because of DDOS attacks and issues with hosting service provider.

Main Menu

clearing a table

Started by ??Empie??, 03 February, 2004, 00:39:48

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

??Empie??

Hi all

I just wrote my first bot totally from scratch. It seemed to work like a charm but it seems that ptokax doesnt clear the table on a hub reboot or script reboot...

The problem lies at the clone detection. I have a list which stores IP's. Here's a stripped example of the problem:


tIPList = {} 

function NewUserConnected(curUser)
	if(tIPList[curUser.sIP]) and not curUser.bOperator then 
		local CloneUser = GetItemByName(tIPList[curUser.sIP])
		CloneUser:SendData(Bot,"No clones allowed. Only 1 login per IP")
		CloneUser:Disconnect()
		tIPList[curUser.sIP] = curUser.sName
	else
		tIPList[curUser.sIP] = curUser.sName
	end	
end


function UserDisconnected(curUser)
	tIPList[curUser.sIP] = nil;
end

It simply stores every the ip of every connecting in tIPList, and when the user disconnects it removes the entry again. Whenever a user connects for the 2nd time the first connection is disconnected and the ip is stored in the list again (becouse on the disconnect it removes the ip from the list so a 3rd connection would be possible).

but now whenever I restart the script or the hub without restarting the pc the list gets saves so lots of ppl cant get in.

Can I clear or reset the table in the main funcion? so to say whenever the script starts?

lots of thx in advance!

? Empie ?

Killua Anime - Akira's Fiction 1 - Killua.student.utwente.nl

kepp

#1
Wouldn't that delete all entries?

Im not sure but you could try in main

function Main()
tIPList = nil;
tIPList = {}
end

??

You also check "and if not user.bOperator" which i don't think is needed since you use NewUserConnected() that only proceed data with an index below OP's
Guarding    

plop

should be no need 2 save it anymore with this modifications.
tIPList = {} 

function NewUserConnected(curUser)
	if(tIPList[curUser.sIP]) then 
		curUser:SendData(Bot,"No clones allowed. Only 1 login per IP")
		curUser:Disconnect()
	else
		tIPList[curUser.sIP] = curUser.sName
	end	
end


function UserDisconnected(curUser)
   if curUser.sName == tIPList[curUser.sIP] then
      tIPList[curUser.sIP] = nil
   end
end

function DataArrival(curUser, data) 
   if curUser.bOperator == nil then 
      if tIPList[curUser.sIP] == nil then
         tIPList[curUser.sIP] = curUser.sName
      elseif tIPList[curUser.sIP] ~= curUser.sName then
         curUser:SendData(Bot,"No clones allowed. Only 1 login per IP")
         curUser:Disconnect()
      end
   end
end
removed the disconnecting of the clone as you can better disconnect the 2de ip.
some isp's put multiple users on 1 ip, your way would be really irritating for them.

plop
http://www.plop.nl lua scripts/howto\'s.
http://www.thegoldenangel.net
http://www.vikingshub.com
http://www.lua.org

>>----> he who fights hatred with hatred, drives the spreading of hatred <----<<

??Empie??

QuoteOriginally posted by plop
removed the disconnecting of the clone as you can better disconnect the 2de ip.
some isp's put multiple users on 1 ip, your way would be really irritating for them.
plop

Yeah, I see what you mean but I'm going to stick to the kicking of the first one..

Sometimes a "ghost clone" stays in the hub for some reason, and it would mean that that user couldnt log in...

about ISP's giving 2 ppl the same IP... I have never heard of that. It is true that a lot of people share their internetconnection, and those people would have 1 IP, thats true, but at the same time they also have only 1 upload, so I dont mind that only one of them can connect.

In the two days that I had the script running (in a 1000+ user hub) only 1 person came to me with that problem. I explained it to him and he totally understood :).

still much thanx for the help Kepp and plop, Im going to dig into the script now ^_^

? Empie ?

plop

NGT from norway is 1 of those isp's, all of them are passive users.
the record i found was 8 users on 1 ip.
it's a lame trick as they need 2 pay extra for a own ip.
nearly all don't know about this untill they complained 2 the isp.

plop
http://www.plop.nl lua scripts/howto\'s.
http://www.thegoldenangel.net
http://www.vikingshub.com
http://www.lua.org

>>----> he who fights hatred with hatred, drives the spreading of hatred <----<<

SMF spam blocked by CleanTalk