How to reset the player's sound to normal on player_blind?

Please post any questions about developing your plugin here. Please use the search function before posting!
User avatar
BackRaw
Senior Member
Posts: 537
Joined: Sun Jul 15, 2012 1:46 am
Location: Germany
Contact:

How to reset the player's sound to normal on player_blind?

Postby BackRaw » Fri Jan 30, 2015 3:56 pm

Hi,

the topic title says it lol. Is it possible? On a PreHook maybe? If so, how would I go about that?
My Github repositories:

Source.Python: https://github.com/backraw
User avatar
satoon101
Project Leader
Posts: 2697
Joined: Sat Jul 07, 2012 1:59 am

Postby satoon101 » Fri Jan 30, 2015 4:12 pm

You don't want players to be blinded either, correct? If so, I would say to hook CFlashbang::Detonate (not fully sure on the names there). I am at work, so I cannot provide an example till I get home.

*Edit: perhaps CCSPlayer::Blind might work, too. Not sure if that also causes the sound, though.
Image
User avatar
BackRaw
Senior Member
Posts: 537
Joined: Sun Jul 15, 2012 1:46 am
Location: Germany
Contact:

Postby BackRaw » Fri Jan 30, 2015 5:05 pm

satoon101 wrote:You don't want players to be blinded either, correct? If so, I would say to hook CFlashbang: :D etonate (not fully sure on the names there). I am at work, so I cannot provide an example till I get home.

*Edit: perhaps CCSPlayer::Blind might work, too. Not sure if that also causes the sound, though.


Alright, I'm not sure if I want players to be blinded or not yet. That's why I have to figure it out :) Either way, I definitely need to stop the sound from playing, that would add more "Fun" lol :D
My Github repositories:

Source.Python: https://github.com/backraw
User avatar
Ayuto
Project Leader
Posts: 2195
Joined: Sat Jul 07, 2012 8:17 am
Location: Germany

Postby Ayuto » Fri Jan 30, 2015 5:10 pm

Do you want an anti-flash for everyone or just for some people? In the first case you can just hook CFlashbangProjectile::Detonate().

If you only want to disable that for some specific users, you need to hook CCSPlayer::Deafen() to disable the sound and CCSPlayer::Blind() to disable the blinding part.
User avatar
BackRaw
Senior Member
Posts: 537
Joined: Sun Jul 15, 2012 1:46 am
Location: Germany
Contact:

Postby BackRaw » Fri Jan 30, 2015 5:15 pm

Ayuto wrote:Do you want an anti-flash for everyone or just for some people? In the first case you can just hook CFlashbangProjectile: :D etonate().

If you only want to disable that for some specific users, you need to hook CCSPlayer: :D eafen() to disable the sound and CCSPlayer::Blind() to disable the blinding part.


Awesome, thanks. Can i do it the same way you provided here?
My Github repositories:

Source.Python: https://github.com/backraw
User avatar
Ayuto
Project Leader
Posts: 2195
Joined: Sat Jul 07, 2012 8:17 am
Location: Germany

Postby Ayuto » Fri Jan 30, 2015 5:16 pm

Yep, that should work.
User avatar
BackRaw
Senior Member
Posts: 537
Joined: Sun Jul 15, 2012 1:46 am
Location: Germany
Contact:

Postby BackRaw » Fri Jan 30, 2015 5:29 pm

How do I find out what parameters I need lol? :D
My Github repositories:

Source.Python: https://github.com/backraw
User avatar
Ayuto
Project Leader
Posts: 2195
Joined: Sat Jul 07, 2012 8:17 am
Location: Germany

Postby Ayuto » Fri Jan 30, 2015 5:42 pm

Just open IDA and look up those functions:

CCSPlayer::Blind(float, float, float)
CCSPlayer::Deafen(float)
User avatar
BackRaw
Senior Member
Posts: 537
Joined: Sun Jul 15, 2012 1:46 am
Location: Germany
Contact:

Postby BackRaw » Fri Jan 30, 2015 6:26 pm

ayuto wrote:just open ida and look up those functions:

Ccsplayer::blind(float, float, float)
ccsplayer::deafen(float)


ida? =d
My Github repositories:

Source.Python: https://github.com/backraw
User avatar
Ayuto
Project Leader
Posts: 2195
Joined: Sat Jul 07, 2012 8:17 am
Location: Germany

Postby Ayuto » Fri Jan 30, 2015 6:39 pm

http://en.wikipedia.org/wiki/Interactive_Disassembler

But of course you can also use a different disassembler if you want.
User avatar
BackRaw
Senior Member
Posts: 537
Joined: Sun Jul 15, 2012 1:46 am
Location: Germany
Contact:

Postby BackRaw » Fri Jan 30, 2015 7:26 pm

Ayuto wrote:http://en.wikipedia.org/wiki/Interactive_Disassembler

But of course you can also use a different disassembler if you want.


Good to know!! Thanks :D
My Github repositories:

Source.Python: https://github.com/backraw
User avatar
satoon101
Project Leader
Posts: 2697
Joined: Sat Jul 07, 2012 1:59 am

Postby satoon101 » Sat Jan 31, 2015 4:45 am

I have added CFlashbangProjectile::Detonate and CCSPlayer::Blind for CS:S and CS:GO to my data locally. CCSPlayer::Deafen will require a symbol/signature, and seems to be a bit tricky at first glance (no time to work on now, need some sleep). Once we get all 3 added to the repo, you will be able to use/hook them in your scripts more easily.
Image
User avatar
Ayuto
Project Leader
Posts: 2195
Joined: Sat Jul 07, 2012 8:17 am
Location: Germany

Postby Ayuto » Sat Jan 31, 2015 9:52 am

This is for CS:S:

Code: Select all

_ZN9CCSPlayer6DeafenEf
55 8B EC 83 EC 28 89 4D FC 8B 45 FC 8B 10
I will take a look at CS:GO's signature later today.
User avatar
BackRaw
Senior Member
Posts: 537
Joined: Sun Jul 15, 2012 1:46 am
Location: Germany
Contact:

Postby BackRaw » Sat Jan 31, 2015 11:54 am

I'll be patient :)
My Github repositories:

Source.Python: https://github.com/backraw
User avatar
Ayuto
Project Leader
Posts: 2195
Joined: Sat Jul 07, 2012 8:17 am
Location: Germany

Postby Ayuto » Sat Jan 31, 2015 4:46 pm

I have now taken a look at CS:GO and found this signature.

Code: Select all

55 8B EC 83 EC 28 56 57 8B F9 F3 0F 11 4D FC
However, this is a special function as it uses a custom calling convention on Windows. The "this" pointer is passed through the ecx register (that's usual for a Windows thiscall), but the other argument is passed through the xmm1 register and that's unusual. There is nothing pushed onto the stack. We can still hook the function, but we can't access its arguments.

Syntax: Select all

import memory

from memory import Convention
from memory import Argument
from memory import Return

from memory.hooks import PreHook

server = memory.find_binary('server')

deafen = server[b'\x55\x8B\xEC\x83\xEC\x28\x56\x57\x8B\xF9\xF3\x0F\x11\x4D\xFC'].make_function(
Convention.THISCALL,
(Argument.POINTER,),
Return.VOID
)

@PreHook(deafen)
def my_hook(args):
print(tuple(args))
return 0
User avatar
satoon101
Project Leader
Posts: 2697
Joined: Sat Jul 07, 2012 1:59 am

Postby satoon101 » Sun Feb 01, 2015 1:18 am

Does this also mean we cannot call that function? Stinks that we can't get the arguments, but at least in this instance I don't think he needs them.

Thank you for the signatures :)
Image
User avatar
Ayuto
Project Leader
Posts: 2195
Joined: Sat Jul 07, 2012 8:17 am
Location: Germany

Postby Ayuto » Sun Feb 01, 2015 12:26 pm

satoon101 wrote:Does this also mean we cannot call that function?
Yep, currently we can't, but we can update our plugin so that we can also handle these special cases. I have several ideas, but I need some time to think about them.
User avatar
BackRaw
Senior Member
Posts: 537
Joined: Sun Jul 15, 2012 1:46 am
Location: Germany
Contact:

Postby BackRaw » Sun Feb 01, 2015 2:34 pm

satoon101 wrote:Does this also mean we cannot call that function? Stinks that we can't get the arguments, but at least in this instance I don't think he needs them.

I guess not. I just need the player_blind event to not fire, e.g. return False or something in the pre event function. I only want the players to be flashed visually, so I would do something like this:

Syntax: Select all

@PreEvent
def pre_player_blind(userid):

player = Player(index_from_userid(userid))

# simulate flashing without sound, just visually
player.set_property_float("m_flFlashMaxAlpha", 200.0)
player.set_property_float("m_flFlashDuration", 1.4)


# either set the player's sound somehow

# or stop player_blind from firing
return False
My Github repositories:

Source.Python: https://github.com/backraw
User avatar
satoon101
Project Leader
Posts: 2697
Joined: Sat Jul 07, 2012 1:59 am

Postby satoon101 » Sun Feb 01, 2015 8:24 pm

That's not exactly what I meant. I just mean you don't need access to the float value that is passed to CCSPlayer::Deafen. You can still return False from hooking that method to stop the deafening sound from playing. And, if you do want to know which player is being deafened, you have access to that through args[0] (which is a Pointer).
Image
User avatar
BackRaw
Senior Member
Posts: 537
Joined: Sun Jul 15, 2012 1:46 am
Location: Germany
Contact:

Postby BackRaw » Sun Feb 01, 2015 8:31 pm

satoon101 wrote:That's not exactly what I meant. I just mean you don't need access to the float value that is passed to CCSPlayer: :D eafen. You can still return False from hooking that method to stop the deafening sound from playing. And, if you do want to know which player is being deafened, you have access to that through args[0] (which is a Pointer).


Ooooh, true. I have to think about how I want to implement it first :)
My Github repositories:

Source.Python: https://github.com/backraw

Return to “Plugin Development Support”

Who is online

Users browsing this forum: No registered users and 141 guests