Mirage Source http://web.miragesource.net/forums/ |
|
Subscript out of Range http://web.miragesource.net/forums/viewtopic.php?f=201&t=4011 |
Page 1 of 1 |
Author: | Avalonia [ Sun Jul 20, 2008 6:46 am ] |
Post subject: | Subscript out of Range |
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
|
Author: | GIAKEN [ Sun Jul 20, 2008 6:51 am ] |
Post subject: | Re: Subscript out of Range |
Check if the MapNpc(i).Num > 0 before using it. |
Author: | Avalonia [ Sun Jul 20, 2008 6:57 am ] |
Post subject: | Re: Subscript out of Range |
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 |
Author: | GIAKEN [ Sun Jul 20, 2008 7:10 am ] |
Post subject: | Re: Subscript out of Range |
Because you aren't use an NPC on your map or the NPC is dead? |
Author: | Avalonia [ Sun Jul 20, 2008 7:28 am ] |
Post subject: | Re: Subscript out of Range |
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. |
Author: | GIAKEN [ Sun Jul 20, 2008 7:30 am ] |
Post subject: | Re: Subscript out of Range |
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. |
Author: | Avalonia [ Sun Jul 20, 2008 7:40 am ] |
Post subject: | Re: Subscript out of Range |
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. |
Author: | GIAKEN [ Sun Jul 20, 2008 8:01 am ] |
Post subject: | Re: Subscript out of Range |
I definitely would not do that. You don't want several players sending dozens of packets a second. |
Author: | Avalonia [ Sun Jul 20, 2008 8:24 am ] |
Post subject: | Re: Subscript out of Range |
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 |
Author: | Labmonkey [ Sun Jul 20, 2008 11:40 am ] |
Post subject: | Re: Subscript out of Range |
have you made sure that you are sending the size when you send the other npc data? |
Author: | Matt [ Sun Jul 20, 2008 11:45 am ] |
Post subject: | Re: Subscript out of Range |
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. |
Author: | Avalonia [ Sun Jul 20, 2008 5:11 pm ] |
Post subject: | Re: Subscript out of Range |
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. |
Page 1 of 1 | All times are UTC |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |