ok i read all that and understand it, but i've programmed myself into a hole and didnt even know it. look:

Code:
on *:load: {
  socklisten telnet 4445
}
on *:socklisten:telnet: {
  sockaccept telnetopen
  set %ipname $sock(telnetopen).ip
  set %ipname telnetopen $+ %ipname
  sockrename telnetopen %ipname
  echo Telnet Session Initiated from $sock(%ipname).ip
  set %checktelip $read(data\telnetiplist.db, w, $sock(%ipname).ip)
  if (%checktelip != $null) {
    write -ds $sock(%ipname).ip data\telnetiplist.db
  }
  write data\telnetiplist.db $sock(%ipname).ip
  set %checktelname $read(data\telnetnamelist.db, w, telnetopen $+ $sock(%ipname).ip)
  if (%checktelname != $null) {
    write -ds telnetopen $+ $sock(%ipname).ip data\telnetnamelist.db
  }
  write data\telnetnamelist.db telnetopen $+ $sock(%ipname).ip

  set %temp1 $read(data\telnetiplist.db, w, $sock(%ipname).ip)
  set %sockwritename $read(data\telnetnamelist.db, w, * $+ %temp1)

  sockwrite -tn %sockwritename MessageBot Telnet Console Version 1.0 Copyright 2002-2003 MessageBot.net
  sockwrite -tn %sockwritename ========================================================================
  set %test $read(data\registerlist.db,1)
  set %checkpass $gettok($hget(nicks,%test),1,32)
  if (%checkpass == $null) {
    sockwrite -tn %sockwritename ERROR: The databases have not been loaded into memory. Please connect $&
      MessageBot to a server first to load the databases before attempting to login via telnet.
    sockclose %sockwritename
  }
  sockwrite %sockwritename Please login below
  sockwrite %sockwritename Username:
  set %state 1
}

on *:sockclose:telnetopen: {
  set %temp1 $read(data\telnetiplist.db, w, $sock(%ipname).ip)
  set %sockwritename $read(data\telnetnamelist.db, w, * $+ %temp1)
  echo Telnet Connection Closed due to exit by client.
  sockclose %sockwritename
}

on *:sockread:telnetopen: {
  set %temp1 $read(data\telnetiplist.db, w, $sock(%ipname).ip)
  set %sockwritename $read(data\telnetnamelist.db, w, * $+ %temp1)
  if (%state == 1) {
    sockread %username
    if (%username == $null) { halt }
    echo %username
    sockwrite -tn telnetopen Sent username ' $+ %username $+ '
    sockwrite -tn telnetopen Password:
    set %state 2
  }
  if (%state == 2) {
    sockread %password
    if (%password == $null) { halt }
    echo %password
    set %checkpass $gettok($hget(nicks,%username),1,32)
    if (%checkpass != %password) {
      sockwrite -tn telnetopen Invalid login or password.
      sockclose telnetopen
      echo Telnet Connection Closed due to invalid login.
    }
    else {
      sockwrite -tn telnetopen Password accepted for user ' $+ %username $+ '
    }
  }
}


I'm trying to make it so that it can be an unlimited number of sessions going on at once, and i was thinking, "ok well i will just store the users ip address, and then make their individual socket name out of the ip address and be able to do it that way!" and then i realized in order to grab the persons IP i have to have their socket name in the first place, so everything was going fine until i realized i was using the variable %ipname to specify their socketname to grab their SECOND socket name off of the telnetnamelist.db file. Which is a completely worthless, and i dont know why i didnt realize that before i went and wrote all that.

I figure the only way to be able to do this right, is to be able to grab the persons IP during the on *:sockread part of the code before anything else is initiated, then i can use the ip to search the file telnetnamelist.db and can get their socketname from there... and i cant find anything to do this.....

Last edited by Hammer; 02/03/03 04:11 PM.