PtokaX forum

Development Section => Your Developing Problems => Topic started by: GeceBekcisi on 23 August, 2005, 12:07:29

Title: Indice numbers
Post by: GeceBekcisi on 23 August, 2005, 12:07:29
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 createtIPtable = {
["UsersIP"] = {
["UsersNick"] = {
[1] = "Login Date to Hub",
[2] = "Logout Date or (User is still online)",
},
}
}
but couldnt find how to add indice numbers to tabletISPs = {  
[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 functiontable.remove(tISPtable[sISPName][IndexNumber])to make all the other IndexNumbers below the deleted one "IndexNumber-1". HELP pls :(
Title:
Post by: bastya_elvtars on 23 August, 2005, 12:38:05
So you don't want the index numbers to be changed after removing an entry?
Title:
Post by: GeceBekcisi on 23 August, 2005, 12:54:29
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 liketISPtable = {
["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 "
Title:
Post by: bastya_elvtars on 23 August, 2005, 13:11:24
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