Rydo Posted July 7, 2012 Author Share Posted July 7, 2012 Ok so I attempted (yet again!) to put the alatars house system fix into my project, and it keeps giving me this message. ![](http://i45.tinypic.com/n3lyc2.png) Link to comment Share on other sites More sharing options...
The New World Posted July 7, 2012 Share Posted July 7, 2012 Means you're missing an end if to match one of your ifs. In this case the If missing an end if is,```if Npc(npcNum).Behaviour <> NPC_BEHAVIOUR_```As well as an end if for the two if statements above it. Link to comment Share on other sites More sharing options...
Rydo Posted July 7, 2012 Author Share Posted July 7, 2012 @DrunkenHyena:> Means you're missing an end if to match one of your ifs. In this case the If missing an end if is,> > ```> if Npc(npcNum).Behaviour <> NPC_BEHAVIOUR_> > ```> As well as an end if for the two if statements above it.I basically took half of that in. So basically some of the Ifs are missing End If? Also where about would I put the End If's since there are more needed? Link to comment Share on other sites More sharing options...
Joost Posted July 7, 2012 Share Posted July 7, 2012 copy/paste the code from if npcx to End function and I'll show you where it goes. cba typing over all the code. Link to comment Share on other sites More sharing options...
Rydo Posted July 7, 2012 Author Share Posted July 7, 2012 ```If NpcX = GetPlayerX(Attacker) Then If NpcY = GetPlayerY(Attacker) Then If Npc(npcNum).Behaviour <> NPC_BEHAVIOUR_FRIENDLY And Npc(npcNum).Behaviour <> NPC_BEHAVIOUR_SHOPKEEPER And Npc(npcNum).Behaviour <> NPC_BEHAVIOUR_MANAGER Then 'House Editor CanPlayerAttackNpc = True Else 'House Editor If Npc(npcNum).Behaviour = NPC_BEHAVIOUR_MANAGER Then Call SendInitManager(Attacker, CInt(GetVar(App.Path & "\data\accounts\houses.ini", "OPTIONS", "" & Player(Attacker).Name)), Npc(npcNum).HMapNum, Npc(npcNum).HBuy, Npc(npcNum).HSell) End If '/House Editor If Len(Trim$(Npc(npcNum).AttackSay)) > 0 Then PlayerMsg Attacker, Trim$(Npc(npcNum).Name) & ": " & Trim$(Npc(npcNum).AttackSay), White End If End Function``` Link to comment Share on other sites More sharing options...
Domino_ Posted July 7, 2012 Share Posted July 7, 2012 in picture you can see that you havent closed if's… >.> give all code. Link to comment Share on other sites More sharing options...
Rydo Posted July 7, 2012 Author Share Posted July 7, 2012 ```Public Function CanPlayerAttackNpc(ByVal Attacker As Long, ByVal mapNpcNum As Long, Optional ByVal IsSpell As Boolean = False) As Boolean Dim mapNum As Long Dim npcNum As Long Dim NpcX As Long Dim NpcY As Long Dim attackspeed As Long ' Check for subscript out of range If IsPlaying(Attacker) = False Or mapNpcNum <= 0 Or mapNpcNum > MAX_MAP_NPCS Then Exit Function End If ' Check for subscript out of range If MapNpc(GetPlayerMap(Attacker)).Npc(mapNpcNum).Num <= 0 Then Exit Function End If mapNum = GetPlayerMap(Attacker) npcNum = MapNpc(mapNum).Npc(mapNpcNum).Num ' Make sure the npc isn't already dead If MapNpc(mapNum).Npc(mapNpcNum).Vital(Vitals.HP) <= 0 Then If Npc(MapNpc(mapNum).Npc(mapNpcNum).Num).Behaviour <> NPC_BEHAVIOUR_FRIENDLY Then If Npc(MapNpc(mapNum).Npc(mapNpcNum).Num).Behaviour <> NPC_BEHAVIOUR_SHOPKEEPER Then Exit Function End If End If End If ' Make sure they are on the same map If IsPlaying(Attacker) Then ' exit out early If IsSpell Then If Npc(npcNum).Behaviour <> NPC_BEHAVIOUR_FRIENDLY And Npc(npcNum).Behaviour <> NPC_BEHAVIOUR_SHOPKEEPER And Npc(npcNum).Behaviour <> NPC_BEHAVIOUR_MANAGER Then CanPlayerAttackNpc = True Exit Function End If End If If npcNum > 0 Then If Npc(npcNum).Behaviour <> NPC_BEHAVIOUR_FRIENDLY And Npc(npcNum).Behaviour <> NPC_BEHAVIOUR_SHOPKEEPER Then Dim petowner As Long TempPlayer(Attacker).targetType = TARGET_TYPE_NPC TempPlayer(Attacker).target = mapNpcNum SendTarget Attacker CanPlayerAttackNpc = True Exit Function End If End If End If If MapNpc(mapNum).Npc(mapNpcNum).IsPet = YES Then petowner = MapNpc(mapNum).Npc(mapNpcNum).PetData.Owner If Attacker = petowner Then Call PlayerMsg(Attacker, "You can't attack your own pet.", BrightRed) Exit Function End If End IfIf MapNpc(mapNum).Npc(mapNpcNum).IsPet = YES Then If Not Map(GetPlayerMap(Attacker)).Moral = MAP_MORAL_NONE Then Call PlayerMsg(Attacker, "This is a safe zone! You can't attack other player's pet.", BrightRed) Exit Function End If End If If MapNpc(mapNum).Npc(mapNpcNum).IsPet = YES Then petowner = MapNpc(mapNum).Npc(mapNpcNum).PetData.Owner If GetPlayerAccess(petowner) > ADMIN_MONITOR Then Call PlayerMsg(Attacker, "You can't attack " & GetPlayerName(petowner) & "'s pet!", BrightRed) Exit Function End If End If If MapNpc(mapNum).Npc(mapNpcNum).IsPet = YES Then If GetPlayerAccess(Attacker) > ADMIN_MONITOR Then Call PlayerMsg(Attacker, "Admins can't attack other player's pet.", Yellow) Exit Function End If End If If MapNpc(mapNum).Npc(mapNpcNum).IsPet = YES Then petowner = MapNpc(mapNum).Npc(mapNpcNum).PetData.Owner If GetPlayerLevel(petowner) < 10 Then Call PlayerMsg(Attacker, GetPlayerName(petowner) & " is below level 10, you can't attack his pet!", BrightRed) Exit Function End If End If If MapNpc(mapNum).Npc(mapNpcNum).IsPet = YES Then If GetPlayerLevel(Attacker) < 10 Then Call PlayerMsg(Attacker, "You are below level 10, you can't attack players with your pet yet!", BrightRed) Exit Function End If End If ' attack speed from weapon If GetPlayerEquipment(Attacker, Weapon) > 0 Then attackspeed = Item(GetPlayerEquipment(Attacker, Weapon)).Speed Else attackspeed = 1000 End If If npcNum > 0 And GetTickCount > TempPlayer(Attacker).AttackTimer + attackspeed Then ' Check if at same coordinates Select Case GetPlayerDir(Attacker) Case DIR_UP NpcX = MapNpc(mapNum).Npc(mapNpcNum).x NpcY = MapNpc(mapNum).Npc(mapNpcNum).y + 1 Case DIR_DOWN NpcX = MapNpc(mapNum).Npc(mapNpcNum).x NpcY = MapNpc(mapNum).Npc(mapNpcNum).y - 1 Case DIR_LEFT NpcX = MapNpc(mapNum).Npc(mapNpcNum).x + 1 NpcY = MapNpc(mapNum).Npc(mapNpcNum).y Case DIR_RIGHT NpcX = MapNpc(mapNum).Npc(mapNpcNum).x - 1 NpcY = MapNpc(mapNum).Npc(mapNpcNum).y End Select If NpcX = GetPlayerX(Attacker) Then If NpcY = GetPlayerY(Attacker) Then If Npc(npcNum).Behaviour <> NPC_BEHAVIOUR_FRIENDLY And Npc(npcNum).Behaviour <> NPC_BEHAVIOUR_SHOPKEEPER And Npc(npcNum).Behaviour <> NPC_BEHAVIOUR_MANAGER Then 'House Editor CanPlayerAttackNpc = True Else 'House Editor If Npc(npcNum).Behaviour = NPC_BEHAVIOUR_MANAGER Then Call SendInitManager(Attacker, CInt(GetVar(App.Path & "\data\accounts\houses.ini", "OPTIONS", "" & Player(Attacker).Name)), Npc(npcNum).HMapNum, Npc(npcNum).HBuy, Npc(npcNum).HSell) End If '/House Editor If Len(Trim$(Npc(npcNum).AttackSay)) > 0 Then PlayerMsg Attacker, Trim$(Npc(npcNum).Name) & ": " & Trim$(Npc(npcNum).AttackSay), White End If End Function``` Link to comment Share on other sites More sharing options...
Domino_ Posted July 7, 2012 Share Posted July 7, 2012 ```Public Function CanPlayerAttackNpc(ByVal Attacker As Long, ByVal mapNpcNum As Long, Optional ByVal IsSpell As Boolean = False) As Boolean Dim mapNum As Long Dim npcNum As Long Dim NpcX As Long Dim NpcY As Long Dim attackspeed As Long ' Check for subscript out of range If IsPlaying(Attacker) = False Or mapNpcNum <= 0 Or mapNpcNum > MAX_MAP_NPCS Then Exit Function End If ' Check for subscript out of range If MapNpc(GetPlayerMap(Attacker)).Npc(mapNpcNum).Num <= 0 Then Exit Function End If mapNum = GetPlayerMap(Attacker) npcNum = MapNpc(mapNum).Npc(mapNpcNum).Num ' Make sure the npc isn't already dead If MapNpc(mapNum).Npc(mapNpcNum).Vital(Vitals.HP) <= 0 Then If Npc(MapNpc(mapNum).Npc(mapNpcNum).Num).Behaviour <> NPC_BEHAVIOUR_FRIENDLY Then If Npc(MapNpc(mapNum).Npc(mapNpcNum).Num).Behaviour <> NPC_BEHAVIOUR_SHOPKEEPER Then Exit Function End If End If End If ' Make sure they are on the same map If IsPlaying(Attacker) Then ' exit out early If IsSpell Then If Npc(npcNum).Behaviour <> NPC_BEHAVIOUR_FRIENDLY And Npc(npcNum).Behaviour <> NPC_BEHAVIOUR_SHOPKEEPER And Npc(npcNum).Behaviour <> NPC_BEHAVIOUR_MANAGER Then CanPlayerAttackNpc = True Exit Function End If End If If npcNum > 0 Then If Npc(npcNum).Behaviour <> NPC_BEHAVIOUR_FRIENDLY And Npc(npcNum).Behaviour <> NPC_BEHAVIOUR_SHOPKEEPER Then Dim petowner As Long TempPlayer(Attacker).targetType = TARGET_TYPE_NPC TempPlayer(Attacker).Target = mapNpcNum SendTarget Attacker CanPlayerAttackNpc = True Exit Function End If End If End If If MapNpc(mapNum).Npc(mapNpcNum).IsPet = YES Then petowner = MapNpc(mapNum).Npc(mapNpcNum).PetData.Owner If Attacker = petowner Then Call PlayerMsg(Attacker, "You can't attack your own pet.", BrightRed) Exit Function End If End IfIf MapNpc(mapNum).Npc(mapNpcNum).IsPet = YES Then If Not Map(GetPlayerMap(Attacker)).Moral = MAP_MORAL_NONE Then Call PlayerMsg(Attacker, "This is a safe zone! You can't attack other player's pet.", BrightRed) Exit Function End If End If If MapNpc(mapNum).Npc(mapNpcNum).IsPet = YES Then petowner = MapNpc(mapNum).Npc(mapNpcNum).PetData.Owner If GetPlayerAccess(petowner) > ADMIN_MONITOR Then Call PlayerMsg(Attacker, "You can't attack " & GetPlayerName(petowner) & "'s pet!", BrightRed) Exit Function End If End If If MapNpc(mapNum).Npc(mapNpcNum).IsPet = YES Then If GetPlayerAccess(Attacker) > ADMIN_MONITOR Then Call PlayerMsg(Attacker, "Admins can't attack other player's pet.", Yellow) Exit Function End If End If If MapNpc(mapNum).Npc(mapNpcNum).IsPet = YES Then petowner = MapNpc(mapNum).Npc(mapNpcNum).PetData.Owner If GetPlayerLevel(petowner) < 10 Then Call PlayerMsg(Attacker, GetPlayerName(petowner) & " is below level 10, you can't attack his pet!", BrightRed) Exit Function End If End If If MapNpc(mapNum).Npc(mapNpcNum).IsPet = YES Then If GetPlayerLevel(Attacker) < 10 Then Call PlayerMsg(Attacker, "You are below level 10, you can't attack players with your pet yet!", BrightRed) Exit Function End If End If ' attack speed from weapon If GetPlayerEquipment(Attacker, Weapon) > 0 Then attackspeed = Item(GetPlayerEquipment(Attacker, Weapon)).Speed Else attackspeed = 1000 End If If npcNum > 0 And GetTickCount > TempPlayer(Attacker).AttackTimer + attackspeed Then ' Check if at same coordinates Select Case GetPlayerDir(Attacker) Case DIR_UP NpcX = MapNpc(mapNum).Npc(mapNpcNum).x NpcY = MapNpc(mapNum).Npc(mapNpcNum).y + 1 Case DIR_DOWN NpcX = MapNpc(mapNum).Npc(mapNpcNum).x NpcY = MapNpc(mapNum).Npc(mapNpcNum).y - 1 Case DIR_LEFT NpcX = MapNpc(mapNum).Npc(mapNpcNum).x + 1 NpcY = MapNpc(mapNum).Npc(mapNpcNum).y Case DIR_RIGHT NpcX = MapNpc(mapNum).Npc(mapNpcNum).x - 1 NpcY = MapNpc(mapNum).Npc(mapNpcNum).y End Select If NpcX = GetPlayerX(Attacker) Then If NpcY = GetPlayerY(Attacker) Then If Npc(npcNum).Behaviour <> NPC_BEHAVIOUR_FRIENDLY And Npc(npcNum).Behaviour <> NPC_BEHAVIOUR_SHOPKEEPER And Npc(npcNum).Behaviour <> NPC_BEHAVIOUR_MANAGER Then 'House Editor CanPlayerAttackNpc = True Else 'House Editor If Npc(npcNum).Behaviour = NPC_BEHAVIOUR_MANAGER Then Call SendInitManager(Attacker, CInt(GetVar(App.Path & "\data\accounts\houses.ini", "OPTIONS", "" & Player(Attacker).Name)), Npc(npcNum).HMapNum, Npc(npcNum).HBuy, Npc(npcNum).HSell) End If '/House Editor If Len(Trim$(Npc(npcNum).AttackSay)) > 0 Then PlayerMsg Attacker, Trim$(Npc(npcNum).Name) & ": " & Trim$(Npc(npcNum).AttackSay), White End If End If End If End If End Function```Try now… Link to comment Share on other sites More sharing options...
Rydo Posted July 7, 2012 Author Share Posted July 7, 2012 Got an error with "TryPlayerAttackNpc" Link to comment Share on other sites More sharing options...
Rydo Posted July 7, 2012 Author Share Posted July 7, 2012 In mod HandleData :/ Link to comment Share on other sites More sharing options...
Nickpop123 Posted July 7, 2012 Share Posted July 7, 2012 Use your old code you had, and with your old problem code, replace it with this:```If NpcX = GetPlayerX(Attacker) Then If NpcY = GetPlayerY(Attacker) Then If Npc(npcNum).Behaviour <> NPC_BEHAVIOUR_FRIENDLY And Npc(npcNum).Behaviour <> NPC_BEHAVIOUR_SHOPKEEPER And Npc(npcNum).Behaviour <> NPC_BEHAVIOUR_MANAGER Then 'House Editor CanPlayerAttackNpc = True Else 'House Editor If Npc(npcNum).Behaviour = NPC_BEHAVIOUR_MANAGER Then Call SendInitManager(Attacker, CInt(GetVar(App.Path & "\data\accounts\houses.ini", "OPTIONS", "" & Player(Attacker).Name)), Npc(npcNum).HMapNum, Npc(npcNum).HBuy, Npc(npcNum).HSell) End If '/House Editor If Len(Trim$(Npc(npcNum).AttackSay)) > 0 Then PlayerMsg Attacker, Trim$(Npc(npcNum).Name) & ": " & Trim$(Npc(npcNum).AttackSay), White End If End If End IfEnd If``` Link to comment Share on other sites More sharing options...
Rydo Posted July 7, 2012 Author Share Posted July 7, 2012 Nickpop123 and Domino, both of your codes work, but I still get an error in ModHandle Data highlighting "TryPlayerAttackNPC" and saying "Sub or function not defined". Link to comment Share on other sites More sharing options...
Rydo Posted July 7, 2012 Author Share Posted July 7, 2012 This is the problematic code``` ' Try to attack a npc For i = 1 To MAX_MAP_NPCS TryPlayerAttackNpc index, i Next``` Link to comment Share on other sites More sharing options...
Domino_ Posted July 8, 2012 Share Posted July 8, 2012 Show that sub where you now get error. Or check in EO2.0 whats there different than in your edit. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now