Forum

> > CS2D > Scripts > How to know if a player is flashbanged?
Forums overviewCS2D overview Scripts overviewLog in to reply

English How to know if a player is flashbanged?

4 replies
To the start Previous 1 Next To the start

old How to know if a player is flashbanged?

Mami Tomoe
User Off Offline

Quote
Hello, I require your assistance in creating a function, or a module that will receive a player ID, and return a boolean value stating whether the player is flashed (by a Flashbang) or not.

Here's an example:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
local function is_flashed(p)
	-- I assume you'd need to use the projectile hook.
	-- And then have a timer for every flashed player and player data, and various other things, but this is all I currently have.
end

local cs2d_player = player

function player(p, value)
	if value == 'flashed' then
		
		return is_flashed(p)
	end
	
	return cs2d_player(p, value)
end

Thank you.

old Re: How to know if a player is flashbanged?

DC
Admin Off Offline

Quote
Unfortunately there is currently no direct way to check that.
There's cs2d lua cmd player with "ai_flashed" but that only works for bots.

The workaround would be to use cs2d lua hook projectile and check if it's a flashbang. If that's the case you need to check two things:
• the distance (if the flashbang is visible on the screen of the player)
• if there's a direct free line between player and flashbang via

Then you can use a global table with timer values to store the flash-state per player and count it down.

old Re: How to know if a player is flashbanged?

Mami Tomoe
User Off Offline

Quote
@user DC, I'm aware there is currently no way of checking that, and I assumed this would be how to achieve that, but I'm struggling with this part:

user DC has written
• if there's a direct free line between player and flashbang


I'm not very good with math, and I want to make an efficient way of checking that.

Assuming everything goes well, simply having that done would mean I can make the rest alone.

old Re: How to know if a player is flashbanged?

SQ
Moderator Off Offline

Quote
@user Mami Tomoe: I think my achievements script had a check if you have flashed the player.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
function stat_projectile(id,w,zx,zy)
	if (w == 52) then
		for m, p in pairs(player(0,"table")) do
			if (player(id,"team") ~= player(p,"team")) then
				local px = player(p,"x")
				local py = player(p,"y")
				local fx = zx
				local fy = zy
				if (pointInRect(zx,zy,px - 336,py - 256,640,480) == true) then
					local rot = math.atan2(fy - py, fx - px)
					local hit = 1
					while distance(fx,fy,px,py) > 4 do
						fx = fx - math.cos(rot) * 3
						fy = fy - math.sin(rot) * 3
						if (tile(math.ceil(fx / 32) - 1,math.ceil(fy / 32) - 1,"wall")) then
							hit = 0
							--break
						end
					end
					if (hit > 0) then
						IncreaseUserValue(id,"SuccessFlashbang",1)
					end
				end
			end
		end
	end
end
edited 1×, last 03.05.21 01:59:09 am
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview