[EO] Type mismatch.

Hello.I am currently trying to code an action bar in EO.I have been doing the packets , and i was trying to test then.I have made a little picture box that when you click it , it will cast the spell on your first hot bar .The data is located server side , here is all the codes :

Client side packets :
This goes at ClientTCP```

Sub LoadHotBar(ByVal slot As Long)
Dim Buffer As clsBuffer
Set Buffer = New clsBuffer

Buffer.WriteLong CLoadHotBar
Buffer.WriteLong slot

SendData Buffer.ToArray()

Set Buffer = Nothing
End Sub

Server side handle data :

Sub HandleHotBar(ByVal Index As Long, ByRef Data() As Byte, ByVal StartAddr As Long, ByVal ExtraVar As Long)
Dim Buffer As clsBuffer
Dim Slot As Long

Set Buffer = New clsBuffer
Buffer.WriteBytes Data()
Slot = Buffer.ReadLong
frmServer.Caption = Slot

SendHotBar Index, Slot

Set Buffer = Nothing
End Sub

ServerTCP:

Sub SendHotBar(ByVal Index As Long, ByVal Slot As Long)
Dim Buffer As clsBuffer
Dim Value As Long
Dim Name As String

Set Buffer = New clsBuffer

Name = GetPlayerName(Index)

Value = GetVar(App.Path & “\data\accounts\hotbar.txt”, Name, “” & Slot)
Buffer.WriteLong SSendHotBar
Buffer.WriteLong Slot
Buffer.WriteLong Value
SendDataTo Index, Buffer.ToArray()

Set Buffer = Nothing

End Sub


Client side handle data:

Private Sub HandleHotBar(ByVal Index As Long, ByRef Data() As Byte, ByVal StartAddr As Long, ByVal ExtraVar As Long)
Dim Buffer As clsBuffer
Dim value As Long
Dim slot As Long

Set Buffer = New clsBuffer

Buffer.WriteBytes Data()

slot = Buffer.ReadLong
value = Buffer.ReadLong

Select Case slot

Case 1

HotBar(Index).slot1 = value

Exit Sub

Case 2

HotBar(Index).slot2 = value

Exit Sub

Case 3

HotBar(Index).slot3 = value

Exit Sub

Case 4

HotBar(Index).slot4 = value

Exit Sub

Case 5

HotBar(Index).slot5 = value

Exit Sub

Case 6

HotBar(Index).slot6 = value

Exit Sub

Case 7

HotBar(Index).slot7 = value

Exit Sub

Case 8

HotBar(Index).slot8 = value

Exit Sub

Case 9

HotBar(Index).slot9 = value

Exit Sub

Case 10

HotBar(Index).slot10 = value

Exit Sub

End Select

Set Buffer = Nothing

End Sub

Where i try to cast the "hot bar spell"

Private Sub Picture5_Click()
Dim spell As Long
LoadHotBar (8)

spell = Val(HotBar(MyIndex).slot8)

CastSpell (spell)
End Sub


The cast spell sub

Public Sub CastSpell(ByVal spellslot As Long)
    Dim Buffer As clsBuffer

’ Check for subscript out of range
    If spellslot < 1 Or spellslot > MAX_PLAYER_SPELLS Then
        Exit Sub
    End If

If SpellCD(spellslot) > 0 Then
        AddText “Spell has not cooled down yet!”, BrightRed
        Exit Sub
    End If

’ Check if player has enough MP
    If GetPlayerVital(MyIndex, Vitals.MP) < spell(PlayerSpells(spellslot)).MPCost Then
        Call AddText("Not enough MP to cast " & Trim$(spell(PlayerSpells(spellslot)).Name) & “.”, BrightRed)
        Exit Sub
    End If

If spell(spellslot) > 0 Then
        If GetTickCount > Player(MyIndex).AttackTimer + 1000 Then
            If Player(MyIndex).Moving = 0 Then
                Set Buffer = New clsBuffer
                Buffer.WriteLong CCast
                Buffer.WriteLong spellslot
                SendData Buffer.ToArray()
                Set Buffer = Nothing
                SpellBuffer = spellslot
                SpellBufferTimer = GetTickCount
            Else
                Call AddText(“Cannot cast while walking!”, BrightRed)
            End If
        End If
    Else
        Call AddText(“No spell here.”, BrightRed)
    End If

End Sub


Thanks , Vitin.

tbh i dont have the time to scan though all of your code.
But a Type Mismatch error is when you try and use one variable type as another.

example would be you use:
Dim X as Integer
Then later try and:
X=“Cat”

Anytime i ever get a mismatch it is along those lines.
Make sure your vatiables are setup and used properly.

If I get a chance tomorrow Ill look at it.

Post the line of code which is erroring. We don’t have time to sift through your entire project. xD

@Robin:

Post the line of code which is erroring. We don’t have time to sift through your entire project. xD

I do. xD

In your server TCP, Value is assigned as a long, and GetVar is for strings. Just put a Val() around the GetVar, or change Value to a string.

P.S. GetVar can read from a .txt?!?!

@Lightning:

P.S. GetVar can read from a .txt?!?!

You can call it a .penis file if you really felt like it. File extensions are only used by Windows Explorer to allow you to open different files in different applications and are completely trivial when it comes to anything else.

@Robin:

@Lightning:

P.S. GetVar can read from a .txt?!?!

You can call it a .penis file if you really felt like it. File extensions are only used by Windows Explorer to allow you to open different files in different applications and are completely trivial when it comes to anything else.

Replace all gfx files with .dat extensions to throw off newbies!

@Robin:

@Lightning:

P.S. GetVar can read from a .txt?!?!

You can call it a .penis file if you really felt like it. File extensions are only used by Windows Explorer to allow you to open different files in different applications and are completely trivial when it comes to anything else.

Nice. Well I learnt something today. 😛

Nice use of bold tags xD

@Mr.:

Replace all gfx files with .dat extensions to throw off newbies!

No.

@Robin:

@Mr.:

Replace all gfx files with .dat extensions to throw off newbies!

No.

I demnad an explanation! But I expect a “No.”.

@Lightning:

@Robin:

Post the line of code which is erroring. We don’t have time to sift through your entire project. xD

I do. xD

In your server TCP, Value is assigned as a long, and GetVar is for strings. Just put a Val() around the GetVar, or change Value to a string.

P.S. GetVar can read from a .txt?!?!

I changed.Now it gives type mismatch at Sub CastSpell.

Thanks for the help anyways.

@[Cake:

Vitin â„¢ link=topic=64522.msg691237#msg691237 date=1284141153]
@Lightning:

@Robin:

Post the line of code which is erroring. We don’t have time to sift through your entire project. xD

I do. xD

In your server TCP, Value is assigned as a long, and GetVar is for strings. Just put a Val() around the GetVar, or change Value to a string.

P.S. GetVar can read from a .txt?!?!

I changed.Now it gives type mismatch at Sub CastSpell.

Thanks for the help anyways.

I’m guessing you changed Value to a string. When you call CastSpell, I would say you are calling CastSpell with Value as a string. Switch it back to a Long, and put a Val() around your GetVar.

Regards,

Lightning

Still not working.

@[Cake:

Vitin â„¢ link=topic=64522.msg691242#msg691242 date=1284141565]
Still not working.

Screenshot or post the line of code that is erroring please. It’s a task trawling through your code xD

!

It looks like spellslot is coming up as a null, and the only reason I can see is the Hotbar array. You didn’t include it in your code, so did you declare it at all? If you have, you might need to give me until tomorrow to sort this out.

Private Type HotBarRec

slot1 As Long
slot2 As Long
slot3 As Long
slot4 As Long
slot5 As Long
slot6 As Long
slot7 As Long
slot8 As Long
slot9 As Long
slot10 As Long

End Type

@[Cake:

Vitin â„¢ link=topic=64522.msg691255#msg691255 date=1284143428]

Private Type HotBarRec

slot1 As Long
slot2 As Long
slot3 As Long
slot4 As Long
slot5 As Long
slot6 As Long
slot7 As Long
slot8 As Long
slot9 As Long
slot10 As Long

End Type

Ok, you have the type, did you delcare the Hotbar Variable like this?

Dim HotBar(1 to MAX_PLAYERS) As HotBarRec

I declared public hotbar(1 to max_players) as hotbarrec

Never mind i have fixed it .Thanks all!

Log in to reply