Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Subscript out of Range
#1
Want to pass the size variable (used for sprite sizes) wich is a byte to the BltNPC function so i can choose between a few sizes when bliting and blit different if its an other size.

Code:
Dim sizez as Integer
Dim i as Long

        ' Blit out the npcs
        For i = 1 To MAX_MAP_NPCS
            sizez = Npc(MapNpc(i).Num).Size
            Call BltNpc(i, nnum)
        Next i

Code:
sizez = Npc(MapNpc(i).Num).Size ' Subscript out of range error here
returns subscript out of range
Reply
#2
Check if the MapNpc(i).Num > 0 before using it.
Reply
#3
GIAKEN Wrote:Check if the MapNpc(i).Num > 0 before using it.

hm MapNpc(i).Num always returns 0 , why doesnt it return the number Sad
Reply
#4
Because you aren't use an NPC on your map or the NPC is dead?
Reply
#5
nnum = Npc(MapNpc(i).Num).Size

Sorry i meant Npc(MapNpc(i).Num).Size only returns 0 , even though it should be on 1.
Have 4 npcs setup with size 1 and 1 with 0

Its 1 in the npc ini file also so that should be fine.
Reply
#6
Well you still need to make sure you're checking if MapNpc().Num > 0...also make sure that the NPC editor is sending the size value right and that it's being sent to the client and that the server is saving and loading it correctly.
Reply
#7
GIAKEN Wrote:Well you still need to make sure you're checking if MapNpc().Num > 0...also make sure that the NPC editor is sending the size value right and that it's being sent to the client and that the server is saving and loading it correctly.

Saving and loading works fine my code is now this , wich checks also if its bigger then 0:

Code:
' Blit out the npcs
        For i = 1 To MAX_MAP_NPCS
            If MapNpc(i).Num > 0 Then
            nnum = Npc(MapNpc(i).Num).Size
            Call BltNpc(i, nnum)
            End If
        Next i

Well i could make a
Senddata("requestsize & Sep_CHAR & Npc(MapNpc(i).Num)& SEP_Char & End_CHar ") and then let the server reply with the size, will try that.
Reply
#8
I definitely would not do that. You don't want several players sending dozens of packets a second.
Reply
#9
GIAKEN Wrote:I definitely would not do that. You don't want several players sending dozens of packets a second.

Well then i have no idea, it saves it fine in the npceditor when i reopen it it receives the 1 value from the server or the 0 , depending on what i set it ,and in the ini it is also Size = 1.
Msgbox(NPC(Mapnpc(2).Num)).Size) returns 0 also , wich should return 1
Reply
#10
have you made sure that you are sending the size when you send the other npc data?
Reply
#11
Labmonkey Wrote:have you made sure that you are sending the size when you send the other npc data?

That's exactly what I was about to suggest.

When loading the npc, server side, if you have ini loading still, make sure you add the line there that will pull the value from the npc's file.

Also, when sending the npc data, add the size to the packet and don't forget to receive it on the client side.
Reply
#12
Ok thanks for help , just forgot to update it to all clients , i only had it update in the npceditor, works now like a charm.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)