Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[EO2.0] [VB6] Pet item


EisKeks
 Share

Recommended Posts

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

that is the logout sub
here 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 Integer
Dim petnum As Long
petnum = 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 If

End Sub
```
Link to comment
Share on other sites

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

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 this

server 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

```
'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
                Next
End Sub

```
if you mean that i got it because im using your system ^^
Link to comment
Share on other sites

Sub CloseSocket(ByVal Index As Long)
Dim I As Integer
Dim petnum As Long
petnum = 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 If

End Sub

is 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

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

=P

btw, 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

****WARNING: SCRAP ANY OTHER MODS FROM THIS THREAD FIRST****

The code:

**SERVER**

Find "Sub PetDisband" In modGameLogic

Change it to

```
'Clear the npc from the map
Sub 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 If

End 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

(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
    Next
End Sub

```
and in modPlayer

find Case ITEM_TYPE_SUMMON and erase

```
Call TakeInvItem(index, itemnum, 0)

```at the bottom

I 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 helps

PS.. ill add this to the original tut.
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...