Code:
Function CanAttackPlayer(ByVal Attacker As Long, ByVal Victim As Long) As Boolean
CanAttackPlayer = False
' Check attack timer
If GetTickCount < TempPlayer(Attacker).AttackTimer + 1000 Then Exit Function
' Check for subscript out of range
If Not IsPlaying(Victim) Then Exit Function
' Make sure they are on the same map
If Not GetPlayerMap(Attacker) = GetPlayerMap(Victim) Then Exit Function
' Make sure we dont attack the player if they are switching maps
If TempPlayer(Victim).GettingMap = YES Then Exit Function
' Check if at same coordinates
Select Case GetPlayerDir(Attacker)
Case DIR_UP
If Not ((GetPlayerY(Victim) + 1 = GetPlayerY(Attacker)) And (GetPlayerX(Victim) = GetPlayerX(Attacker))) Then Exit Function
Case DIR_DOWN
If Not ((GetPlayerY(Victim) - 1 = GetPlayerY(Attacker)) And (GetPlayerX(Victim) = GetPlayerX(Attacker))) Then Exit Function
Case DIR_LEFT
If Not ((GetPlayerY(Victim) = GetPlayerY(Attacker)) And (GetPlayerX(Victim) + 1 = GetPlayerX(Attacker))) Then Exit Function
Case DIR_RIGHT
If Not ((GetPlayerY(Victim) = GetPlayerY(Attacker)) And (GetPlayerX(Victim) - 1 = GetPlayerX(Attacker))) Then Exit Function
Case Else
Exit Function
End Select
' Check if map is attackable
If Not Map(GetPlayerMap(Attacker)).Moral = MAP_MORAL_NONE Then
If GetPlayerPK(Victim) = NO Then
Call PlayerMsg(Attacker, "This is a safe zone!", BrightRed)
Exit Function
End If
End If
' Make sure they have more then 0 hp
If GetPlayerVital(Victim, Vitals.HP) <= 0 Then Exit Function
' Check to make sure that they dont have access
If GetPlayerAccess(Attacker) > ADMIN_MONITOR Then
Call PlayerMsg(Attacker, "You cannot attack any player for thou art an admin!", BrightBlue)
Exit Function
End If
' Check to make sure the victim isn't an admin
If GetPlayerAccess(Victim) > ADMIN_MONITOR Then
Call PlayerMsg(Attacker, "You cannot attack " & GetPlayerName(Victim) & "!", BrightRed)
Exit Function
End If
' Make sure attacker is high enough level
If GetPlayerLevel(Attacker) < 10 Then
Call PlayerMsg(Attacker, "You are below level 10, you cannot attack another player yet!", BrightRed)
Exit Function
End If
' Make sure victim is high enough level
If GetPlayerLevel(Victim) < 10 Then
Call PlayerMsg(Attacker, GetPlayerName(Victim) & " is below level 10, you cannot attack this player yet!", BrightRed)
Exit Function
End If
CanAttackPlayer = True
End Function
_________________
Nean wrote:
Yes harold. Give it to me.