Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Problem
#1
Ok this is from unsupported version of MS I know... its the sql version but...

after I go on and make 1 npc and add it to the map... then after I close the server and try to start it back up I guess this error...

---------------------------
Server
---------------------------
Run-time error '3021':

Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record.
---------------------------
OK
---------------------------


Anyone have any ideas whats causing it?
Reply
#2
I deleted the npc I made from the database and then the server loaded up... so I guess its something with the npcs table... but I didnt change anything so I dont know whats up.

EDIT:: Yeah im positive now. I got on made 1 NPC. I logged off and closed the server... I then tried to start the server back up and the error is there.

Also something else I found weird... I named the NPC... "NPC" and it says the name field is 20 bytes... I wouldnt think anything of this... but I got to characters table and the name there is test and it says 4 bytes.... so is it not saving the names of npc right or something?

EDIT2::
Well found the error... ran the source and debugged..
Code:
.FKey = CLng(RS("FKey"))

Highlights that in LoadNPCs. Some reason it isnt loading it right... im not the best understand the code for MySQL but I will mess around with it... if anyone knows why the FKey isnt loading or setting right let me know,.
Reply
#3
Sorry for double post...

I think I found out whats up...

its trying to load all of the npcs 1 to 255... well if I made one then theres only 1 to load... so when it tries to load #2 up then it has an empty set getting the error...

I guess somehow I have to findout how many there are and then have it stop at that. or something
Reply
#4
Just loop it... if the NPCs name is blank, then don't load it...
Reply
#5
I was trying to check if FKey was null but I cant get that to work.

Its the exact same as Items too but items work I dont get that...

I looked at items and it makes them all just leaves the others blank... but npcs only makes the ones you made.

I could make rows for all of them but thats a lot lol
Reply
#6
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:
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
Reply
#7
Thanks I already fixed this... I added in blank records for all of them... it automatically did that for items and stuff but not npcs some reason.

Anyways I got it working.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)