English How to check if a player is scoping

10 replies
Goto Page
To the start Previous 1 Next To the start
Up
Goo
User
Offline Off
I need to be able to check if a player is using a scope, and what zoom level.

It's for the shieldhit hook
11.11.19 08:27:24 pm
Up
DC
Admin
Offline Off
Hmm.. I can't think of a way to do that.

I think there's no way in general to check if a player is scoping. In hooks like cs2d lua hook hit it would be possible to check for scoping by checking the amount of damage. This isn't a 100% accurate solution in all cases though (damage can be reduced by previous hits).

Since cs2d lua hook shieldhit doesn't even provide a damage value it's not even possible to use a damage based workaround there
www.UnrealSoftware.de | www.CS2D.com | www.CarnageContest.com | Use the forum & avoid PMs!
11.11.19 08:41:41 pm
Up
Goo
User
Offline Off
@user DC: I decided to use
item(wpn_id, 'dmg')
.
Dirty workaround, but it works well if I use a multiplier like
* 0.5
.

But then I had a problem when I thought about player scoping, for now I ignore scoping but that'll affect gameplay...

There should be a "DMG" variable that gives the amount of damage that the shield mitigated.
11.11.19 08:46:03 pm
Up
DC
Admin
Offline Off
Yep, you're right. Will consider to add a damage param to the shield hook.
www.UnrealSoftware.de | www.CS2D.com | www.CarnageContest.com | Use the forum & avoid PMs!
11.11.19 08:49:01 pm
Up
Goo
User
Offline Off
Don't forget
player(p, 'weaponmode')
.
11.11.19 08:52:41 pm
Up
Masea
Super User
Offline Off
For now, you can try using cs2d lua hook attack2 if I am not wrong.
Create your UI easy and fast: UI Framework | Go deeper into the darkness and test your bravery: file cs2d Outlast 2 Modification (27)
11.11.19 08:54:31 pm
Up
Goo
User
Offline Off
@user Masea: Yeah it's possible to follow the weapon mode for every player in a variable.

But, its unefficient and not really worth the effort.
Plus, it could go wrong without you even realizing it.
11.11.19 09:52:35 pm
Up
DC
Admin
Offline Off
Yep, user Goo. Thought about adding the very same thing. Will do so.
www.UnrealSoftware.de | www.CS2D.com | www.CarnageContest.com | Use the forum & avoid PMs!
12.11.19 05:49:02 pm
Up
Mora_rus
User
Offline Off
add a variable like
Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
player1zoom = 0

addhook("attack2","_attack2")
function _attack2(id,mode)
     if mode==1 then
          player1zoom = 1
     elseif mode==2 then
          player1zoom = 2
     end
end

addhook("shieldhit","_shieldhit")
function _shieldhit(id,source)
     if player1zoom == 1 then
          msg("ah is one")
     elseif player1zoom == 2 then
          msg("oh is two")
     end
end

addhook("select","_select")
function _select(id)
     player1zoom = 0
end

made for 3 minutes and not tested, is only the idea.
I think is enough to keep at least one variable for every player in that case, the select hook allow you to drop the variable(also if u even change the weapon u're in scope to the same weapon it count as "select")

/maybe i'm wrong just kill me :v
edited 2×, last 12.11.19 08:05:04 pm
S.T.A.L.K.E.R. - The Lost Land dev. https://discord.gg/aABCkHQ
12.11.19 06:06:04 pm
Up
mrc
User
Offline Off
Use shieldhit instead shiedhit on line 12.
CS2D GLOBAL Community - www.CS2DGLOBAL.tk
12.11.19 08:03:46 pm
Up
Mora_rus
User
Offline Off
@user mrc: I know right, but as I said I just made an idea for 3 minutes. Just tired after job and less attentive. Fixed post, thanks anyways.
S.T.A.L.K.E.R. - The Lost Land dev. https://discord.gg/aABCkHQ
To the start Previous 1 Next To the start