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
Mahi
Senior Member
Posts: 236
Joined: Wed Aug 29, 2012 8:39 pm
Location: Finland

Postby Mahi » Sat May 23, 2015 11:19 am

satoon101 wrote:*Edit: we are working on a couple new decorators that will allow you to hook these types of functions once an entity of the specified type is created on the server. There is still a lot of work to do on it, though. The usage of these decorators 'might' end up looking something like this:

Syntax: Select all

from entities.hooks import EntityPreHook


@EntityPreHook('player', 'deafen')
def pre_deafen(args):
...

Please, please, please, please, YES! :D

When I first saw Source.Python, I thought it's just an other shitty addon which will never see the daylight. I was wrong, this has got to be one of the best things that have ever happened to the CS community!

I can't wait for SP to reach its final version, even though that's still quite far away. Huge thanks to all the SP developers, you're doing one hell of a job, keep on rolling guys! :)
User avatar
BackRaw
Senior Member
Posts: 537
Joined: Sun Jul 15, 2012 1:46 am
Location: Germany
Contact:

Postby BackRaw » Sat May 23, 2015 6:39 pm

Ayuto wrote:Yep, it does. :)


https://github.com/backraw/backraw.sp/blob/master/addons/source-python/plugins/flashfunsp/hooks.py works like a charm! Thanks very much guys :D
My Github repositories:

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

Postby Ayuto » Sat May 23, 2015 9:04 pm

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

Postby BackRaw » Sun May 24, 2015 1:45 am



Awesome job!
My Github repositories:

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

Postby satoon101 » Thu May 28, 2015 6:58 pm

BackRaw wrote:Does return 0 i the pre-hook block the defean function?

You should really use False instead of 0. Actually, I thought we had an enum that we used to block or continue, but I can't find it so maybe we don't.
Image
User avatar
L'In20Cible
Project Leader
Posts: 1536
Joined: Sat Jul 14, 2012 9:29 pm
Location: Québec

Postby L'In20Cible » Thu May 28, 2015 7:11 pm

There is no enum as the returned value of the callback override the real one (if not None).
User avatar
satoon101
Project Leader
Posts: 2703
Joined: Sat Jul 07, 2012 1:59 am

Postby satoon101 » Thu May 28, 2015 7:27 pm

I think that is only true of post hooks. But even with post hooks you modify the return_value argument instead of returning a value. With pre hooks, you just return False to block the function or modify one of the arguments passed to change the behavior during the function call.
Image
User avatar
Ayuto
Project Leader
Posts: 2209
Joined: Sat Jul 07, 2012 8:17 am
Location: Germany

Postby Ayuto » Thu May 28, 2015 7:52 pm

No, L'In20Cible is right. Here is the proof. https://github.com/Source-Python-Dev-Team/Source.Python/blob/master/src/core/modules/memory/memory_hooks.cpp#L124

If you would just return True or False in a PreHook, what would be the return value for the caller?
User avatar
L'In20Cible
Project Leader
Posts: 1536
Joined: Sat Jul 14, 2012 9:29 pm
Location: Québec

Postby L'In20Cible » Thu May 28, 2015 8:52 pm

I think you are mixing SPE syntax which used to be:

Syntax: Select all

return (HookAction.Continue/Override, <overriden return value>)


Which was kinda pointless, as if you return anything, you want it to be overriden.
User avatar
satoon101
Project Leader
Posts: 2703
Joined: Sat Jul 07, 2012 1:59 am

Postby satoon101 » Thu May 28, 2015 9:15 pm

Yeah, I think I am too. I really gotta stop replying while I am at work...
Image
User avatar
BackRaw
Senior Member
Posts: 537
Joined: Sun Jul 15, 2012 1:46 am
Location: Germany
Contact:

Postby BackRaw » Sun Sep 13, 2015 11:00 pm

Any updates on this - return something or change an argument? :)
My Github repositories:

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

Postby satoon101 » Sun Sep 13, 2015 11:36 pm

What exactly are you asking about here, specifically? I did notice in your repository that you block both the deafen and the blind, though you do it very strangely in the blind hook. All you have to do is return False to block the blinding. However, if you want to block both blind and deafen, all you really need to do is block the CFlashbangProjectile::Detonate member function:

Syntax: Select all

@EntityPreHook(EntityCondition.equals_entity_classname('flashbang_projectile'), 'detonate')
def pre_flashbang_detonate(args):
return False


This will also fix everything in this comment I noticed in your code:
https://github.com/backraw/backraw.sp/blob/master/flashfunsp/flashfunsp.py#L204

Syntax: Select all

# In actuality, the player will still get blinded, but they won't
# notice it. The only 'bug' here is that, if they look at the
# detonating grenade, they still see a little explosion.
# I'm not quite sure yet, whether I should leave it like that or try
# to fix it.


Off topic: I have noticed that instead of just updating your repository, you have a tendency to remove the repository completely and start fresh every time you work on it. That sort of defeats part of the purpose of a version control system. I also prefer to have each of my plugins in their own repository instead of one all-encompassing repo, as that is easier for others to post issues and pull requests to and helps keep it a lot more organized.
Image
User avatar
BackRaw
Senior Member
Posts: 537
Joined: Sun Jul 15, 2012 1:46 am
Location: Germany
Contact:

Postby BackRaw » Mon Sep 14, 2015 12:58 pm

satoon101 wrote:What exactly are you asking about here, specifically? I did notice in your repository that you block both the deafen and the blind, though you do it very strangely in the blind hook. All you have to do is return False to block the blinding. However, if you want to block both blind and deafen, all you really need to do is block the CFlashbangProjectile: :D etonate member function:

Syntax: Select all

@EntityPreHook(EntityCondition.equals_entity_classname('flashbang_projectile'), 'detonate')
def pre_flashbang_detonate(args):
return False


This will also fix everything in this comment I noticed in your code:
https://github.com/backraw/backraw.sp/blob/master/flashfunsp/flashfunsp.py#L204

Syntax: Select all

# In actuality, the player will still get blinded, but they won't
# notice it. The only 'bug' here is that, if they look at the
# detonating grenade, they still see a little explosion.
# I'm not quite sure yet, whether I should leave it like that or try
# to fix it.


Thanks!! That's what I need. I asked because there is no return_type in the entities/orangebox/cstrike/CCSPlayer.ini data file:

Syntax: Select all

[[deafen]]
identifier_windows = 55 8B EC 83 EC 28 89 4D FC 8B 45 FC 8B 10
identifier_linux = _ZN9CCSPlayer6DeafenEf
arguments = FLOAT


satoon101 wrote:Off topic: I have noticed that instead of just updating your repository, you have a tendency to remove the repository completely and start fresh every time you work on it. That sort of defeats part of the purpose of a version control system. I also prefer to have each of my plugins in their own repository instead of one all-encompassing repo, as that is easier for others to post issues and pull requests to and helps keep it a lot more organized.


The old repository was messed up and I'm using a different IDE now. Sorry about that.
My Github repositories:

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

Postby satoon101 » Mon Sep 14, 2015 1:34 pm

BackRaw wrote:Thanks!! That's what I need. I asked because there is no return_type in the entities/orangebox/cstrike/CCSPlayer.ini data file:

Syntax: Select all

[[deafen]]
identifier_windows = 55 8B EC 83 EC 28 89 4D FC 8B 45 FC 8B 10
identifier_linux = _ZN9CCSPlayer6DeafenEf
arguments = FLOAT

There is no return type for that function, it's a void. But you have to return something in the pre-hook to block the function from firing.


BackRaw wrote:The old repository was messed up and I'm using a different IDE now. Sorry about that.

No need to apologize, I just found it a bit odd. Do what you want to do, it just defeated one of the primary purposes of having an online repository and version control system.
Image
User avatar
Ayuto
Project Leader
Posts: 2209
Joined: Sat Jul 07, 2012 8:17 am
Location: Germany

Postby Ayuto » Mon Sep 14, 2015 5:21 pm

satoon101 wrote:But you have to return something in the pre-hook to block the function from firing.
Something that is not None. :P

As a reminder for everyone: If a function has a return type that is not "void", you need to return a value of that type to block the original function. If it's a void function, you can return anything that is not None (True, False, 0, 1, 2, object, what ever).
User avatar
BackRaw
Senior Member
Posts: 537
Joined: Sun Jul 15, 2012 1:46 am
Location: Germany
Contact:

Postby BackRaw » Tue Sep 15, 2015 9:22 am

Thank you for craifying! :)

satoon101 wrote:No need to apologize, I just found it a bit odd. Do what you want to do, it just defeated one of the primary purposes of having an online repository and version control system.
Yes, you're right and I know that. ;)
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 80 guests