Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Runtime error 5: Invailed call or argument

Hi,

i have downloaded a game with his own database.. if i try to pvp ( player vs player) the game crashes and if i check debug he comes up with this error: Runtime error 5: Invailed call or argument.
what does it mean and how can i fix it?
Here is my code:

(Line producing crash is denoted by ==> and <==)


Public Function pAttackSkill(index As Integer)
If PlayerData(index).charstate = 10 Then Exit Function
Dim SkillDataBase As Recordset
Dim SkillDataBase2 As Recordset
Dim BookMark As Variant
Dim ObjectID(1 To 9) As String
Dim SkillID As String
Dim CastingID As String
Dim Crit As String
Dim AfterState As String
Dim Damage As String
Dim Damage2 As String
Dim Damage3 As String
Dim NumTargets As Integer
Dim TimerVar As Integer
Dim dmg1 As Double
Dim dmg2 As Double
Dim tdmg As Double
Dim tdmg1 As Double
Dim PMinA As Integer
Dim PMaxA As Integer
Dim SMinA As Integer
Dim SMaxA As Integer
Dim SPer As Integer
Dim Exp As Integer
Dim ndmg As Double
Dim sdmg As Integer
Dim smana As Integer
Dim SkillName As String
Dim SkillName1 As String
Dim attackn As Integer
Dim skill As Integer
OpenSremuDataBase
Set SkillDataBase = DataBases.OpenRecordset("Skills", dbOpenTable) 'DB Table

'dmg1 = ((Rnd * 5000) + 1000)
ObjectID(1) = PlayerData(index).AttackingID
SkillID = PlayerData(index).AttackSkillID
SkillDataBase.index = "Id"
SkillDataBase.Seek ">=", SkillID
Dim db As ADODB.Connection
Dim rs As ADODB.Recordset
Dim rs3 As ADODB.Recordset
Set db = New ADODB.Connection
Set rs = New ADODB.Recordset
Set rs3 = New ADODB.Recordset
db.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "DataBaseSremuDatabase.mdb;"
Dim tablolar
Dim tablo
tablolar = "Skilldata_10000|Skilldata_15000|SkillData_5000|Skilldata_20000|Skilldata_25000|Skilldata_30000|Skilldata_35000"
tablo = Split(tablolar, "|")

Dim t As Integer
For t = 0 To UBound(tablo)
rs.Open "SELECT * FROM " & tablo(t) & " WHERE Alan2 = '" & skill & "'", db, adOpenKeyset, adLockOptimistic
If rs.RecordCount > 0 Then
SkillName1 = rs("Alan4")
smana = rs("Mana")
SMinA = rs("Min")
SMaxA = rs("Max")
SPer = rs("Per")
'bulduk
Exit For
End If
rs.Close
Next t

With SkillDataBase
attackn = !NumberofAttacks
End With


If PlayerData(index).ArtMP < (smana) Then
Call LowMana(index)
Exit Function
End If
fData = "0B00"
fData = fData & "A633"
fData = fData & "0000"
fData = fData & PlayerData(index).CharID
fData = fData & "100002"
fData = fData & Inverse(DecToHexLong(PlayerData(index).ArtMP - (smana)))
'PlayerData(index).MP = PlayerData(index).MP - (sMana) 'take away mp cost
Dim mps As Integer
PlayerData(index).ArtMP = PlayerData(index).ArtMP - (smana)
mps = PlayerData(index).ArtMP

For i = 1 To UBound(PlayerData)
If PlayerData(i).Ingame = True Then
frmMain.GameSocket(i).SendData cv_StringFromHex(fData)
End If
Next i

'-----------------------
'Dim Exp As Integer

SkillID = PlayerData(index).AttackSkillID

NumTargets = 1
fData = "45B2"
fData = fData & "0000"
fData = fData & "0102"
fData = fData & SkillID
fData = fData & PlayerData(index).CharID
CastingID = (Inverse((DecToHexLong(Int(Rnd * 1548575) + 65536))))
fData = fData & CastingID
fData = fData & ObjectID(1)
fData = fData & "00"

pLen = (Len(fData) - 8) / 2
fData = WordFromInteger(pLen) & fData
For i = 1 To UBound(PlayerData)
If PlayerData(i).Ingame = True Then
frmMain.GameSocket(i).SendData cv_StringFromHex(fData)
End If
Next i

Select Case SkillName
Case "Cold wave-Arrest"
ColdEffect index, ObjectID(1), SkillID
Exit Function
'then you need to wait the casting time then
Case "Cold wave-Binding"
ColdEffect index, ObjectID(1), SkillID
Exit Function
Case "Cold wave-Shackle"
ColdEffect index, ObjectID(1), SkillID
Exit Function
Case "Cold Wave - Freeze"
ColdEffect index, ObjectID(1), SkillID
Exit Function
End Select
'then you need to wait the casting time then

fData = "05B5"
fData = fData & "0000"
fData = fData & "01"
fData = fData & CastingID
fData = fData & ObjectID(1)
fData = fData & "01"
fData = fData & ByteFromInteger(attackn) 'Num Attacks
fData = fData & ByteFromInteger(NumTargets)
For x = 1 To NumTargets
fData = fData & ObjectID(1) 'was x
Dim Y As Integer
For Y = 1 To attackn
If AfterState = "80" Then Exit For
If ((Rnd * 10) + 1) > 10 Then 'the 10 should be the crit of the weapon
Crit = "02"
Else
Crit = "01"
End If

For i = 1 To 500 'Number of mobs in area
If Y > 1 Then

Dim s As String
Dim skill2
Dim d As String
Dim ReSkillname As String
If Left(SkillName1, 20) = "SKILL_CH_SPEAR_CHAIN" Then ' Combos Damage calc

s = Right(SkillName1, 4)
skill2 = Left(SkillName1, Len(SkillName1) - 5)
d = CStr(CInt(Y) & s)
ReSkillname = (skill2 & d)

ElseIf Left(SkillName1, 20) = "SKILL_CH_SWORD_CHAIN" Then

s = Right(SkillName1, 4)
skill2 = Left(SkillName1, Len(SkillName1) - 5)
d = CStr(CInt(Y) & s)

ReSkillname = (skill2 & d)

Else
s = Right(SkillName1, 3)
[b]==>skill2 = Left(SkillName1, Len(SkillName1) - 3)<==[/b]
d = CStr(CInt(Y) & s)

ReSkillname = (skill2 & d)

End If
rs3.Open "SELECT * FROM " & tablo(t) & " WHERE Alan4 = '" & ReSkillname & "'", db, adOpenKeyset, adLockOptimistic

If rs3.RecordCount > 0 Then
SMinA = rs3("Min")
SMaxA = rs3("Max")
SPer = rs3("Per")
End If
rs3.Close
If SMinA = "0" Or SMaxA = "0" Then
SMinA = PlayerData(index).MaxPhyAtk
SMaxA = PlayerData(index).MinPhyAtk
SendNotice "Skill Error"
End If

End If

PMaxA = PlayerData(index).MaxPhyAtk + SMaxA
PMinA = PlayerData(index).MinPhyAtk + SMinA
dmg1 = CDbl(Val(PMaxA) * Val(SPer) / 100)
dmg2 = CDbl(Val(PMinA) * Val(SPer) / 100)
ndmg = CDbl(Val(dmg1) - Val(dmg2))
tdmg = CDbl(Val(dmg1 + ndmg))
tdmg1 = ((Rnd * 50) + tdmg)


Dim tdef As Integer
tdef = Mobs(i).pDef
Damage = (tdmg1 - tdef) 'was 2000
If Crit = "02" Then Damage = Damage * 2
If PlayerData(index).Berserking = True Then Damage = Damage * 2
If frmMain.BerserkTimer(index).Enabled = True Then Damage = (Damage * 2)

Damage = Inverse(DecToHex10Long(CLng(Damage)))


Exp = i 'ndex ' right index :)

If ObjectID(1) = Mobs(i).ID Then 'was ObjectID(x)
frmMain.MobWalkTimer.Enabled = False
If Mobs(i).HP <= 0 Then Exit Function
TimerVar = i
Mobs(i).HP = Mobs(i).HP - HexToDec(Inverse(Damage))
If Mobs(i).HP < 0 Then
AfterState = "80"
Mobs(i).Attacking = False
frmMain.mobattack.Enabled = False
deger = 0
'Exit For
'PlayerData(index).SelectedID = ""
Else
AfterState = "00"
End If
Exit For
End If
Next i

fData = fData & AfterState
fData = fData & Crit
fData = fData & Damage
fData = fData & "0000"

Next Y
Next x


pLen = (Len(fData) - 8) / 2
fData = WordFromInteger(pLen) & fData
For i = 1 To UBound(PlayerData)
If PlayerData(i).Ingame = True Then
frmMain.GameSocket(i).SendData cv_StringFromHex(fData)
End If
Next i

'Skill Over
fData = "0200"
fData = fData & "CDB2"
fData = fData & "0000"
fData = fData & "0200"
frmMain.GameSocket(index).SendData cv_StringFromHex(fData)

If AfterState = "80" Then

'SendNotice PlayerData(index).Charname & " KILLED " & Charname

Exit Function

End If

PlayerData(index).UsingSkill = True
PlayerData(index).AttackSkillID = ""
frmMain.AttackDelay(index).Interval = 2200 'skill delay
frmMain.AttackDelay(index).Enabled = True
'frmMain.MobWalkTimer.Enabled = True

End Function

Please help me

Sign In or Register to comment.