Raised This Month: $51 Target: $400
 12% 

How to block the sound of give_item()?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
hellmoss
Senior Member
Join Date: Oct 2009
Location: ZOMBIE PLAGUE
Old 11-05-2017 , 04:16   How to block the sound of give_item()?
Reply With Quote #1

Hello, so this is my code:
Code:
strip_user_weapons(id)
give_item(id, "weapon_knife")
When I give a knife to a player it plays the buy sound. Any way around it?
hellmoss is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 11-05-2017 , 04:53   Re: How to block the sound of give_item()?
Reply With Quote #2

FM_EmitSound
__________________
HamletEagle is offline
hellmoss
Senior Member
Join Date: Oct 2009
Location: ZOMBIE PLAGUE
Old 11-05-2017 , 11:23   Re: How to block the sound of give_item()?
Reply With Quote #3

It worked, thanks.
But if I block the buy sound using this forward it will block every time a buy sound occurs, right? There is no way to block the sound in that specific moment of my code with any other method? (I've figured a way but just wanna make sure FM_EmitSound is all I can work with)

Last edited by hellmoss; 11-05-2017 at 11:36.
hellmoss is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 11-05-2017 , 13:53   Re: How to block the sound of give_item()?
Reply With Quote #4

You can register FM_EmitSound right before give_item and unregister it right after.

register_forward
give_item
unregister_forward
__________________
HamletEagle is offline
KiLLeR.
Senior Member
Join Date: Jul 2014
Location: Bulgaria
Old 11-05-2017 , 20:03   Re: How to block the sound of give_item()?
Reply With Quote #5

Or what if he set bool variable to true before give_item and then check in FM_EmitSound if this variable is true and if yes, only then block?!
KiLLeR. is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 11-06-2017 , 05:09   Re: How to block the sound of give_item()?
Reply With Quote #6

Quote:
Originally Posted by KiLLeR. View Post
Or what if he set bool variable to true before give_item and then check in FM_EmitSound if this variable is true and if yes, only then block?!
Whatever works.
__________________

Last edited by HamletEagle; 11-06-2017 at 05:09.
HamletEagle is offline
aron9forever
Veteran Member
Join Date: Feb 2013
Location: Rromania
Old 11-06-2017 , 05:24   Re: How to block the sound of give_item()?
Reply With Quote #7

Quote:
Originally Posted by KiLLeR. View Post
Or what if he set bool variable to true before give_item and then check in FM_EmitSound if this variable is true and if yes, only then block?!
what he suggested is better, because with your way the forward will be called for all sounds and the value of bool will be checked all the time, so that's wasted CPU instructions

if you do it the way he said, the actual register / unregister will be a bit more expensive, but you save on continuous usage as emitsound is called for many other things (knife sounds as an example)


it's not really important in this particular scenario but it took me a while to learn that it makes a huge impact for functions such as prethink, it's better to learn to do it right and get used to doing it that way
__________________
Meanwhile, in 2050:
Quote:
Originally Posted by aron9forever
useless small optimizations
Quote:
Originally Posted by Black Rose View Post
On a map that is 512x512x128 units you end up with 3,355,443,200,000 different "positions". To store each one of those positions individually in the variable "user_or" you need 12 terabytes of memory.
aron9forever is offline
hellmoss
Senior Member
Join Date: Oct 2009
Location: ZOMBIE PLAGUE
Old 11-06-2017 , 05:46   Re: How to block the sound of give_item()?
Reply With Quote #8

Quote:
Originally Posted by HamletEagle View Post
You can register FM_EmitSound right before give_item and unregister it right after.

register_forward
give_item
unregister_forward
Thanks!
hellmoss is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 11:36.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode