AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Download the sounds if they do not have (https://forums.alliedmods.net/showthread.php?t=184908)

Sutar 05-10-2012 09:49

Download the sounds if they do not have
 
That made the test, and does not compile ...
writes:

Quote:

//AMXXPC compile.exe
// by the AMX Mod X Dev Team

//// loadsound.sma
// D:\test\cstrike\addons\amxmodx\scripting\load sound.sma(29) :
error 088: number of arguments does not match definition
//
// 1 Error.
// Could not locate output file D:\Server\test_minimap1\cstrike\addons\amxmod x\scripting\compiled\loadsound.amx (compile failed).
//
// Compilation Time: 0,06 sec
// ----------------------------------------

Press enter to exit ...

I've highlighted the line 29

Code:

#include <amxmodx>

#define MaxSounds 2

new soundlist[MaxSounds][] =
{
"sound/loading/loading_1",
"sound/loading/loading_2"
}

public plugin_init()
{
        register_plugin("Loading Sound", "1.5", "Sutar")
}

public client_connect(id)
{
        client_cmd(id, "mp3 play %s", soundlist[random_num(1, MaxSounds)])
        return PLUGIN_CONTINUE
}

public plugin_precache()
{
        for(new i = 0; i < MaxSounds; i++)
        {
                if(!file_exists(soundlist[i]))
                        precache_sound("%s.mp3", soundlist[i])
        }
       
        return PLUGIN_CONTINUE
}

Why a mistake?

<VeCo> 05-10-2012 09:58

Re: Download the sounds if they do not have
 
PHP Code:

precache_generic(soundlist[i]) 


Pattinho 05-10-2012 10:00

Re: Download the sounds if they do not have
 
Well at first you should change the Random num, because it is between 0 and 1 instead of 1 and 2.

and its better if you use this here.

PHP Code:

 public plugin_precache()
{
    for(new 
0MaxSoundsi++)
    {
        if(!
file_exists(soundlist[i])){
                new 
path[75]
                        
format(path,74,"%s.mp3",soundlist[i])
                     
precache_sound(path)
               }
    }
    
    return 
PLUGIN_CONTINUE


Its because you can't set in precache_sound "%s"

GordonFreeman (RU) 05-10-2012 10:01

Re: Download the sounds if they do not have
 
Code:
#include <amxmodx> #define MaxSounds 2 new soundlist[MaxSounds][] = { "sound/loading/loading_1.mp3", "sound/loading/loading_2.mp3" } public plugin_init() {     register_plugin("Loading Sound", "1.5", "Sutar") } public client_connect(id) {     client_cmd(id, "mp3 play %s", soundlist[random_num(1, MaxSounds)])     return PLUGIN_CONTINUE } public plugin_precache() {     for(new i = 0; i < MaxSounds; i++)     {         if(!file_exists(soundlist[i])){             precache_sound(soundlist[i])     }         return PLUGIN_CONTINUE } }

precache_sound doesnt not support formated lines

Sutar 05-10-2012 11:40

Re: Download the sounds if they do not have
 
Thank you very much, but here I thought that with this script will correct this error:

Quote:

Missing RIFF/WAVE chunks
Missing RIFF/WAVE chunks
Missing RIFF/WAVE chunks
Missing RIFF/WAVE chunks
How can I fix it?

Sutar 05-11-2012 16:55

Re: Download the sounds if they do not have
 
That's how you can correct the error?

Arkshine 05-11-2012 17:16

Re: Download the sounds if they do not have
 
Use precache_generic

Sutar 05-12-2012 03:32

Re: Download the sounds if they do not have
 
Quote:

#include <amxmodx>

#define MaxSounds 4

new soundlist[MaxSounds][] =
{
"sound/loading/sound_1",
"sound/loading/sound_2",
"sound/loading/sound_3",
"sound/loading/sound_4"
}

public plugin_init()
{
register_plugin("Loading Sound", "1.5", "Sutar")
}

public client_connect(id)
{
client_cmd(id, "mp3 play %s", soundlist[random_num(0, MaxSounds)])
return PLUGIN_CONTINUE
}

public plugin_precache()
{
for(new i = 0; i < MaxSounds; i++)
{
if(!file_exists(soundlist[i]))
{
new path[75]
format(path, 74, "%s.mp3", soundlist[i])
precache_generic(path)
}
}

return PLUGIN_CONTINUE
}
Here everything seems right, but an error in line 20
line 20:

Quote:

client_cmd(id, "mp3 play %s", soundlist[random_num(0, MaxSounds)])
if you do "MaxSounds - 1". All is well, but the last sound will not play. What is wrong?

Xalus 05-12-2012 04:06

Re: Download the sounds if they do not have
 
client_cmd(id, "mp3 play %s", soundlist[random(MaxSounds)])

Sutar 05-12-2012 05:51

Re: Download the sounds if they do not have
 
Thank you very much.
Everything is working fine.

Can you help to make this function?
I want the path to every sound, to write to a file in a new line of ...
can help to make this function?

So I wrote to connect to the file:
Quote:

public plugin_init()
{
register_plugin("Loading Sound", "1.5", "Sutar")

new dirname[110], filename[125], string[192]
get_configsdir(dirname, 109)
format(filename, 124, "%s/sound.ini", dirname)
new file = fopen(filename, "rt")
}
But how to make "soundlist" includes all addresses are sounds that are in the file "sound.ini"?

Example:
The content of the file "sound.ini"
Quote:

sound/loading/sound_1
sound/loading/sound_2
sound/loading/sound_3
In the plug-in will be read and the variable "soundlist" will be:

Quote:

soundlist[][] = {
"sound/loading/sound_1",
"sound/loading/sound_2",
"sound/loading/sound_3"
}


All times are GMT -4. The time now is 00:19.

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