In ES i did as bellow:
Syntax: Select all
from vecmath import vector, distance
distance(vector(es.getplayerlocation(VICTIM)), vector(es.getplayerlocation(ATTACKER))) * 0.0254
Syntax: Select all
from vecmath import vector, distance
distance(vector(es.getplayerlocation(VICTIM)), vector(es.getplayerlocation(ATTACKER))) * 0.0254
Syntax: Select all
from Source import Player
from events.decorator import Event
@Event
def player_death(GameEvent):
# Get the victim and attacker userids
userid = GameEvent.GetInt('userid')
attacker = GameEvent.GetInt('attacker')
# Was this a suicide?
if attacker in (userid, 0):
# If so, do nothing
return
# Get the victim and attacker playerinfo
victim = get_player_info(userid)
killer = get_player_info(attacker)
# Were either of the 2 playerinfo instances returned as None?
if victim is None or killer is None:
# If so, do nothing
return
# Was this a team kill?
if victim.GetTeamIndex() == killer.GetTeamIndex():
# If so, do nothing
return
# Get the player's position
victim_origin = victim.GetAbsOrigin()
# Get the attacker's position
killer_origin = killer.GetAbsOrigin()
distance = victim_origin.DistTo(killer_origin)
def get_player_info(userid):
'''Returns an IPlayerInfo instance for the given userid'''
# Loop through all players on the server
for player in Player.Players():
# Is the current player the one we are looking for?
if player.GetUserID() == userid:
# Return the player's IPlayerInfo instance
return player
# If no player was found, return None
return None
satoon101 wrote:If you build with the newest version (just pushed some changes a few minutes ago), you can use the script above. Take note that I changed that script to use a better method.
Satoon
Return to “Plugin Development Support”
Users browsing this forum: No registered users and 39 guests