Author Topic: Indice numbers  (Read 1924 times)

0 Members and 1 Guest are viewing this topic.

Offline GeceBekcisi

  • Scripter
  • Lord
  • ******
  • Posts: 311
  • Karma: +10/-1
  • You don't need eyes to see, you need vision..
Indice numbers
« on: 23 August, 2005, 12:07:29 »
I was using this function
Code: [Select]
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
Code: [Select]
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
Code: [Select]
tISPs = {  
[ISPname] = {  
[1] = {  
[1] = Start IP1  
[2] = End IP1  
}  
[2] = {  
[1] = Start IP2  
[2] = End IP2  
}  
}
with function below:
Code: [Select]
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
Code: [Select]
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...

PtokaX forum

Indice numbers
« on: 23 August, 2005, 12:07:29 »

Offline bastya_elvtars

  • Forum God
  • ****
  • Posts: 3 752
  • Karma: +173/-7
  • The rock n' roll doctor
    • The FreshStuff3 Site
(No subject)
« Reply #1 on: 23 August, 2005, 12:38:05 »
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.

Offline GeceBekcisi

  • Scripter
  • Lord
  • ******
  • Posts: 311
  • Karma: +10/-1
  • You don't need eyes to see, you need vision..
(No subject)
« Reply #2 on: 23 August, 2005, 12:54:29 »
Code: [Select]
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
Code: [Select]
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...

Offline bastya_elvtars

  • Forum God
  • ****
  • Posts: 3 752
  • Karma: +173/-7
  • The rock n' roll doctor
    • The FreshStuff3 Site
(No subject)
« Reply #3 on: 23 August, 2005, 13:11:24 »
Code: [Select]
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.

PtokaX forum

(No subject)
« Reply #3 on: 23 August, 2005, 13:11:24 »