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

Mute C4


Post New Thread Reply   
 
Thread Tools Display Modes
Plugin Info:     Modification:   Counter-Strike        Category:   Gameplay       
baneado
Veteran Member
Join Date: Dec 2012
Location: amxmodx-es.com
Old 06-12-2015 , 16:35   Mute C4
Reply With Quote #1

Ok, here we go. A simple plugin that block the sound of C4 when a player is planting or disarming it and the beep sound when is planted.

It also can block the red led sprite that appears when is planted.

Well, cvars aren't cvars really, if you change the cvar in current map, you must wait to the next map for see the changes.

Cvars:
  • amx_blockc4led (default: 0). Disable the red led sprite.
  • amx_blockc4sound (default: 1). Disable all possible C4 sounds.
Changelog
Code:
v 0.2:
- Removed: an unnecessary var
- Removed: c4_explode1 sound from the "unprecaching list"


Note: "Unprecaching" that resources is the best method and doesn't cause the server crash
Attached Files
File Type: sma Get Plugin or Get Source (c4mute.sma - 590 views - 1.6 KB)

Last edited by baneado; 06-13-2015 at 07:34. Reason: update 0.2
baneado is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 06-13-2015 , 06:14   Re: Mute C4
Reply With Quote #2

Never do that again, really, never. Even if you tested your method there are good chances that things will go wrong on an untested plugin, trust me. You can do small stupid mistakes that makes your entire plugin fail.

About your plugin, everything is crap, sorry to say that. First thing, why do you create a trie when you already have the list of sounds ? If you would have something like a file where user put sounds, yes, use trie, but why here ? Moreover, you don't know how to use it properly, you should not use something you don't fully understand(you never destroy it + you also choosed the wrong way, a dyn array would be better here than a trie(it still doesn't make sense, just saying)).

unprecache_file is not needed, you can directly use the string from UnPrecache_C4SoundList.

And, just tested this plugin, it doesn't work. As I said, never post an untested plugin. Also, the ideea of blocking precache some resources that are needed doesn't seem sane to me.
__________________

Last edited by HamletEagle; 06-13-2015 at 06:14.
HamletEagle is offline
baneado
Veteran Member
Join Date: Dec 2012
Location: amxmodx-es.com
Old 06-13-2015 , 07:29   Re: Mute C4
Reply With Quote #3

Quote:
Originally Posted by HamletEagle View Post
Never do that again, really, never. Even if you tested your method there are good chances that things will go wrong on an untested plugin, trust me. You can do small stupid mistakes that makes your entire plugin fail.

About your plugin, everything is crap, sorry to say that. First thing, why do you create a trie when you already have the list of sounds ? If you would have something like a file where user put sounds, yes, use trie, but why here ? Moreover, you don't know how to use it properly, you should not use something you don't fully understand(you never destroy it + you also choosed the wrong way, a dyn array would be better here than a trie(it still doesn't make sense, just saying)).

unprecache_file is not needed, you can directly use the string from UnPrecache_C4SoundList.

And, just tested this plugin, it doesn't work. As I said, never post an untested plugin. Also, the ideea of blocking precache some resources that are needed doesn't seem sane to me.
Well, now it's my turn...

Why create a trie? Why not an array? Read this thread please:
Quote:
Originally Posted by joaquimandrade View Post
A trie should be used when you want to posteriorly search for a string.
I have the sound file, but I don't know if the precached file is that file, so I need to search it, right?
It will be more efficient the trie than the array...

The tries don't need to be destroyed:
Quote:
Originally Posted by ConnorMcLeod View Post
Tries don't need to be destroyed at plugin_end, it is automatic.
unprecache_file is not needed, yes, removed. I used it because the other plugin.

Tested the plugin now, and it works, so don't say that.
baneado is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 06-13-2015 , 07:41   Re: Mute C4
Reply With Quote #4

It doesn't work, tested it. I will check again later.

Quote:
I have the sound file, but I don't know if the precached file is that file, so I need to search it, right?
It will be more efficient the trie than the array...
My point is that you can work directly with UnPrecache_C4SoundList. Are you afraid of 1/2 loops per round ? If you want, you can cache the size of UnPrecache_C4SoundList. But, this are micro optimizations, is up to.

About the array and trie you are right, sorry. I had the impresion that you just get all strings, not that you search for a specific one(I just woke up, sorry again).

A trie should be always detroyed, to free up memory. Is better to be sure than having a headache.
It is true that all the handlers to whatever they are should be destroyed automatically, but you never know, and it doesn't hurt to be sure.
__________________

Last edited by HamletEagle; 06-13-2015 at 07:47.
HamletEagle is offline
baneado
Veteran Member
Join Date: Dec 2012
Location: amxmodx-es.com
Old 06-13-2015 , 15:14   Re: Mute C4
Reply With Quote #5

Quote:
Originally Posted by HamletEagle View Post
It doesn't work, tested it. I will check again later.


My point is that you can work directly with UnPrecache_C4SoundList. Are you afraid of 1/2 loops per round ? If you want, you can cache the size of UnPrecache_C4SoundList. But, this are micro optimizations, is up to.

About the array and trie you are right, sorry. I had the impresion that you just get all strings, not that you search for a specific one(I just woke up, sorry again).

A trie should be always detroyed, to free up memory. Is better to be sure than having a headache.
It is true that all the handlers to whatever they are should be destroyed automatically, but you never know, and it doesn't hurt to be sure.
I tested the plugin two times today, it's working.

I'm afraid because what you say is:
PHP Code:
public fw_PrecacheSound(const szSound[])
{
    for( new 
0sizeof(UnPrecache_C4SoundList); i++ )
    {
        if ( 
equal(szSoundUnPrecache_C4SoundList[i]) )
        
// continue code... 
With that code, you will do a loop for every sound precached, instead only one at plugin_init

And, what is the problem if a handler isn't destroyed?
baneado is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 06-13-2015 , 17:30   Re: Mute C4
Reply With Quote #6

A word about Trie. It's true handles themselves are automatically deleted at map change, but not necessary the associated data. in 1.8.2, because how it's designed (re-use of previous memory allocation) and depending what does the plugin, you can actually waste memory. in 1.8.3-dev, library is completely different and it won't happen. You should anyway close always any handles (not only Trie) right away you don't need it.

About your plugin, well, your method is really quite inappropriate. Doing stuffs with unprecached resources will lead only to issues, not necessarily with this plugin itself, but I can see at least: it will generate an unnecessary warning in console, you might break others plugins using such resources for something else, and plugin can't be paused/unpaused properly.

So, you should use a more traditional way, by blocking the emitted sound and the message (and thus adding support for pausing/unpausing). Now about optimization, using a Trie is a bit overkill as PrecacheSound is called only at map change. It's fine to use it, really trivial, but then you should have deleted it once sutffs done.
__________________

Last edited by Arkshine; 06-13-2015 at 17:36.
Arkshine is offline
wickedd
Veteran Member
Join Date: Nov 2009
Old 06-13-2015 , 18:42   Re: Mute C4
Reply With Quote #7

Quote:
Originally Posted by baneado View Post
I tested the plugin two times today, it's working.
I just tried it and it didn't work. I heard the sound and seen the flashing red light.
__________________
Just buy the fucking game!!!!
I hate No-Steamers and lazy ass people.
wickedd is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 06-13-2015 , 19:08   Re: Mute C4
Reply With Quote #8

This will likely not work since FM_Precache* are not registered in plugin_precache().
__________________

Last edited by Arkshine; 06-13-2015 at 19:38.
Arkshine is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 09-17-2015 , 13:38   Re: Mute C4
Reply With Quote #9

Author did not fixed his code. Unapproved, if you decide to post a working version PM any plugin approver and your plugin will be checked again.
__________________
HamletEagle 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 22:14.


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