﻿ Unreal Software - Thread: get player id behind the wall

# Forum

CS2D Scripts get player id behind the wall

# get player id behind the wall

4 replies
1

#### get player id behind the wall

Unknown_Cheater
User Offline

when player shot or trigger attack hook pointer to other player behin the wall then msg the id

1------[] 2

1 = shooter
2 = victim
[] = wall

#### Re: get player id behind the wall

DC

So if the mouse pointer of player 1 is pointing at player 2, you want to display the id of player 2?

If yes you can do this in the attack hook (or any other hook):
retrieve mousemapxand mousemapy of player 1 with player
create 2 variables id and distance,
iterate over all living players:
1
2
3
4
```local playerlist=player(0,"tableliving")
for _,id in pairs(playerlist) do
' insert distance check logic here
end
```
inside the loop calculate the distance of the player position ( player x and y) and mouse position from the first step. You can probably skip player 1 (the one you got the mouse cursor position from)
if the the id variable is still 0 or if the calculated distance is smaller than the value in the distance variable, save the player id and the distance to the variables
at the end of the loop the id variable will contain the id of the closest player to the cursor and the distance variable will contain the distance between that player and the cursor
in the end you can check if the distance is close enough (<= 32 for instance) and then display the ID

If this should also work when the mouse cursor of player 1 is NOT pointing exactly at player 2 but also when player 1 is just looking at player 2 you have to use some math and check which player is closest to the invisible line of sight of player 1.

#### Re: get player id behind the wall

Unknown_Cheater
User Offline

@ DC:
1
2
3
4
5
6
7
8
9
10
11
```vid = 0

function attack_(sid)
if player(sid, "weapon") == 32 then
if player(sid, "rot") ==  -- its victim position idk how to do it
vid = -- idk how to get victim id, dont using hit hook
msg2(sid, "ID: "..vid)
end
end
end
```

#### Re: get player id behind the wall

DC

So you also want to get the ID of players the player is "looking at" without pointing at them with the cross hair?

In either way you have to iterate over all other players and do a distance check. Either the distance to the mouse pointer of player 1 or the distance to the line of sight of player 1.
https://en.wikipedia.org/wiki/Distance_from_a_point_to_a_line

#### Re: get player id behind the wall

Unknown_Cheater
User Offline

distance
1
```math.sqrt((player(sid, "x") - player(vid, "x")) ^ 2 + (player(sid, "y") - player(vid, "y")) ^ 2))
```
1