goku1993 Posted April 14, 2011 Share Posted April 14, 2011 well you can make it clear them when you're closing the server i guess?Give me a sec to look at the tut again and I'll modify this when I find a way (btw check the tutorials posts even if it's long you might find then fix somewhere there)edit:nvm check below Link to comment Share on other sites More sharing options...
EisKeks Posted April 14, 2011 Author Share Posted April 14, 2011 that is the logout subhere is the petdisbaned but when i close i dont get back the item. I think i havte to clear in the sub petdisband the pet out of the mapproperties but how :/```Sub CloseSocket(ByVal Index As Long)Dim I As IntegerDim petnum As Longpetnum = Trim$(Player(Index).Pet.SpriteNum) If Index > 0 Then If TempPlayer(Index).TempPetSlot > 0 Then Call PetDisband(Index, GetPlayerMap(Index), petnum) For I = 1 To Player_HighIndex If GetPlayerMap(I) = GetPlayerMap(Index) Then SendMap I, GetPlayerMap(Index) End If Next End If Call LeftGame(Index) Call TextAdd("Connection from " & GetPlayerIP(Index) & " has been terminated.") frmServer.Socket(Index).Close Call UpdateCaption Call ClearPlayer(Index) End IfEnd Sub``` Link to comment Share on other sites More sharing options...
goku1993 Posted April 14, 2011 Share Posted April 14, 2011 so when you close the server the pet dissapears but the item of the pet dissapears from player inventory as well? is that what you're saying? Link to comment Share on other sites More sharing options...
EisKeks Posted April 14, 2011 Author Share Posted April 14, 2011 so the pet isnt in the properties after restarting … i disbaned is its not in the properties but its on my map when i push disband then its shown in the properties but it wont follow me ore other things i have to del it out of my map or spawn a new one its not my pet only a npc on this map :/ Link to comment Share on other sites More sharing options...
EisKeks Posted April 14, 2011 Author Share Posted April 14, 2011 so in this order.server on -> client log in -> spawn pet -> disband pet -> shut client -> shut server -> open server -> open client -> log in -> pet is on map but not in properties -> push disband pet pet appers in propperties but dont follow me ore do something i said.same when i do thisserver on -> client log in -> spawn pet -> shut client -> shut server -> open server -> open client -> log in -> pet is on map but not in properties -> push disband pet pet appers in propperties but dont follow me ore do something i said. Link to comment Share on other sites More sharing options...
goku1993 Posted April 14, 2011 Share Posted April 14, 2011 try putting a SendMap Index, GetPlayerMap(Index) after each petdisband? Link to comment Share on other sites More sharing options...
Yxxe Posted April 14, 2011 Share Posted April 14, 2011 The pets do clear on server shutdown. Your client just thinks there is a pet on the map due to the map file sent when it was summoned. If you want to get rid of this, just recache the map and send it again. Link to comment Share on other sites More sharing options...
EisKeks Posted April 14, 2011 Author Share Posted April 14, 2011 > recache the map and send it againand how can i do this? Link to comment Share on other sites More sharing options...
goku1993 Posted April 14, 2011 Share Posted April 14, 2011 i don't feel like giving you the answer, his tutorial is pretty clear look through it and you can easily find how he recached and sent the map… Link to comment Share on other sites More sharing options...
Yxxe Posted April 14, 2011 Share Posted April 14, 2011 @EisKeks:> and how can i do this?Look at the spawnpet procedure and how I cached and sent the map. I can't write any code out as I am typing on my phone. Link to comment Share on other sites More sharing options...
EisKeks Posted April 14, 2011 Author Share Posted April 14, 2011 ``` 'create the pet for the map Map(PlayerMap).Npc(PetSlot) = npcnum MapNpc(PlayerMap).Npc(PetSlot).Num = npcnum 'set its Pet Data MapNpc(PlayerMap).Npc(PetSlot).IsPet = YES MapNpc(PlayerMap).Npc(PetSlot).PetData.Name = GetPlayerName(Index) & "'s " & Npc(npcnum).Name MapNpc(PlayerMap).Npc(PetSlot).PetData.Owner = Index 'If Pet doesn't exist with player, link it to the player If Player(Index).Pet.SpriteNum <> npcnum Then Player(Index).Pet.SpriteNum = npcnum Player(Index).Pet.Name = GetPlayerName(Index) & "'s " & Npc(npcnum).Name End If TempPlayer(Index).TempPetSlot = PetSlot 'cache the map for sending Call MapCache_Create(PlayerMap) 'save the map SaveMap (PlayerMap) 'send the update For I = 1 To Player_HighIndex If IsPlaying(I) Then If GetPlayerMap(I) = GetPlayerMap(Index) Then SendMap I, PlayerMap End If End If Next Select Case GetPlayerDir(Index) Case DIR_UP Call SpawnNpc(PetSlot, PlayerMap, GetPlayerX(Index), GetPlayerY(Index) - 1) Case DIR_DOWN Call SpawnNpc(PetSlot, PlayerMap, GetPlayerX(Index), GetPlayerY(Index) + 1) Case DIR_LEFT Call SpawnNpc(PetSlot, PlayerMap, GetPlayerX(Index) + 1, GetPlayerY(Index)) Case DIR_RIGHT Call SpawnNpc(PetSlot, PlayerMap, GetPlayerX(Index), GetPlayerY(Index) - 1) End Select 're-warp the players on the map For I = 1 To Player_HighIndex If IsPlaying(I) Then If GetPlayerMap(I) = GetPlayerMap(Index) Then Call PlayerWarp(Index, PlayerMap, GetPlayerX(Index), GetPlayerY(Index)) End If End If NextEnd Sub```if you mean that i got it because im using your system ^^ Link to comment Share on other sites More sharing options...
goku1993 Posted April 14, 2011 Share Posted April 14, 2011 he means look at it and see how he cached and saved the map then apply that to the code you added… Link to comment Share on other sites More sharing options...
EisKeks Posted April 14, 2011 Author Share Posted April 14, 2011 Sub CloseSocket(ByVal Index As Long)Dim I As IntegerDim petnum As Longpetnum = Trim$(Player(Index).Pet.SpriteNum) If Index > 0 Then If TempPlayer(Index).TempPetSlot > 0 Then 'cache the map for sending Call MapCache_Create(PlayerMap) 'save the map SaveMap (PlayerMap) Call PetDisband(Index, GetPlayerMap(Index), petnum) For I = 1 To Player_HighIndex If GetPlayerMap(I) = GetPlayerMap(Index) Then SendMap I, GetPlayerMap(Index) End If Next End If Call LeftGame(Index) Call TextAdd("Connection from " & GetPlayerIP(Index) & " has been terminated.") frmServer.Socket(Index).Close Call UpdateCaption Call ClearPlayer(Index) End IfEnd Subis this right? oO if yes i becomm an error cause the (PlayerMap) is not defined if i use (Index) it wouldn't change anything :/ Link to comment Share on other sites More sharing options...
RyokuHasu Posted April 15, 2011 Share Posted April 15, 2011 O.o there is a more simple way… just Give item number = NPC number. =P and call it int he disban.. ill look uo the exact mod i would use XD... that first one was WAAY more coplicated then needed=Pbtw, yes it is lightning's system, but when you start asking about the items its mine ;D brb with the codes Link to comment Share on other sites More sharing options...
RyokuHasu Posted April 15, 2011 Share Posted April 15, 2011 ****WARNING: SCRAP ANY OTHER MODS FROM THIS THREAD FIRST****The code:**SERVER**Find "Sub PetDisband" In modGameLogicChange it to```'Clear the npc from the mapSub PetDisband(ByVal index As Long, ByVal MapNum As Long) If TempPlayer(index).TempPetSlot < 1 Then Exit Sub Call ClearSingleMapNpc(TempPlayer(index).TempPetSlot, MapNum) Call GiveInvItem(index, Player(index).Pet.SpriteNum, 0) Map(GetPlayerMap(index)).Npc(TempPlayer(index).TempPetSlot) = 0 TempPlayer(index).TempPetSlot = 0 End Sub```=P this should work. Its a much simpler way to do the item return… O.o however the Index in close socket is some what dirrent then normal and will not return the item O.o i will need to fix that too XD but this is a way Simple way to get the item back.[hr/]```Sub mnuDisconnectPlayer_Click() Dim Name As String Name = frmServer.lvwInfo.SelectedItem.SubItems(3) If Not Name = "Not Playing" Then CloseSocket (FindPlayer(Name)) End IfEnd Sub```O.o this is what is called when you log out… SO... the index IS NOT the same when calling disband... if you want it back on logout as well you might have to do a bit more work... Link to comment Share on other sites More sharing options...
RyokuHasu Posted April 15, 2011 Share Posted April 15, 2011 (yes i know, tripple post, i was working hard to help solve this lol)****WARNING: SCRAP ANY OTHER MODS FROM THIS THREAD FIRST****The other option is DONT TAKE THE ITEM in the first place…In game logic change sub SpawnPet too```Sub SpawnPet(ByVal index As Long, ByVal MapNum As Long, npcNum As Long) Dim PlayerMap As Long Dim i As Integer Dim PetSlot As Byte 'Prevent multiple pets for the same owner If TempPlayer(index).TempPetSlot > 0 Then Exit Sub End If PlayerMap = GetPlayerMap(index) PetSlot = 0 For i = 1 To MAX_MAP_NPCS If Map(PlayerMap).Npc(i) = 0 Then PetSlot = i Exit For End If Next If PetSlot = 0 Then Call PlayerMsg(index, "The map is too crowded for you to call on your pet!", Red) Exit Sub End If 'create the pet for the map Map(PlayerMap).Npc(PetSlot) = npcNum MapNpc(PlayerMap).Npc(PetSlot).Num = npcNum 'set its Pet Data MapNpc(PlayerMap).Npc(PetSlot).IsPet = YES MapNpc(PlayerMap).Npc(PetSlot).PetData.Name = GetPlayerName(index) & "'s " & Npc(npcNum).Name MapNpc(PlayerMap).Npc(PetSlot).PetData.Owner = index 'If Pet doesn't exist with player, link it to the player If Player(index).Pet.SpriteNum <> npcNum Then Player(index).Pet.SpriteNum = npcNum Player(index).Pet.Name = GetPlayerName(index) & "'s " & Npc(npcNum).Name End If TempPlayer(index).TempPetSlot = PetSlot 'cache the map for sending Call MapCache_Create(PlayerMap) 'send the update For i = 1 To Player_HighIndex If IsPlaying(i) Then If GetPlayerMap(i) = GetPlayerMap(index) Then SendMap i, PlayerMap End If End If Next Select Case GetPlayerDir(index) Case DIR_UP Call SpawnNpc(PetSlot, PlayerMap, GetPlayerX(index), GetPlayerY(index) - 1) Case DIR_DOWN Call SpawnNpc(PetSlot, PlayerMap, GetPlayerX(index), GetPlayerY(index) + 1) Case DIR_LEFT Call SpawnNpc(PetSlot, PlayerMap, GetPlayerX(index) + 1, GetPlayerY(index)) Case DIR_RIGHT Call SpawnNpc(PetSlot, PlayerMap, GetPlayerX(index), GetPlayerY(index) - 1) End Select 're-warp the players on the map For i = 1 To Player_HighIndex If IsPlaying(i) Then If GetPlayerMap(i) = GetPlayerMap(index) Then Call PlayerWarp(index, PlayerMap, GetPlayerX(index), GetPlayerY(index)) End If End If NextEnd Sub```and in modPlayerfind Case ITEM_TYPE_SUMMON and erase```Call TakeInvItem(index, itemnum, 0)```at the bottomI recomend this way over rewritting how you call the logout procedures. Its not giving the back cause it was never taken away, same thing in the end. =P hope this helpsPS.. ill add this to the original tut. Link to comment Share on other sites More sharing options...
EisKeks Posted April 15, 2011 Author Share Posted April 15, 2011 ya it works also great ^^ but i still got the damm problem that the pets comes back as npc's by restarting the server :/ and i dont know where to fix it. Link to comment Share on other sites More sharing options...
RyokuHasu Posted April 15, 2011 Share Posted April 15, 2011 =o hmmm…. I beleive that Lightning never completly solved a server crash or server exit for removing the NPCs =P sooo... ummm... Thats not realy my problem, sorry. >.< i only changed how you create them, and not how you remove them. =P 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