AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   mp3 play problems (https://forums.alliedmods.net/showthread.php?t=243219)

pob18 07-01-2014 10:37

mp3 play problems
 
why the music does not play at te rr time?

PHP Code:

#include <amxmodx>
#include <amxmisc>
#include <dhudmessage>
#include <hamsandwich>
#include <fun>

#define PRECACHE_SOUND "server/music.mp3"

new TimerSecondsCvar
new bool:g_knife true

public plugin_init()
{
    
register_event("DeathMsg""on_death""a")
    
register_event"CurWeapon""EventCurWeapon""be""2!29" )
    
    
SecondsCvar register_cvar("auto_rr_time","50.0")

    
Timer get_pcvar_num(SecondsCvar)
    
set_task(1.0"start_rr_timer"___"a"Timer)
}


public 
plugin_precache()
    
precache_sound(PRECACHE_SOUND)


public 
on_death()
{
    new 
victim
    victim 
read_data(2)
    
    if(
g_knife)
        
set_task(1.0"fnRevivePlayer"victim)
}

public 
fnRevivePlayer(id
{
    if(!
is_user_alive(id)) 
        
ExecuteHamB(Ham_CS_RoundRespawnid)    
}

public 
EventCurWeapon(id)
{
    if(
g_knife)
    {
        
engclient_cmd(id"weapon_knife")
        
set_user_gravity(id0.5)
    }
}

public 
start_rr_timer()
{
    
Timer--
    
    
//client_cmd(0, "stopsound")
    
client_cmd(0"spk ^"%s^""PRECACHE_SOUND)
    
    
set_dhudmessage(24000, -1.00.0800.00.01)
    
show_dhudmessage(0"auto restart in·: %d"Timer)

    if(
Timer 1)
    {
        
server_cmd("sv_restartround 1")
        
set_task(3.0"rr_end")
        
set_task(3.0"off_gravity")
        
g_knife false
    
}
}

public 
rr_end()
{
    
set_dhudmessage(random_num(0255), random_num(0255), random_num(0255), -1.00.7826.03.00.11.5false )
    
show_dhudmessage(0"good luck!")
}

public 
off_gravity(id
{
    
client_cmd(0"stopsound")
    new 
players[32], num
    get_players
(playersnum"c")
    for (new 
0;num;i++)
                   
set_user_gravity(players[i], 1.0



Flick3rR 07-01-2014 12:33

Re: mp3 play problems
 
As far as I know, client_cmd is blocked by the engine with the new updates. Also, it should be "mp3 play" instead of "spk"

Freezo Begin 07-01-2014 12:40

Re: mp3 play problems
 
Or, Simply use this

Code:
stock PlaySound(id, const sound[]) {     if (equal(sound[strlen(sound)-4], ".mp3"))         client_cmd(id, "mp3 play ^"%s^"", sound)     else         client_cmd(id, "spk ^"%s^"", sound) }

then you will have to do this

Code:
PlaySound(0,PRECACHE_SOUND)

pob18 07-01-2014 14:16

Re: mp3 play problems
 
still does not play

Flick3rR 07-01-2014 14:26

Re: mp3 play problems
 
1)I will have to repeat myself.
Quote:

Originally Posted by Flick3rR (Post 2160354)
As far as I know, client_cmd is blocked by the engine with the new updates.

If I'm wrong, let someone correct me.
2) Where is your sound?
3) I think that it should be in "sound/misc" folder (if it's .wav, I'm not sure)

pob18 07-01-2014 14:33

Re: mp3 play problems
 
Quote:

Originally Posted by Flick3rR (Post 2160424)
1)I will have to repeat myself.

If I'm wrong, let someone correct me.
2) Where is your sound?
3) I think that it should be in "sound/misc" folder (if it's .wav, I'm not sure)

I changed the code to Freezo ones, the sound are located at "sound/myfolder/sound.mp3"

Flick3rR 07-01-2014 14:34

Re: mp3 play problems
 
Post the code you have, because I've got confused... These directories are messing something.

pob18 07-01-2014 14:40

Re: mp3 play problems
 
PHP Code:

#include <amxmodx>
#include <amxmisc>
#include <dhudmessage>
#include <hamsandwich>
#include <fun>

#define PRECACHE_SOUND "myserver/music.mp3"



new TimerSecondsCvar
new bool:g_knife true

public plugin_init()
{
    
    
register_event("DeathMsg""on_death""a")
    
register_event"CurWeapon""EventCurWeapon""be""2!29" )
    
    
SecondsCvar register_cvar("auto_rr_time","50.0")

    
Timer get_pcvar_num(SecondsCvar)
    
set_task(1.0"start_rr_timer"___"a"Timer)
}


public 
plugin_precache()
    
precache_sound(PRECACHE_SOUND)


public 
on_death()
{
    new 
victim
    victim 
read_data(2)
    
    if(
g_knife)
        
set_task(1.0"fnRevivePlayer"victim)
}

public 
fnRevivePlayer(id
{
    if(!
is_user_alive(id)) 
        
ExecuteHamB(Ham_CS_RoundRespawnid)    
}

public 
EventCurWeapon(id)
{
    if(
g_knife)
    {
        
engclient_cmd(id"weapon_knife")
        
set_user_gravity(id0.5)
    }
}

public 
start_rr_timer()
{
    
Timer--
    
    
PlaySound(0,PRECACHE_SOUND)
    
    
set_dhudmessage(24000, -1.00.0800.00.01)
    
show_dhudmessage(0"time to rr: %d"Timer)

    if(
Timer 1)
    {
        
server_cmd("sv_restartround 1")
        
set_task(3.0"rr_end")
        
set_task(3.0"off_gravity")
        
g_knife false
    
}
}

public 
rr_end()
{
    
set_dhudmessage(random_num(0255), random_num(0255), random_num(0255), -1.00.7826.03.00.11.5false )
    
show_dhudmessage(0"good luck")
}

public 
off_gravity(id
{
    
client_cmd(0"stopsound")
    new 
players[32], num
    get_players
(playersnum"c")
    for (new 
0;num;i++)
                   
set_user_gravity(players[i], 1.0
}

stock PlaySound(id, const sound[])
{
    if (
equal(sound[strlen(sound)-4], ".mp3"))
        
client_cmd(id"mp3 play ^"%s^""sound)
    else
        
client_cmd(id"spk ^"%s^""sound)



Flick3rR 07-01-2014 14:49

Re: mp3 play problems
 
Try to change it with "misc/myserver/music.mp3".
And also:
Quote:

Originally Posted by Flick3rR (Post 2160354)
As far as I know, client_cmd is blocked by the engine with the new updates.


Freezo Begin 07-01-2014 14:54

Re: mp3 play problems
 
try this again .
Code:
stock PlaySound(id, const sound[]) {     if (equal(sound[strlen(sound)-4], ".mp3"))         client_cmd(id, "mp3 play ^"sound/%s^"", sound)     else         client_cmd(id, "spk ^"%s^"", sound) }


All times are GMT -4. The time now is 21:07.

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