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

Playback event


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
redivcram
Veteran Member
Join Date: Jul 2014
Location: Serbia
Old 10-31-2015 , 07:07   Playback event
Reply With Quote #1

This plugin is supposed to replace Deagle fire sound with hl 357 sound.. simply when I shoot with deagle it's firing sound is supposed to be the 357 shot.. but I get the same sound, I'm not familiar with this but can someone explain it to me?

PHP Code:
#include <amxmodx>
#include <fakemeta>

#define FIRE_SND "weapons/357_shot1.wav"

new const gGunsEvents[] = { "events/deagle.sc" };

new 
gGunsEventIdsBitSumgFwIdgMaxClients;

public 
plugin_precache()
{
    
precache_sound(FIRE_SND);
    
    
gFwId register_forwardFM_PrecacheEvent "fwPrecacheEvent" );
}

public 
fwPrecacheEvent(type, const name[]) 
{
    for(new 
0sizeof gGunsEvents; ++i
    {
        if(
equal(gGunsEvents[i], name)) 
        {
            
gGunsEventIdsBitSum |= (<< get_orig_retval());
            return 
FMRES_HANDLED;
        }
    }
    
    return 
FMRES_IGNORED;
}

public 
plugin_init()
{
    
register_plugin("Weapon Ent""1.0""EsprimoP");
    
    
unregister_forward(FM_PrecacheEvent gFwId 1);
    
register_forward(FM_PlaybackEvent "fwPlaybackEvent");
    
    
global_get(glb_maxClients);
}

public 
fwPlaybackEvent(flagsinvokereventid
{
    if (!(
gGunsEventIdsBitSum & (<< eventid)) || !(<= invoker <= gMaxClients))
        return 
FMRES_IGNORED;
    
    
emit_sound(invokerCHAN_WEAPONFIRE_SNDVOL_NORMATTN_NORM0PITCH_NORM);
    
    return 
FMRES_HANDLED;

redivcram is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 10-31-2015 , 10:16   Re: Playback event
Reply With Quote #2

IIRC, from PlaybackEvent you can only change the sound that other players hear from you, not the sound that you hear.
__________________
HamletEagle is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 10-31-2015 , 10:30   Re: Playback event
Reply With Quote #3

It does work, HamletEagle. There's a thread regarding changing the fire sound that I just replied to. In my tests I replaced the sound for every weapon for the M4A1 and it worked, but I found it worked inconsistently. And I cannot test if other players hear the correct sound. But I definitely heard M4A1 sound for deagle, AK47, AWP in my tests.
__________________
Bugsy is offline
redivcram
Veteran Member
Join Date: Jul 2014
Location: Serbia
Old 10-31-2015 , 10:34   Re: Playback event
Reply With Quote #4

Since It's not my thread, I got the code from you that you posted and changed it for deagle only.. as you can see above. What's the problem?
redivcram is offline
zmd94
Veteran Member
Join Date: Nov 2013
Location: Malaysia (9w2zow).
Old 10-31-2015 , 10:34   Re: Playback event
Reply With Quote #5

This is the link:

https://forums.alliedmods.net/showpo...24&postcount=8
zmd94 is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 10-31-2015 , 10:42   Re: Playback event
Reply With Quote #6

This is your problem:
PHP Code:
if(equal(gGunsEvents[i], name)) 
//should be 
if(equal(gGunsEventsname)) 
You were doing the following for the length of the FIRE_SND string, checking 1 char versus the name string in fwPrecacheEvent.
Code:
if "e" == "events/weaponX.sc" 
if "v" == "events/weaponX.sc"
if "e" == "events/weaponX.sc"
if "n" == "events/weaponX.sc"
if "t" == "events/weaponX.sc"
etc.
This works for me:
PHP Code:
#include <amxmodx>
#include <fakemeta>

new const FireSound[] = "weapons/m4a1-1.wav";

new const 
g_guns_events[] = "events/deagle.sc";

new 
g_guns_eventids_bitsum g_fwid g_max_clients;

public 
plugin_precache() 
{
    
precache_soundFireSound );
    
    
g_fwid register_forwardFM_PrecacheEvent "fwPrecacheEvent" );
}

public 
fwPrecacheEventtype , const name[] ) 
{
    for (new 
0sizeof g_guns_events; ++i
    {
        if ( 
equalg_guns_events name ) ) 
        {
            
g_guns_eventids_bitsum |= ( << get_orig_retval() );
            return 
FMRES_HANDLED;
        }
    }
    
    return 
FMRES_IGNORED;
}

public 
plugin_init() 
{
    
unregister_forwardFM_PrecacheEvent g_fwid );
    
register_forwardFM_PlaybackEvent "fwPlaybackEvent" );
    
    
g_max_clients global_get(glb_maxClients);
}

public 
fwPlaybackEventflags invoker eventid 
{
    if ( !( 
g_guns_eventids_bitsum & ( << eventid ) ) || !( <= invoker <= g_max_clients ) )
        return 
FMRES_IGNORED;
    
    
emit_soundinvoker CHAN_WEAPON FireSound VOL_NORM ATTN_NORM PITCH_NORM );
    
    return 
FMRES_HANDLED;

__________________

Last edited by Bugsy; 10-31-2015 at 11:25.
Bugsy is offline
redivcram
Veteran Member
Join Date: Jul 2014
Location: Serbia
Old 10-31-2015 , 11:38   Re: Playback event
Reply With Quote #7

Sorry about that... I'll try and look harder next time.

I tried the code, but nothing. I fire deagle and still same sound
redivcram is offline
redivcram
Veteran Member
Join Date: Jul 2014
Location: Serbia
Old 10-31-2015 , 14:00   Re: Playback event
Reply With Quote #8

When you say "This works for me", do other players hear m4 when you shoot deagle or do you?
redivcram is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 10-31-2015 , 14:57   Re: Playback event
Reply With Quote #9

I just tested with bots and I heard their normal gun sound. Not sure how to debug, I can try when I have time.
__________________
Bugsy is offline
redivcram
Veteran Member
Join Date: Jul 2014
Location: Serbia
Old 10-31-2015 , 19:15   Re: Playback event
Reply With Quote #10

Alright
redivcram 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 14:12.


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