Indice numbers
 

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

Indice numbers

Started by GeceBekcisi, 23 August, 2005, 12:07:29

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

GeceBekcisi

I was using this function
if tIPtable[curUser.sIP] == nil then
	tIPtable[curUser.sIP] = {} 
end 
tIPtable[curUser.sIP][curUser.sName] = {} 
tIPtable[curUser.sIP][curUser.sName] = {sEntryDate,"User is still online	"} 
tFunctions.SaveToFile(sIPFile, tIPtable, "tIPtable")
to create
tIPtable = {
	["UsersIP"] = {
		["UsersNick"] = {
			[1] = "Login Date to Hub",
			[2] = "Logout Date or (User is still online)",
		},
	}
}
but couldnt find how to add indice numbers to table
tISPs = {  
	[ISPname] = {  
		[1] = {  
			[1] = Start IP1  
			[2] = End IP1  
		}  
		[2] = {  
			[1] = Start IP2  
			[2] = End IP2  
		}  
}
with function below:
if tISPtable[sISPName] == nil then
	tISPtable[sISPName] = {} 
end 
tISPtable[sISPName][IndexNumber] = {} 
tISPtable[sISPName][IndexNumber] = {sIP1,sIP2} 
tFunctions.SaveToFile(sISPFile, tISPtable, "tISPtable")
I need help with creating [IndexNumber] and also; when a indice is deleted with function
table.remove(tISPtable[sISPName][IndexNumber])
to make all the other IndexNumbers below the deleted one "IndexNumber-1". HELP pls :(
Do you need an advanced user handling script? Download UserBekcisi today (Latest Edit)
Features: User + ISP + GeoIP database, user info + share checking and many more...

bastya_elvtars

So you don't want the index numbers to be changed after removing an entry?
Everything could have been anything else and it would have just as much meaning.

GeceBekcisi

tISPtable = {
	["ISP1"] = {
		[1] = {
			[1] = "123.0.0.7",
			[2] = "123.0.0.9",
		},
		[2] = {
			[1] = "123.0.0.3",
			[2] = "123.0.0.4",
		},
		[3] = {
			[1] = "123.0.0.10",
			[2] = "123.0.0.11",
		},
	},
	["ISP2"] = {
		[1] = {
			[1] = "123.0.0.70",
			[2] = "123.0.0.90",
		},
		[2] = {
			[1] = "123.0.0.30",
			[2] = "123.0.0.40",
		},
	},
}
should be like
tISPtable = {
	["ISP1"] = {
		[1] = {
			[1] = "123.0.0.7",
			[2] = "123.0.0.9",
		},
		[2] = {
			[1] = "123.0.0.10",
			[2] = "123.0.0.11",
		},
	},
	["ISP2"] = {
		[1] = {
			[1] = "123.0.0.70",
			[2] = "123.0.0.90",
		},
		[2] = {
			[1] = "123.0.0.30",
			[2] = "123.0.0.40",
		},
	},
}
after a command like " !delisp 123.0.0.3 123.0.0.4 "
Do you need an advanced user handling script? Download UserBekcisi today (Latest Edit)
Features: User + ISP + GeoIP database, user info + share checking and many more...

bastya_elvtars

for a,b in pairs(tISPtable) do -- go thruogh the table
  for k,v in pairs(b) do -- and every nested table
    if v[1]==startIP and v[2]==endIP then -- if the range is in there
      tISPtable[a][k]=nil -- we ALWAYS refer to the global table
      break -- no longeer needed to run the loop
    end
  end
end
Everything could have been anything else and it would have just as much meaning.

SMF spam blocked by CleanTalk