I am trying to make a plugin that plays a sound when you press a key, and a looping sound in the back
Code:
#include <amxmodx>
#include <amxmisc>
#include <engine>
#include <fakemeta>
#define PLUGIN "Key sounds"
#define VERSION "1.0"
#define AUTHOR "BuNdEvA"
#define time 0.75 //how often the sound repeats
public plugin_precache()
{
precache_sound("Zvukovi/kick")
//add custom sounds here
//precache_sound(sound directory here)
}
public pluginInit()
{
new sound[81]; //repeating sound
new sound1[81]; //duck sound
new sound2[81]; //jump sound
new sound3[81]; //a sound
new sound4[81]; //d sound
new sound5[81]; //w sound
new sound6[81]; //s sound
sound[] = {"Zvukovi/kick"};
sound1[] = {" "};
sound2[] = {" "};
sound3[] = {" "};
sound4[] = {" "};
sound5[] = {" "};
sound6[] = {" "};
register_plugin(PLUGIN,VERSION,AUTHOR)
register_clcmd("+duck", "playSound1;+duck")
register_clcmd("+jump", "playSound2;+jump")
register_clcmd("+moveleft", "playSound3;+moveleft")
register_clcmd("+moveright", "playSound4;+moveright")
register_clcmd("+forward", "playSound5;+forward")
register_clcmd("+backward", "playSound6;+backward")
}
public soundRepeat()
{
set_task(time, "playRepeatSound", _, _, _, "b")
}
public playRepeatSound()
{
client_cmd(0, "spk ^"%s^"", sound)
}
public playSound1()
{
client_cmd(0, "spk ^"%s^"", sound1)
return PLUGIN_HANDLED
}
public playSound2()
{
client_cmd(0, "spk ^"%s^"", sound2)
return PLUGIN_HANDLED
}
public playSound3()
{
client_cmd(0, "spk ^"%s^"", sound3)
return PLUGIN_HANDLED
}
public playSound4()
{
client_cmd(0, "spk ^"%s^"", sound4)
return PLUGIN_HANDLED
}
public playSound5()
{
client_cmd(0, "spk ^"%s^"", sound5)
return PLUGIN_HANDLED
}
public playSound6()
{
client_cmd(0, "spk ^"%s^"", sound6)
return PLUGIN_HANDLED
}
I'm used to programming in c++ so I wanted to give Pawn a try, it seamed fairly easy, but I clearly don't know how to work it...