Raised This Month: $ Target: $400
 0% 

Download the sounds if they do not have


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Sutar
Senior Member
Join Date: Sep 2010
Old 05-10-2012 , 09:49   Download the sounds if they do not have
Reply With Quote #1

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?
Sutar is offline
<VeCo>
Veteran Member
Join Date: Jul 2009
Location: Bulgaria
Old 05-10-2012 , 09:58   Re: Download the sounds if they do not have
Reply With Quote #2

PHP Code:
precache_generic(soundlist[i]) 
__________________
<VeCo> is offline
Pattinho
Member
Join Date: Dec 2007
Old 05-10-2012 , 10:00   Re: Download the sounds if they do not have
Reply With Quote #3

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"

Last edited by Pattinho; 05-10-2012 at 10:00.
Pattinho is offline
GordonFreeman (RU)
Veteran Member
Join Date: Jan 2010
Location: Uzbekistan
Old 05-10-2012 , 10:01   Re: Download the sounds if they do not have
Reply With Quote #4

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
__________________
The functional way is the right way
GordonFreeman (RU) is offline
Sutar
Senior Member
Join Date: Sep 2010
Old 05-10-2012 , 11:40   Re: Download the sounds if they do not have
Reply With Quote #5

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?

Last edited by Sutar; 05-10-2012 at 11:42.
Sutar is offline
Sutar
Senior Member
Join Date: Sep 2010
Old 05-11-2012 , 16:55   Re: Download the sounds if they do not have
Reply With Quote #6

That's how you can correct the error?
Sutar is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 05-11-2012 , 17:16   Re: Download the sounds if they do not have
Reply With Quote #7

Use precache_generic
__________________
Arkshine is offline
Sutar
Senior Member
Join Date: Sep 2010
Old 05-12-2012 , 03:32   Re: Download the sounds if they do not have
Reply With Quote #8

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?
Sutar is offline
Xalus
Veteran Member
Join Date: Dec 2009
Location: Belgium
Old 05-12-2012 , 04:06   Re: Download the sounds if they do not have
Reply With Quote #9

client_cmd(id, "mp3 play %s", soundlist[random(MaxSounds)])
__________________
Retired.
Xalus is offline
Sutar
Senior Member
Join Date: Sep 2010
Old 05-12-2012 , 05:51   Re: Download the sounds if they do not have
Reply With Quote #10

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"
}

Last edited by Sutar; 05-12-2012 at 06:09.
Sutar is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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