AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Walk triggers sound? (https://forums.alliedmods.net/showthread.php?t=61559)

Elite_Fallen_Angel 10-03-2007 14:53

Walk triggers sound?
 
How would I have a custom sound play everytime a player walks?

I disabled mp_footsteps if that makes any difference?

Thank you for any and all help :)

M249-M4A1 10-03-2007 15:28

Re: Walk triggers sound?
 
You could try and loop an iceskate sound on a player using set_task that loops for as long as the soundfile is. I'm assuming this goes along with your iceskate plugin. It's the only way I could think of doing it right now, but I'm sure theres a more efficient method of doing this

Elite_Fallen_Angel 10-03-2007 16:19

Re: Walk triggers sound?
 
The sound file is 3 seconds.

I don't want it to play when they aren't moving though. Maybe if I set it to loop everytime a player presses:
A, W, S, D
and then stops when they release the key.?

I am not sure how to do it but I will try and figure it out. Any help would be greatly appreciated.

Lord_Destros 10-03-2007 16:38

Re: Walk triggers sound?
 
That wouldn't make sense if someone is holding the key down but is not moving (running into a wall/corner). To get around that you could probably get the users origin to see if they have moved while holding it down (while ignoring z access).

Elite_Fallen_Angel 10-03-2007 16:40

Re: Walk triggers sound?
 
That's a good idea!

Um, I will look around on the Wiki to see what I can come up with. Any sample code would help :)

Alka 10-04-2007 10:26

Re: Walk triggers sound?
 
Hum, i've maded something...maybe is not the best way but shold work :D

Code:

#include <amxmodx>
#include <fakemeta>
 
#define PLUGIN "Custom FootSteps Sound"
#define VERSION "1.0"
#define AUTHOR "Alka"
 
new Float:NextCheck[33];
new const FootStepSound[] = "misc/whatever.wav";
 
public plugin_init() {
    register_plugin(PLUGIN, VERSION, AUTHOR);
 
    register_forward(FM_PlayerPostThink, "Fwd_PlayerPostThink");
}
 
public Fwd_PlayerPostThink(id)
{
    if(!is_user_alive(id))
          return;
 
    static Float:gametime;
    gametime = get_gametime();
 
    if(NextCheck[id] < gametime)
    {
          static Float:Velocity[3], Button;
 
          pev(id, pev_velocity, Velocity);
          pev(id, pev_button, Button);
 
          if((Button & IN_FORWARD) || (Button & IN_BACK) || (Button & IN_LEFT) || (Button & IN_RIGHT))
          {
              if(pev(id, pev_flFallVelocity) == 0.0 && floatround(vector_length(Velocity)) != 0.0)
              {
                    emit_sound(id, CHAN_VOICE, FootStepSound, VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
              }
          }
          NextCheck[id] = gametime + 3.0;
    }
}

Is for a sound with 3 sec len. ;)

Wilson [29th ID] 10-10-2007 05:46

Re: Walk triggers sound?
 
Sssssssseeeeeeaaaaarrrrch.

http://forums.alliedmods.net/showthread.php?t=44736


All times are GMT -4. The time now is 16:09.

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