Forum

> > CS2D > Scripts > get player id behind the wall
Forums overviewCS2D overview Scripts overviewLog in to reply

English get player id behind the wall

4 replies
To the start Previous 1 Next To the start

old Re: get player id behind the wall

DC
Admin On Online

Quote
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 cs2d lua hook attack hook (or any other hook):
• retrieve mousemapxand mousemapy of player 1 with cs2d lua cmd 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 (cs2d lua cmd 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.

old Re: get player id behind the wall

Unknown_Cheater
User Off Offline

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

addhook("attack", "attack_")
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
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview