Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Folder Saving
#1
Ok I was going to make binary files, but I can't find the tutorial I was wanting to use for it. So instead until' then I want to have each players profile saved into their own folder such as (PlayersName folder) inside = playersName.ini, playerE-mail.ini, & PlayersPet.ini.

If anyone could help me out with it I would be extremely appreciative.

Thanks, later,
Korrey D.
Reply
#2
Look at the way the accounts are saved, and then chage it the way you want. I'd like to have dived more into this for ya, but, I'm tired and want to sleep.

EDIT: Server Side you'd need to change to Sub SavePlayer and the Sub LoadPlayer. Dunno hwo to do it yet ,, cause I'm not really familliar yet with saving and loading of files
Reply
#3
Back when I made Playerworlds games, I used to use folders to sort quests and such. Only mine was kinda reversed.. where I had the name of the quest as a folder, then a (playername).ini that was created.. a kind of flag system.

Mine were set up like this: (Taken from my PW Main.AS)

Code:
Sub OnScriptedTile(Player)

Dim FileSystem,filename
Filename = GetPlayerName(player)
Set FileSystem = CreateObject("Scripting.FileSystemObject")

'... etc


Code:
Case 20

    If GetPlayerX(player) = 9 and GetPlayerY(player) = 3 Then

        If FileSystem.FolderExists("C:\Documents and Settings\Owner\My Documents\Player Worlds\The Plane\Server\accounts\bank\Cookbook\" & filename) Then
        Call PlayerMessage(player,"You have already read this book!",15)
        Else
        Call PlayerMessage(player,"You browse the pages of the cookbook.",10)
        Call PlayerMessage(player,"[+100 EXP]",15)
        Call GivePlayerEXP(player, +100)
        Call CheckPlayerLevel(Player)
        Call FileSystem.CreateFolder("C:\Documents and Settings\Owner\My Documents\Player Worlds\The Plane\Server\accounts\bank\Cookbook\" & filename)    
        End If
    End If
Reply
#4
ok I was looking at the code that you posted and the code that is already in miragesource, and I'm not sure but I'm not really around my VB6 right now so do you think this will work?
Code:
Sub SavePlayer(ByVal Index As Long)
Dim FileName As String
Dim i As Long
Dim n As Long

    FileName = App.Path & "\Accounts\" & Trim(player(index).Name) & Trim(Player(Index).Login) & ".ini"
    
    Call PutVar(FileName, "GENERAL", "Login", Trim(Player(Index).Login))
    Call PutVar(FileName, "GENERAL", "Password", Trim(Player(Index).Password))

    For i = 1 To MAX_CHARS
        ' General
        Call PutVar(FileName, "CHAR" & i, "Name", Trim(Player(Index).Char(i).Name))
        Call PutVar(FileName, "CHAR" & i, "Class", STR(Player(Index).Char(i).Class))
        Call PutVar(FileName, "CHAR" & i, "Sex", STR(Player(Index).Char(i).Sex))
        Call PutVar(FileName, "CHAR" & i, "Sprite", STR(Player(Index).Char(i).Sprite))
        Call PutVar(FileName, "CHAR" & i, "Level", STR(Player(Index).Char(i).Level))
        Call PutVar(FileName, "CHAR" & i, "Exp", STR(Player(Index).Char(i).Exp))
        Call PutVar(FileName, "CHAR" & i, "Access", STR(Player(Index).Char(i).Access))
        Call PutVar(FileName, "CHAR" & i, "PK", STR(Player(Index).Char(i).PK))
        Call PutVar(FileName, "CHAR" & i, "Guild", STR(Player(Index).Char(i).Guild))
        
        ' Vitals
        Call PutVar(FileName, "CHAR" & i, "HP", STR(Player(Index).Char(i).HP))
        Call PutVar(FileName, "CHAR" & i, "MP", STR(Player(Index).Char(i).MP))
        Call PutVar(FileName, "CHAR" & i, "SP", STR(Player(Index).Char(i).SP))
        
        ' Stats
        Call PutVar(FileName, "CHAR" & i, "STR", STR(Player(Index).Char(i).STR))
        Call PutVar(FileName, "CHAR" & i, "DEF", STR(Player(Index).Char(i).DEF))
        Call PutVar(FileName, "CHAR" & i, "SPEED", STR(Player(Index).Char(i).SPEED))
        Call PutVar(FileName, "CHAR" & i, "MAGI", STR(Player(Index).Char(i).MAGI))
        Call PutVar(FileName, "CHAR" & i, "POINTS", STR(Player(Index).Char(i).POINTS))
        
        ' Worn equipment
        Call PutVar(FileName, "CHAR" & i, "ArmorSlot", STR(Player(Index).Char(i).ArmorSlot))
        Call PutVar(FileName, "CHAR" & i, "WeaponSlot", STR(Player(Index).Char(i).WeaponSlot))
        Call PutVar(FileName, "CHAR" & i, "HelmetSlot", STR(Player(Index).Char(i).HelmetSlot))
        Call PutVar(FileName, "CHAR" & i, "ShieldSlot", STR(Player(Index).Char(i).ShieldSlot))
        
        ' Check to make sure that they aren't on map 0, if so reset'm
        If Player(Index).Char(i).Map = 0 Then
            Player(Index).Char(i).Map = START_MAP
            Player(Index).Char(i).x = START_X
            Player(Index).Char(i).y = START_Y
        End If
            
        ' Position
        Call PutVar(FileName, "CHAR" & i, "Map", STR(Player(Index).Char(i).Map))
        Call PutVar(FileName, "CHAR" & i, "X", STR(Player(Index).Char(i).x))
        Call PutVar(FileName, "CHAR" & i, "Y", STR(Player(Index).Char(i).y))
        Call PutVar(FileName, "CHAR" & i, "Dir", STR(Player(Index).Char(i).Dir))
        
        ' Inventory
        For n = 1 To MAX_INV
            Call PutVar(FileName, "CHAR" & i, "InvItemNum" & n, STR(Player(Index).Char(i).Inv(n).Num))
            Call PutVar(FileName, "CHAR" & i, "InvItemVal" & n, STR(Player(Index).Char(i).Inv(n).Value))
            Call PutVar(FileName, "CHAR" & i, "InvItemDur" & n, STR(Player(Index).Char(i).Inv(n).Dur))
        Next n
        
        ' Spells
        For n = 1 To MAX_PLAYER_SPELLS
            Call PutVar(FileName, "CHAR" & i, "Spell" & n, STR(Player(Index).Char(i).Spell(n)))
        Next n
    Next i

Sub LoadPlayer(ByVal Index As Long, ByVal Name As String)
Dim FileName As String
Dim i As Long
Dim n As Long

    Call ClearPlayer(Index)
    
    FileName = App.Path & "\Accounts\" & Trim(Player(Index).Name) & Trim(Name) & ".ini"

    Player(Index).Login = GetVar(FileName, "GENERAL", "Login")
    Player(Index).Password = GetVar(FileName, "GENERAL", "Password")

    For i = 1 To MAX_CHARS
        ' General
        Player(Index).Char(i).Name = GetVar(FileName, "CHAR" & i, "Name")
        Player(Index).Char(i).Sex = Val(GetVar(FileName, "CHAR" & i, "Sex"))
        Player(Index).Char(i).Class = Val(GetVar(FileName, "CHAR" & i, "Class"))
        Player(Index).Char(i).Sprite = Val(GetVar(FileName, "CHAR" & i, "Sprite"))
        Player(Index).Char(i).Level = Val(GetVar(FileName, "CHAR" & i, "Level"))
        Player(Index).Char(i).Exp = Val(GetVar(FileName, "CHAR" & i, "Exp"))
        Player(Index).Char(i).Access = Val(GetVar(FileName, "CHAR" & i, "Access"))
        Player(Index).Char(i).PK = Val(GetVar(FileName, "CHAR" & i, "PK"))
        Player(Index).Char(i).Guild = Val(GetVar(FileName, "CHAR" & i, "Guild"))
        
        ' Vitals
        Player(Index).Char(i).HP = Val(GetVar(FileName, "CHAR" & i, "HP"))
        Player(Index).Char(i).MP = Val(GetVar(FileName, "CHAR" & i, "MP"))
        Player(Index).Char(i).SP = Val(GetVar(FileName, "CHAR" & i, "SP"))
        
        ' Stats
        Player(Index).Char(i).STR = Val(GetVar(FileName, "CHAR" & i, "STR"))
        Player(Index).Char(i).DEF = Val(GetVar(FileName, "CHAR" & i, "DEF"))
        Player(Index).Char(i).SPEED = Val(GetVar(FileName, "CHAR" & i, "SPEED"))
        Player(Index).Char(i).MAGI = Val(GetVar(FileName, "CHAR" & i, "MAGI"))
        Player(Index).Char(i).POINTS = Val(GetVar(FileName, "CHAR" & i, "POINTS"))
        
        ' Worn equipment
        Player(Index).Char(i).ArmorSlot = Val(GetVar(FileName, "CHAR" & i, "ArmorSlot"))
        Player(Index).Char(i).WeaponSlot = Val(GetVar(FileName, "CHAR" & i, "WeaponSlot"))
        Player(Index).Char(i).HelmetSlot = Val(GetVar(FileName, "CHAR" & i, "HelmetSlot"))
        Player(Index).Char(i).ShieldSlot = Val(GetVar(FileName, "CHAR" & i, "ShieldSlot"))
        
        ' Position
        Player(Index).Char(i).Map = Val(GetVar(FileName, "CHAR" & i, "Map"))
        Player(Index).Char(i).x = Val(GetVar(FileName, "CHAR" & i, "X"))
        Player(Index).Char(i).y = Val(GetVar(FileName, "CHAR" & i, "Y"))
        Player(Index).Char(i).Dir = Val(GetVar(FileName, "CHAR" & i, "Dir"))
        
        ' Check to make sure that they aren't on map 0, if so reset'm
        If Player(Index).Char(i).Map = 0 Then
            Player(Index).Char(i).Map = START_MAP
            Player(Index).Char(i).x = START_X
            Player(Index).Char(i).y = START_Y
        End If
        
        ' Inventory
        For n = 1 To MAX_INV
            Player(Index).Char(i).Inv(n).Num = Val(GetVar(FileName, "CHAR" & i, "InvItemNum" & n))
            Player(Index).Char(i).Inv(n).Value = Val(GetVar(FileName, "CHAR" & i, "InvItemVal" & n))
            Player(Index).Char(i).Inv(n).Dur = Val(GetVar(FileName, "CHAR" & i, "InvItemDur" & n))
        Next n
        
        ' Spells
        For n = 1 To MAX_PLAYER_SPELLS
            Player(Index).Char(i).Spell(n) = Val(GetVar(FileName, "CHAR" & i, "Spell" & n))
        Next n
    Next i
End Sub
Reply
#5
You forgot the [/code].
Reply
#6
I fixed it.
Reply
#7
so what your saying is something like this?
Code:
Trim(player(index).Name) & "\" & Trim(Player(Index).Login)
Reply
#8
I told you Eric IF I knew how I did it I would show you, but I can not remember what I had coded to make the file system work, so I will see if I can get the hard drive working and retrieve it but I doubt it.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)