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

Cleaning Target


Valentine90
 Share

Recommended Posts

**Sorry my English**

If you have a target and he leaves the game or dies, it is not cleaned of your player, you will continue with a selected target even if that player is no longer online or live on that map.

**1** - In **modPlayer**, search for:
```
Call SetPlayerVital(index, Vitals.HP, 0)
```

**2**- Beneath add:
```
  ' Loop through entire map and purge NPC from targets
    For i = 1 To Player_HighIndex
        If IsPlaying(i) And IsConnected(i) Then
            If GetPlayerMap(i) = GetPlayerMap(index) Then
                If TempPlayer(i).targetType = TARGET_TYPE_PLAYER Then
                    If TempPlayer(i).target = index Then
                        TempPlayer(i).target = 0
                        TempPlayer(i).targetType = TARGET_TYPE_NONE
                        SendTarget i
                    End If
                End If
            End If
        End If
    Next
```

**3 -** Search for:
```
TempPlayer(index).InGame = False
```

**4 -** Beneath add:
```
      ' Loop through entire map and purge NPC from targets
        For i = 1 To Player_HighIndex
            If IsPlaying(i) And IsConnected(i) Then
                If GetPlayerMap(i) = GetPlayerMap(index) Then
                    If TempPlayer(i).targetType = TARGET_TYPE_PLAYER Then
                        If TempPlayer(i).target = index Then
                            TempPlayer(i).target = 0
                            TempPlayer(i).targetType = TARGET_TYPE_NONE
                            SendTarget i
                        End If
                    End If
                End If
            End If
        Next
```

**Credits:**
Valentine
Link to comment
Share on other sites

> I noticed this too, but I didn't see where it would cause an error or any problems. 
>
> Could it cause any problems if left undone? If so, what?

In certain engines you can get RTE9\. Usually there is an IsPlaying(index) check to stop a sub if the player is offline.
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...