16-12-2006, 10:37 PM
I'm not sure if it's a problem w/ the DateBase, almost sure it is not. Probly is your code or the database is not fully w/ blank npcs. I got blank 307 and it was totaly messedup(for me). This is the sub I use:
If your npcs table is not full you need to add every single blank npc by hand, or use this sub I did(CheckNpcs) a while ago, only once:
I'm not sure if you have this sub under here. If you don't add it:
Code:
Sub LoadNpcs()
Dim I As Long
Dim J As Long
Dim cCount As Long
Dim RS As ADODB.Recordset
'Call CheckNpcs
'Setup database stuff
Set RS = New ADODB.Recordset
RS.Open "SELECT * FROM npcs;", Conn_Server, adOpenStatic, adLockReadOnly
If RS.EOF Then Exit Sub
RS.MoveFirst
For I = 1 To MAX_NPCS
With Npc(RS("FKey"))
.FKey = CLng(RS("FKey"))
.Name = Trim$(CStr(RS("Name")))
.AttackSay = Trim$(CStr(RS("AttackSay")))
If CLng(RS("Big")) = 1 Then
.Big = True
Else
.Big = False
End If
.Sprite = CLng(RS("Sprite"))
.SpawnSecs = CLng(RS("SpawnSecs"))
.Behavior = CLng(RS("Behavior"))
.Range = CLng(RS("Range"))
For J = 1 To 10
.DropChance(J) = CLng(RS("Drop" & J & "Chance"))
.DropItem(J) = CLng(RS("DropItem" & J))
.DropItemValue(J) = CLng(RS("DropItem" & J & "Value"))
Next J
.STR = CLng(RS("STR"))
.DEF = CLng(RS("DEF"))
.SPEED = CLng(RS("SPEED"))
.MAGI = CLng(RS("MAGI"))
.DEX = CLng(RS("DEX"))
.AGI = CLng(RS("AGI"))
.StartHP = CLng(RS("StartHP"))
.ExpGiven = CLng(RS("ExpGiven"))
.QuestID = CLng(RS("QuestID"))
.QuestIDFinish = CLng(RS("QuestIDFinish"))
.Attack_with_Poison = Trim$(CStr(RS("Attack_With_Poison")))
.Poison_Length = CLng(RS("Poison_Length"))
.Poison_Vital = CLng(RS("Poison_Vital"))
.Poison_Chance = CLng(RS("Poison_Chance"))
.CanBePoisoned = Trim$(CStr(RS("CanBePoisoned")))
.Shop = CLng(RS("Shop"))
End With
DoEvents
If I MAX_NPCS Then
RS.MoveNext
End If
Next I
RS.Close
Set RS = Nothing
End Sub
If your npcs table is not full you need to add every single blank npc by hand, or use this sub I did(CheckNpcs) a while ago, only once:
Code:
Public Sub CheckNpcs()
'Check to see if max items is how many items there are in the database.
Dim RecCount As Long
Dim I As Long
Dim OffSet As Long
Dim RS As ADODB.Recordset
RecCount = GetRecordCount("Npcs")
OffSet = MAX_NPCS - RecCount
If OffSet = 0 Then Exit Sub
Set RS = New ADODB.Recordset
RS.Open "SELECT * FROM Npcs;", Conn_Client, adOpenStatic, adLockOptimistic
If RS.EOF = True Then Exit Sub
RS.MoveFirst
For I = MAX_NPCS - OffSet + 1 To MAX_NPCS
'thingstoupdate
RS.Update
Next I
RS.Close
Set RS = Nothing
End Sub
I'm not sure if you have this sub under here. If you don't add it:
Code:
Public Function GetRecordCount(dbTable As String, Optional WH As String = "0") As Long
'Setup database stuff
Dim RS As ADODB.Recordset
Dim I As Long
Dim SQL As String
Set RS = New ADODB.Recordset
If WH = "0" Then
SQL = "SELECT * FROM " & dbTable & ";"
Else
SQL = "SELECT * FROM " & dbTable & " WHERE " & WH & ";"
End If
RS.Open SQL, Conn_Client, adOpenStatic, adLockReadOnly
RS.MoveFirst
I = RS.RecordCount
RS.Close
Set RS = Nothing
GetRecordCount = I
End Function