Raised This Month: $ Target: $400
 0% 

mp3 play problems


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
pob18
Member
Join Date: Jun 2014
Old 07-01-2014 , 14:40   Re: mp3 play problems
Reply With Quote #1

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)

pob18 is offline
pob18
Member
Join Date: Jun 2014
Old 07-01-2014 , 16:30   Re: mp3 play problems
Reply With Quote #2

Now the music is played, but wtf the music starts playing and stops and starts again playing every second
pob18 is offline
Flick3rR
Veteran Member
Join Date: Feb 2014
Location: Bulgaria, Stara Zagora
Old 07-01-2014 , 16:44   Re: mp3 play problems
Reply With Quote #3

Yes, that was the other thing I was about to say. It's because you send the command in each repeating of the task. Just call a function to play the sound before to set the task, and then set the task.
You should place the line where you call the song, somewhere else. It depends on what you want.
__________________

Last edited by Flick3rR; 07-01-2014 at 16:46.
Flick3rR is offline
Send a message via Skype™ to Flick3rR
Backstabnoob
BANNED
Join Date: Feb 2009
Location: Iwotadai Dorm
Old 07-01-2014 , 19:11   Re: mp3 play problems
Reply With Quote #4

^ That won't work because nobody is connected to the server on plugin_init yet. The command won't be set to anyone.

Just cache who you already used the command on in the task.

PHP Code:
public start_rr_timer()
{
    
Timer--

    static 
boolbListens33 ]

    new 
aPlayers32 ], iNumid
    get_players
aPlayersiNum )

    for( --
iNumiNum >= 0iNum-- )
    {
        
id aPlayersiNum ]
        if( !
bListensid ] )
        {
            
PlaySoundidPRECACHE_SOUND )
            
bListensid ] = true
        
}
    }

    
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 
    
}

Also, in rr_end, you probably want to use client_cmd(0, "mp3 stop").

Last edited by Backstabnoob; 07-01-2014 at 19:13.
Backstabnoob is offline
pob18
Member
Join Date: Jun 2014
Old 07-01-2014 , 20:50   Re: mp3 play problems
Reply With Quote #5

Quote:
Originally Posted by Backstabnoob View Post
^ That won't work because nobody is connected to the server on plugin_init yet. The command won't be set to anyone.

Just cache who you already used the command on in the task.

PHP Code:
public start_rr_timer()
{
    
Timer--

    static 
boolbListens33 ]

    new 
aPlayers32 ], iNumid
    get_players
aPlayersiNum )

    for( --
iNumiNum >= 0iNum-- )
    {
        
id aPlayersiNum ]
        if( !
bListensid ] )
        {
            
PlaySoundidPRECACHE_SOUND )
            
bListensid ] = true
        
}
    }

    
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 
    
}

Also, in rr_end, you probably want to use client_cmd(0, "mp3 stop").
Thanks for your help!
pob18 is offline
aron9forever
Veteran Member
Join Date: Feb 2013
Location: Rromania
Old 07-03-2014 , 11:54   Re: mp3 play problems
Reply With Quote #6

wait wasn't mp3 removed from precaching in the latest steam build?
meaning it would be considered an invalid file? they blocked precache_generic didn't they?
__________________
Meanwhile, in 2050:
Quote:
Originally Posted by aron9forever
useless small optimizations
Quote:
Originally Posted by Black Rose View Post
On a map that is 512x512x128 units you end up with 3,355,443,200,000 different "positions". To store each one of those positions individually in the variable "user_or" you need 12 terabytes of memory.
aron9forever is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 07-03-2014 , 12:01   Re: mp3 play problems
Reply With Quote #7

Quote:
Originally Posted by aron9forever View Post
wait wasn't mp3 removed from precaching in the latest steam build?
meaning it would be considered an invalid file? they blocked precache_generic didn't they?
They didn't, you still can precache few other file formats, but not as much as before. There should be a complete list somewhere on this forum, or just search google for it. .mp3 is one of the extensions that are allowed.
klippy is offline
pob18
Member
Join Date: Jun 2014
Old 07-08-2014 , 03:59   Re: mp3 play problems
Reply With Quote #8

Hey, if I enter to the server, but the rr started about 10 seconds ago, the music is played from the start for any player, how to change this?
pob18 is offline
Backstabnoob
BANNED
Join Date: Feb 2009
Location: Iwotadai Dorm
Old 07-08-2014 , 04:27   Re: mp3 play problems
Reply With Quote #9

You can't.
Backstabnoob is offline
pob18
Member
Join Date: Jun 2014
Old 07-08-2014 , 09:38   Re: mp3 play problems
Reply With Quote #10

So for every one the music plays when a player connects?
pob18 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 21:07.


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