Author Topic: Getting values from tables  (Read 1947 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..
Getting values from tables
« on: 15 August, 2005, 19:06:49 »
Which way should I follow to get values from table which has a structure like:
Code: [Select]
tIPtable = {
[curUser.sIP] = {
[curUser.sName] = {
["Entered"] = "LogInDate",
["Left"] = "LogOutDate",
},
},
}
I need to search for curUser.sIP and if it is found, get curUser.sName, Entered and Left values.

And also, I need to search for curUser.sName and if it is found, get curUser.sIP, Entered and Left values.


Thanks for any help..
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

Getting values from tables
« on: 15 August, 2005, 19:06:49 »

Offline plop

  • Forum God
  • ****
  • Posts: 2 464
  • Karma: +37/-0
(No subject)
« Reply #1 on: 15 August, 2005, 19:21:00 »
example.
Code: [Select]
tIPtable = {
[curUser.sIP] = {
[curUser.sName] = {
["Entered"] = "LogInDate",
["Left"] = "LogOutDate",
},
},
}

if tIPtable[(curUser.sIP)] then
if tIPtable[(curUser.sIP)][(curUser.sName)] then
-- known username for the IP.
else
-- new username for the IP
end
else
-- build new table entry for IP
end

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 <----<<

Offline bastya_elvtars

  • Forum God
  • ****
  • Posts: 3 744
  • Karma: +173/-7
  • The rock n' roll doctor
    • The FreshStuff3 Site
(No subject)
« Reply #2 on: 15 August, 2005, 20:39:27 »
I think you should have entered and left in a different table, since these change more frequently than IP, and is easier to maintain.
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 #3 on: 15 August, 2005, 20:59:45 »
I only wanna get one entry & exit date per user in per ip. so that table is ok for now, I think
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

(No subject)
« Reply #3 on: 15 August, 2005, 20:59:45 »