02-12-2007, 10:07 PM
So, someone think they can help me optimize it?
In Pokemon, we all know we have PC Boxes.
Well, PDoA's goal is to recreate Pokemon to the best of it's ability. So, I code PC Boxes.
This code's worked once before, I just found it and readded it.
PC Boxes are written on Account Creation, and on log in[for existing users] if it doesn't already exist.
The code:
Now, I realize I've got over 1000, maybe 2000, I wouldn't be so shocked as to guess 5000+ strings written.
Even with DoEvents thrown in there, it lags the server crazy when these boxes are written.
Anyone think they can help me solve this?
In Pokemon, we all know we have PC Boxes.
Well, PDoA's goal is to recreate Pokemon to the best of it's ability. So, I code PC Boxes.
This code's worked once before, I just found it and readded it.
PC Boxes are written on Account Creation, and on log in[for existing users] if it doesn't already exist.
The code:
Code:
Option Explicit
Public Const MAX_BOXES = 20
Public Const POKEMON_PER_BOX = 30
Sub WriteNewBoxes(index)
Dim Filename As String, Name As String, i As Byte, j As Byte
Dim n As Byte, m As Long
Filename = App.Path & "\trainers\(Info)\PC Boxes\"
Name = GetPlayerName(index)
Filename = Filename & Name & "\"
Call MkDir(Filename)
For i = 1 To MAX_BOXES
For j = 1 To POKEMON_PER_BOX
Call PutVar(Filename & "Box" & i & ".ini", "Pokemon" & j, "Name", "0")
Call PutVar(Filename & "Box" & i & ".ini", "Pokemon" & j, "Number", "0")
Call PutVar(Filename & "Box" & i & ".ini", "Pokemon" & j, "Type", "0")
Call PutVar(Filename & "Box" & i & ".ini", "Pokemon" & j, "Type2", "0")
Call PutVar(Filename & "Box" & i & ".ini", "Pokemon" & j, "Ability", "0")
Call PutVar(Filename & "Box" & i & ".ini", "Pokemon" & j, "HP", "0")
Call PutVar(Filename & "Box" & i & ".ini", "Pokemon" & j, "Held Item", "0")
Call PutVar(Filename & "Box" & i & ".ini", "Pokemon" & j, "Attack", "0")
Call PutVar(Filename & "Box" & i & ".ini", "Pokemon" & j, "Defense", "0")
Call PutVar(Filename & "Box" & i & ".ini", "Pokemon" & j, "SpAtk", "0")
Call PutVar(Filename & "Box" & i & ".ini", "Pokemon" & j, "SpDef", "0")
Call PutVar(Filename & "Box" & i & ".ini", "Pokemon" & j, "Speed", "0")
Call PutVar(Filename & "Box" & i & ".ini", "Pokemon" & j, "Happiness", "0")
Call PutVar(Filename & "Box" & i & ".ini", "Pokemon" & j, "Level", "0")
Call PutVar(Filename & "Box" & i & ".ini", "Pokemon" & j, "Nature", "0")
Call PutVar(Filename & "Box" & i & ".ini", "Pokemon" & j, "OT", "0")
Call PutVar(Filename & "Box" & i & ".ini", "Pokemon" & j, "IDNo", "0")
Call PutVar(Filename & "Box" & i & ".ini", "Pokemon" & j, "TNL", "0")
Call PutVar(Filename & "Box" & i & ".ini", "Pokemon" & j, "LevelMet", "0")
Call PutVar(Filename & "Box" & i & ".ini", "Pokemon" & j, "Cool", "0")
Call PutVar(Filename & "Box" & i & ".ini", "Pokemon" & j, "Tough", "0")
Call PutVar(Filename & "Box" & i & ".ini", "Pokemon" & j, "Beauty", "0")
Call PutVar(Filename & "Box" & i & ".ini", "Pokemon" & j, "Cute", "0")
Call PutVar(Filename & "Box" & i & ".ini", "Pokemon" & j, "Smart", "0")
Call PutVar(Filename & "Box" & i & ".ini", "Pokemon" & j, "Sheen", "0")
Call PutVar(Filename & "Box" & i & ".ini", "Pokemon" & j, "Gender", "0")
Call PutVar(Filename & "Box" & i & ".ini", "Pokemon" & j, "Ball", "0")
Call PutVar(Filename & "Box" & i & ".ini", "Pokemon" & j, "Status", "0")
Call PutVar(Filename & "Box" & i & ".ini", "Pokemon" & j, "Condition", "0")
Call PutVar(Filename & "Box" & i & ".ini", "Pokemon" & j, "Pokerus", "0")
Call PutVar(Filename & "Box" & i & ".ini", "Pokemon" & j, "Confused", "0")
Call PutVar(Filename & "Box" & i & ".ini", "Pokemon" & j, "Attract", "0")
Call PutVar(Filename & "Box" & i & ".ini", "Pokemon" & j, "Exp", "0")
Call PutVar(Filename & "Box" & i & ".ini", "Pokemon" & j, "MaxHP", "0")
Call PutVar(Filename & "Box" & i & ".ini", "Pokemon" & j, "Shiney", "0")
DoEvents
'moves
For m = 1 To 4
Call PutVar(Filename & "Box" & i & ".ini", "Pokemon" & j & "Move" & m, "Number", "0")
Call PutVar(Filename & "Box" & i & ".ini", "Pokemon" & j & "Move" & m, "PP", "0")
Call PutVar(Filename & "Box" & i & ".ini", "Pokemon" & j & "Move" & m, "Max PP", "0")
Next m
Next j
DoEvents
Next i
End Sub
Now, I realize I've got over 1000, maybe 2000, I wouldn't be so shocked as to guess 5000+ strings written.
Even with DoEvents thrown in there, it lags the server crazy when these boxes are written.
Anyone think they can help me solve this?