Nie wiem dlaczego, ale ten plugin za każdym razem odtwarza 2 takie samie piosenki i potem znowu 2 te same itd. Czy problem tkwi w kodzie ?
#include <amxmodx>
#include <amxmisc>
new gFiles[300][128]
new gCount=0
new cSoundsDir[] = "sound/shotownia/warto_poczekac/"
public plugin_init()
{
register_plugin("RoundSound","2.1","Kobra LeD")
register_event("SendAudio", "win", "a", "2&%!MRAD_terwin")
register_event("SendAudio", "win", "a", "2&%!MRAD_ctwin")
}
public win()
{
if(gCount>0)
{
new rand = random_num(0,gCount-1)
client_cmd(0,"stopsound")
new cleanFile[128]
format(cleanFile, 128, "%s", gFiles[rand])
replace_all(cleanFile, 128, "_", " ")
replace_all(cleanFile, 128, ".mp3", "")
set_hudmessage(255, 0, 0, 0.11, 0.11, 0, 6.0, 12.0)
show_hudmessage(0, "%s",cleanFile)
play_any_sound(gFiles[rand])
}
return PLUGIN_HANDLED
}
public plugin_precache()
{
new rsFile[128],s[128],i
get_configsdir(rsFile, 128)
format(rsFile, 128 ,"%s/roundsound.ini", rsFile) // should be something like addons/amxmodx/configs/
i=fopen(rsFile,"rt")
gCount=0
if(i==0){
log_amx("Error loading config file! [%s]", rsFile)
} else {
while (!feof(i)) // Reading rs config from roundsound.ini
{
fgets(i,s,128)
trim(s)
if(s[0]!=0) {
log_amx("Loaded [%s]", s);
copy(gFiles[gCount], 128, s)
gCount++
}
}
fclose(i)
}
for(i=0;i<gCount;i++)
{
format(s, 200, "%s%s", cSoundsDir, gFiles[i])
precache_generic(s)
}
log_amx("Loaded music files: %d", gCount)
return PLUGIN_CONTINUE
}
public play_any_sound(sound[])
{
new is_mpeg = ( containi(sound, ".mp3") != -1 )
if ( is_mpeg )
client_cmd(0, "mp3 play ^"%s%s^"", cSoundsDir, sound)
else
client_cmd(0, "spk ^"%s%s^"", cSoundsDir, sound)
}
Jeśli tak to proszę o poprawienie.
PS. Nie wiedziałem w jakim dziale to dać więc umieściłem tutaj .


Dodatki SourceMod














