runtime error 5- invalid call or argument

  • (2 Pages)
  • +
  • 1
  • 2

27 Replies - 5475 Views - Last Post: 20 June 2009 - 03:18 AM Rate Topic: -----

#1 speederzz  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 09-May 09

runtime error 5- invalid call or argument

Posted 09 May 2009 - 05:33 AM

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 <==)

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)
	   ==> skill2 = Left(SkillName1, Len(SkillName1) - 3) <==
		d = CStr(CInt(y) & s)

		ReSkillname = (skill2 & d)


Can someone help me?

Is This A Good Question/Topic? 0
  • +

Replies To: runtime error 5- invalid call or argument

#2 Nikhil_07n  Icon User is offline

  • The cheese stands alone..
  • member icon

Reputation: 54
  • View blog
  • Posts: 2,490
  • Joined: 09-January 09

Re: runtime error 5- invalid call or argument

Posted 09 May 2009 - 11:37 AM

maybe the value (Len(SkillName1) - 3) is evaluating to negative.
Was This Post Helpful? 0
  • +
  • -

#3 speederzz  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 09-May 09

Re: runtime error 5- invalid call or argument

Posted 10 May 2009 - 04:50 AM

I've tried this:

skill2 = Left(SkillName1, Len(SkillName1) - 9)

and this:

skill2 = Left(SkillName1, Len(SkillName1) - 1)


But that didnt work either.
Maybe i need to add something after
Dim skill2
?
Was This Post Helpful? 0
  • +
  • -

#4 firebolt  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 93
  • View blog
  • Posts: 5,561
  • Joined: 20-February 09

Re: runtime error 5- invalid call or argument

Posted 10 May 2009 - 06:08 AM

Do:
skill2 = Left(SkillName1, Len(SkillName1) - Val(3))


Was This Post Helpful? 0
  • +
  • -

#5 thava  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 180
  • View blog
  • Posts: 1,607
  • Joined: 17-April 07

Re: runtime error 5- invalid call or argument

Posted 10 May 2009 - 07:29 PM

did you notice the statement of nikhil

this means that skillname1 should return empty string so the problem is some where else in your coding
Was This Post Helpful? 0
  • +
  • -

#6 firebolt  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 93
  • View blog
  • Posts: 5,561
  • Joined: 20-February 09

Re: runtime error 5- invalid call or argument

Posted 10 May 2009 - 11:42 PM

good 'ol If statement should do it. :)
Was This Post Helpful? 0
  • +
  • -

#7 speederzz  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 09-May 09

Re: runtime error 5- invalid call or argument

Posted 11 May 2009 - 09:39 AM

I didn't post the full code, because the code is very long.
Skillname1 is a string in this code. It is:
Dim SkillName1 As String


The code of firebolt didnt work. I think i need to add something after
Dim skill2
like
Dim skill2 as String
but i dont know.
Was This Post Helpful? 0
  • +
  • -

#8 thava  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 180
  • View blog
  • Posts: 1,607
  • Joined: 17-April 07

Re: runtime error 5- invalid call or argument

Posted 11 May 2009 - 06:16 PM

you still in the wrong way there is nothing in skill2

skillname1 should return empty string so the problem is some where else in your coding
Was This Post Helpful? 0
  • +
  • -

#9 speederzz  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 09-May 09

Re: runtime error 5- invalid call or argument

Posted 12 May 2009 - 08:22 AM

View Postthava, on 11 May, 2009 - 05:16 PM, said:

you still in the wrong way there is nothing in skill2

skillname1 should return empty string so the problem is some where else in your coding


I've tried this:
Dim skillname1
But that didnt work. Do I need to publish the full code?
Was This Post Helpful? 0
  • +
  • -

#10 thava  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 180
  • View blog
  • Posts: 1,607
  • Joined: 17-April 07

Re: runtime error 5- invalid call or argument

Posted 12 May 2009 - 04:51 PM

yes
Was This Post Helpful? 0
  • +
  • -

#11 speederzz  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 09-May 09

Re: runtime error 5- invalid call or argument

Posted 13 May 2009 - 07:06 AM

Ok, here it is:

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 & "\DataBase\SremuDatabase.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)
==> skill2 = Left(SkillName1, Len(SkillName1) - 3) <==
		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


I hope you can fix my problem:)
Was This Post Helpful? 0
  • +
  • -

#12 thava  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 180
  • View blog
  • Posts: 1,607
  • Joined: 17-April 07

Re: runtime error 5- invalid call or argument

Posted 14 May 2009 - 06:52 PM

   If rs.RecordCount > 0 Then
		SkillName1 = rs("Alan4")
		If len(skillname1)<=3 then
		   Msgbox skillname1
		End If
		smana = rs("Mana")
		SMinA = rs("Min")
		SMaxA = rs("Max")
		SPer = rs("Per")
			'bulduk
		Exit For
   End If



hope to change your code here
Was This Post Helpful? 0
  • +
  • -

#13 speederzz  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 09-May 09

Re: runtime error 5- invalid call or argument

Posted 15 May 2009 - 07:37 AM

I've tried it, but it didnt work. But now i've switch this:
Else
		s = Right(SkillName1, 3)
		skill2 = Left(SkillName1, Len(SkillName1) - 3)		 d = CStr(CInt(Y) & s)

		ReSkillname = (skill2 & d)

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


into this:
Else
		s = Right(SkillName1, 3)
		skill2 = Left(SkillName1, Len(SkillName1) - 3) 
		d = CStr(CInt(Y) & s)

		ReSkillname = (skill2 & d)


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

I havent got anymore a runtime error 5, but now i get this error: Compile error: Next without For. But this is already coded. This are the errors:(The errors are denoted by ==> and <==)
rs3.Open "SELECT * FROM " & "Chinnese_Skills" & " WHERE Alan4 = '" & skill2 & "'", 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 " & PlayerData(index).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
Can you help please?
Was This Post Helpful? 0
  • +
  • -

#14 thava  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 180
  • View blog
  • Posts: 1,607
  • Joined: 17-April 07

Re: runtime error 5- invalid call or argument

Posted 16 May 2009 - 02:50 AM

i told that you have to change your logic there ok here is some changes reply me whether will it works
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 & "\DataBase\SremuDatabase.mdb;"
	Dim tablolar
	Dim tablo
	tablolar = & #34;Skilldata_10000|Skilldata_15000|SkillData_5000|Skilldata_20000|Skilldata_250
00|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")
'**********************************************
'********changes add to your code
'**********************************************
if len(skillname1)<=3 then
	msgbox "Your skill Name is strictly less than the minimum length"
	msgbox SkillName1 
	SkillName1 = " Not a valid Skill"
	msgbox SkillName1 
end if
'*************************************************

		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)
==> skill2 = Left(SkillName1, Len(SkillName1) - 3) <==
		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



copy and paste the above code in your form now run if the message box wil raise then you have to set a different logic on that area or a default skill in the if condition

This post has been edited by thava: 16 May 2009 - 02:51 AM

Was This Post Helpful? 1
  • +
  • -

#15 speederzz  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 09-May 09

Re: runtime error 5- invalid call or argument

Posted 16 May 2009 - 04:30 AM

When i try to do my funtion i see this:
Your skill Name is strictly less than the minimum length
And:
Not a valid Skill

And then i get a runtime error 9: subscript out of range:
rs3.Open "SELECT * FROM " & tablo(t) & " WHERE Alan4 = '" & ReSkillname & "'", db, adOpenKeyset, adLockOptimistic
. Fixed. Ive changed it into:
rs3.Open "SELECT * FROM " & "Chinnese_Skills" & " WHERE Alan4 = '" & ReSkillname & "'", db, adOpenKeyset, adLockOptimistic
But now I have again a runtime error 5
skill2 = Left(SkillName1, Len(SkillName1) - 3)
So does this mean that the database is wrong?

This post has been edited by speederzz: 16 May 2009 - 06:42 AM

Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2