PDA

View Full Version : Precache sound don't work


nacrotic
06-17-2007, 05:33 PM
#include <amxmodx>
#include <amxmisc>

#define PLUGIN "dod_FunSounds"
#define VERSION "1.0"
#define AUTHOR "N@CR0T!C"

#define MAX_SOUND 64

new g_soundName[MAX_SOUND][32]
new g_soundNums

public plugin_init() {
register_plugin(PLUGIN, VERSION, AUTHOR)
register_cvar("FunSounds_SubFolder","FunSounds")
register_cvar("FunSounds_Remake","0")
modifspeech()

}

public plugin_precache() {
new sndfile[128]
new path[30]
new filename[128]
new soundPath [62]
get_cvar_string("FunSounds_SubFolder",path,29)
get_configsdir(sndfile,127)
format(filename,127,"%s/dod_funsounds.cfg",sndfile);
if (!file_exists(filename)){
return 0
}
new text[256]
new a , pos = 0
while (g_soundNums < MAX_SOUND && read_file(filename,pos++,text,255,a)){
if (text[0] == ';'){
continue
}
if (parse(text,g_soundName[g_soundNums],31) < 1){
continue
}
format(soundPath,61,"%s/%s.wav",path,g_soundName[g_soundNums])
precache_sound(soundPath)
g_soundNums++
}
return 1
}

public modifspeech()
{

if(get_cvar_num("FunSounds_Remake"))
{
new sndfile[128]
new path[30]
new filename[128]
new speechfile[128]
new soundPath [62]
new soundToWrite[96]
get_cvar_string("FunSounds_SubFolder",path,29)
get_configsdir(sndfile,127)
format(filename,127,"%s/dod_funsounds.cfg",sndfile);
format(speechfile,127,"%s/speech.ini",sndfile);
if (!file_exists(filename)){
return 0
}
new text[256]
new a , pos = 0
while (g_soundNums < MAX_SOUND && read_file(filename,pos++,text,255,a)){
if (text[0] == ';'){
continue
}
if (parse(text,g_soundName[g_soundNums],31) < 1){
continue
}
format(soundPath,61,"%s/%s.wav",path,g_soundName[g_soundNums])
if (!file_exists(speechfile)){
return 0
}
format(soundToWrite,95,"^"%s^" ^"spk \^'%s\^'^" ^"cd^" ^"u^"",g_soundName[g_soundNums],soundPath)
write_file ( speechfile, soundToWrite, 35 )
g_soundNums++
}
set_cvar_num("FunSounds_Remake",0)
}
return 1
}

In config dir th file dod_funsounds.cfg
alliesscore
axisscore

the sma compiled but not work

diamond-optic
06-17-2007, 10:28 PM
not totally sure what that is supposed to even do lol.. looks a bit confusing..

Hell Phoenix
06-18-2007, 12:23 AM
What is modifspeech? Also, how do you know its not precaching? It doesnt look like the plugin does anything besides precache some sounds.

nacrotic
06-18-2007, 02:54 AM
What is modifspeech?
short code to add new sound in speech.ini

Also, how do you know its not precaching?
any download at connexion ...

not totally sure what that is supposed to even do lol.. looks a bit confusing..
i would like precacheing sound specified in dod_funsounds.cfg for play ingame later ...

diamond-optic
06-18-2007, 09:55 AM
hmm seems kinda odd thing to do.. to use one config file.. to add stuff to another config file..

if i get a chance this morning ill try looking into it (heh as in actually try running it :) heheh)

nacrotic
06-18-2007, 10:32 AM
ok thank diamond-optic

nacrotic
06-19-2007, 08:25 AM
My script work now

#include <amxmodx>
#include <amxmisc>

#define PLUGIN "dod_FunSounds"
#define VERSION "2.0"
#define AUTHOR "N@CR0T!C"

#define MAX_SOUND 64

new g_soundName[MAX_SOUND][32]
new g_soundNums
new sndfile[128]
new path[32]
new filename[128]
new soundPath [64]
new text[256]
new a , pos = 0

public plugin_init() {
register_plugin(PLUGIN, VERSION, AUTHOR)
register_cvar("amx_funsounds_subfolder","FunSounds")
modifspeech()

}

public plugin_precache() {

get_cvar_string("amx_funsounds_subfolder",path,31)
get_configsdir(sndfile,127)
format(filename,127,"%s/dod_funsounds.cfg",sndfile)
if (!file_exists(filename)){
return 0
}
else
{
a=0
pos=0
g_soundNums=0
while (g_soundNums < MAX_SOUND && read_file(filename,pos++,text,255,a)){
if (text[0] == ';'){
continue
}
if (parse(text,g_soundName[g_soundNums],31) < 1){
continue
}
format(soundPath,63,"%s/%s.wav",path,g_soundName[g_soundNums])
log_amx("%s : precached ok",soundPath)
precache_sound(soundPath)
g_soundNums++
}
}
return PLUGIN_CONTINUE
}

public modifspeech()
{
new speechfile[128]
new soundToWrite[96]
get_cvar_string("amx_funsounds_subfolder",path,31)
get_configsdir(sndfile,127)
format(filename,127,"%s/dod_funsounds.cfg",sndfile)
format(speechfile,127,"%s/speech.ini",sndfile)
if (!file_exists(filename)){
return 0
}
a=0
pos=0
while (g_soundNums < MAX_SOUND && read_file(filename,pos++,text,255,a)){
if (text[0] == ';'){
continue
}
if (parse(text,g_soundName[g_soundNums],31) < 1){
continue
}
format(soundPath,63,"%s/%s",path,g_soundName[g_soundNums])
if (!file_exists(speechfile)){
return 0
}
format(soundToWrite,95,"^"%s^" ^"spk \^'%s\^'^" ^"cd^" ^"u^"",g_soundName[g_soundNums],soundPath)
log_amx("%s : write ok",g_soundName[g_soundNums])
write_file ( speechfile, soundToWrite, 35+g_soundNums )
g_soundNums++
}
set_cvar_num("amx_funsounds_speechremake",0)
return PLUGIN_CONTINUE
}