Mirage Engine
accessing an offline account - Printable Version

+- Mirage Engine (https://mirage-engine.uk/forums)
+-- Forum: Mirage Source (Nostalgia) (https://mirage-engine.uk/forums/forumdisplay.php?fid=61)
+--- Forum: Archive (2006-2011) (https://mirage-engine.uk/forums/forumdisplay.php?fid=18)
+---- Forum: Resources (https://mirage-engine.uk/forums/forumdisplay.php?fid=49)
+---- Thread: accessing an offline account (/showthread.php?tid=188)



accessing an offline account - Dr. Spoon - 16-07-2006

with only the character name
ONLY SERVER SIDE
make a new module and name it modOfflineAccount
add all of this code to it
Code:
Type TempAccountRec
    Login As String * NAME_LENGTH
    Password As String * NAME_LENGTH
    Char(1 To MAX_CHARS) As PlayerRec
End Type

Public TempAccount As TempAccountRec


Sub GetChar(ByVal Name As String)
Dim f As Long
Dim s As String, X As Long
    f = FreeFile
    frmServer.fileList.Path = App.Path & "\accounts"
    For X = 0 To frmServer.fileList.ListCount
        Open (frmServer.fileList.Path & "/" & frmServer.fileList.List(X)) For Input As #f
            Do While Not EOF(f)
                Input #f, s
                If Trim(LCase(s)) = ("name=" & Trim(LCase(Name))) Then
                    Close #f
                    Call LoadTempAccount(frmServer.fileList.List(X))
                    Exit Sub
                End If
            Loop
        Close #f
    Next X
End Sub
need to make a file list on frmServer named fileList
set its filter to *.ini
set its visibility to false
then you need these two subs but with your specific code in them..
Code:
Sub LoadTempAccount(ByVal Name As String)
Dim FileName As String
Dim n As Long, X As Byte
    FileName = App.Path & "\accounts\" & Trim(Name)
    TempAccount.Login = Trim(GetVar(FileName, "GENERAL", "Login"))
    TempAccount.Password = Trim(GetVar(FileName, "GENERAL", "Password"))
    For X = 1 To MAX_CHARS
        With TempAccount.Char(X)
        'place a copy of your load player Sub here
        End With
    Next X
End Sub

Sub ClearTempAccount()
Dim n As Long, X As Byte
    TempAccount.Login = ""
    TempAccount.Password = ""
    For X = 1 To MAX_CHARS
        With tempAccount.Char(X)
        'place a copy of your clear player Sub here
        End With
    Next X
End Sub
now what this will do is find out which accoutn the character name belongs to then load in that account to the TempAccount array
allowing you to change anything in it you wish to change then you
can save it and be done with it
the saveing sub is something you can figure out on your own from
the code provided i am sure
the clear TempAccount sub is used to erase the info server side

enjoy


- Xentar - 16-07-2006

IDOL! lets try it right now ^^, thx man


- Dr. Spoon - 19-07-2006

well how did it work out for you?
just curious..
would like some sort of feed back


- Leighland - 19-07-2006

I'm messing with this right now, I'll tell ya how it works out Smile


- Leighland - 19-07-2006

Code:
Sub GetChar(ByVal Name As String)
Dim f As Long
Dim s As String, X As Long
    f = FreeFile
    frmServer.fileList.Path = App.Path & "\accounts"
    For X = 0 To frmServer.fileList.ListCount
        Open (frmServer.fileList.Path & "/" & frmServer.fileList.List(X)) For Input As #f
            Do While Not EOF(f)
                Input #f, s
                If Trim(LCase(s)) = ("name=" & Trim(LCase(Name))) Then
                    Close #f
                    Call LoadTempAccount(frmServer.fileList.List(X))
                    Exit Sub
                End If
            Loop
        Close #f
    Next X
End Sub

This gives me an error on this line:

Code:
Open (frmServer.fileList.Path & "/" & frmServer.fileList.List(X)) For Input As #f
- Path not found.

Tried this and it also fails to work:
Code:
Open (frmServer.fileList.Path & "\" & frmServer.fileList.List(X)) For Input As #f
- File not found


- Obsidian - 19-07-2006

if you've changed your accounts path... or the accounts folder doesn't exist, that could be the reason why.

You might also try

frmServer.fileList.Path = App.Path & "accounts"


That might fix it. Just play with that for a bit and see what you can do.


- Leighland - 19-07-2006

Meh I gave up ... confused myself... I'l take anothe rstab at it when I'm not tired lol.


- Gilgamesch - 21-07-2006

is there a "index" for this tem account? :/ cuz tahts what i need if i call a sub or function for example, it always is like that: getplayersomething(index as long, bla bla)



oh, and how can i get the charnum for the char?

thanks


- Dr. Spoon - 22-07-2006

if you only want the char number of the specific character all you would
have to do is scan the right account for the char name to see which one
matches it
this code takes the characters name and finds the right acocunt by scanning them all
if you want to find the specific char number just add in something like this
to the already present GetChar sub it would go into the spot where it calls
the load temp account
Code:
dim File as string
File = app.path & "\" & frmserver.FileList.list(frmserver.FileList.listindex)
for x = 1 to Max_Chars
    If getvar(File, "CHAR" & X, "Name") = Name then
        CharNum = X
        Exit Sub
    End If
next x

that should about do it
any more questions?

and no there is no index for this acocunt becaouse it isn't connected via a client i am sureyou could set one up for it


- Gilgamesch - 22-07-2006

since you asked if we got more questions, how would you set that up? Big Grin


- Dr. Spoon - 24-07-2006

add something like this
to the already present GetChar sub it would go into the spot where it calls
the load temp account

that is what i said in that short narative above the bit of code
that is were you would put it and it would retrieve the charNum ..
which is what you requested

are you having any specific problems with any part of the code?