Forum

> > CS2D > Scripts > How to know if a player is flashbanged?
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch How to know if a player is flashbanged?

4 Antworten
Zum Anfang Vorherige 1 Nächste Zum Anfang

alt How to know if a player is flashbanged?

Mami Tomoe
User Off Offline

Zitieren
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.

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

DC
Admin Off Offline

Zitieren
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.

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

Mami Tomoe
User Off Offline

Zitieren
@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 hat geschrieben
• 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.

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

SQ
Moderator Off Offline

Zitieren
@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
1× editiert, zuletzt 03.05.21 01:59:09
Zum Anfang Vorherige 1 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht