Raised This Month: $ Target: $400
 0% 

Play MP3 to victims teammates only


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Rirre
Veteran Member
Join Date: Nov 2006
Old 05-13-2010 , 05:40   Play MP3 to victims teammates only
Reply With Quote #1

Right now this play MP3 to the victim only upon death.
I would like this to play to the victim's teammates only.
How to do that?
EDIT: Would like dead people to not be executed by this command either.

PHP Code:
#include <amxmodx>

#define music 4

new mp3list[music][] = 
{
    
"file1.mp3",
    
"file2.mp3",
    
"file3.mp3",
    
"file4.mp3"
}

public 
plugin_init ()
{
    
register_plugin"Sound On Death""1.0""Biscuit" );
    
register_event"DeathMsg""Event_PlayerKilled""a" );
    
register_logevent("round_end_event"2"1=Round_End");
}

public 
round_end_event()
    
client_cmd(0,"mp3 stop")

public 
Event_PlayerKilled ()
{
    
//Get victim
    
new victim read_data(2)

    
//play random mp3 in mp3list to victim
    
new random_num(0,music-1)

    
client_cmd(victim,"mp3 play %s",mp3list[r])


Last edited by Rirre; 05-13-2010 at 07:29.
Rirre is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 05-13-2010 , 05:42   Re: Play MP3 to victims teammates only
Reply With Quote #2

Loop through all players or using get_players() then check the team.
__________________
Arkshine is offline
Rirre
Veteran Member
Join Date: Nov 2006
Old 05-13-2010 , 06:30   Re: Play MP3 to victims teammates only
Reply With Quote #3

I have no clue how that works.

EDIT:
Alright, currently got this:
PHP Code:
#include <amxmodx>
#include <cstrike>

#define music 4

new g_MaxPlayers;

new 
mp3list[music][] = 
{
    
"file1.mp3",
    
"file2.mp3",
    
"file3.mp3",
    
"file4.mp3"
}

public 
plugin_init ()
{
    
register_plugin"Sound On Death""1.0""Biscuit" );
    
register_event"DeathMsg""Event_PlayerKilled""a" );
    
register_logevent("round_end_event"2"1=Round_End");
    
g_MaxPlayers get_maxplayers();
}

public 
round_end_event()
    
client_cmd(0,"mp3 stop");

public 
Event_PlayerKilled (id)
{
new 
random_num(0,music-1);

    for (new 
Client 1Client <= g_MaxPlayersClient++)
    {
        if (!
is_user_connected(Client))
            continue;

        switch (
get_user_team(Client))
        {
            case 
1// Terrorist
            
{
                
client_cmd(id,"mp3 play %s",mp3list[r]);
            }
            case 
2// CT
            
{
                
client_cmd(id,"mp3 play %s",mp3list[r]);
            }
        }
    }

The problem with this one is if I kill a enemy, it play the song to me.
Supposed to be contrary.

Right now I have no idea how to fix this.
Appreciate help.

Last edited by Rirre; 05-13-2010 at 07:43.
Rirre is offline
Spunky
Senior Member
Join Date: May 2008
Location: Orlando, Fl.
Old 05-13-2010 , 09:19   Re: Play MP3 to victims teammates only
Reply With Quote #4

The number of players changes throughout the game, and plugin_init() is only called once. Call get_players() wherever you intend to use that information.
Spunky is offline
Send a message via AIM to Spunky
Rirre
Veteran Member
Join Date: Nov 2006
Old 05-14-2010 , 06:52   Re: Play MP3 to victims teammates only
Reply With Quote #5

Alright, requesting if this could be done by someone since I can't figure out any working method with this one.
Rirre is offline
Voi
Veteran Member
Join Date: Sep 2006
Location: Gdansk, Poland
Old 05-15-2010 , 12:59   Re: Play MP3 to victims teammates only
Reply With Quote #6

untested, but this should work like you want it:
Code:
#include <amxmodx>
#include <cstrike>

#define music 4

new g_MaxPlayers;

new mp3list[music][] = 
{
"file1.mp3",
"file2.mp3",
"file3.mp3",
"file4.mp3"
}

public plugin_init ()
{
register_plugin( "Sound On Death", "1.0", "Biscuit" );
register_event( "DeathMsg", "Event_PlayerKilled", "a" );
register_logevent("round_end_event", 2, "1=Round_End");
g_MaxPlayers = get_maxplayers();
}

public round_end_event()
client_cmd(0,"mp3 stop");

public Event_PlayerKilled (id)
{
    new r = random_num(0,music-1);
    new VictimTeam = get_user_team(id)
    for (new Client = 1; Client <= g_MaxPlayers; Client++)
    {
        if (!is_user_connected(Client))
            continue;
        
        if(is_user_alive(Client))
        {
            new ClientTeam = get_user_team(Client)
            switch(ClientTeam)
        {
            case 1: // Terrorist
            {
                if(Client != id && ClientTeam == VictimTeam)
                    client_cmd(id,"mp3 play %s",mp3list[r]);
            }
            case 2: // CT
            {
                if(Client != id && ClientTeam == VictimTeam)
                    client_cmd(id,"mp3 play %s",mp3list[r]);
            }
        }
        }
        
        
    }
}
edit:
i missed something, hold on
edit2:
*should* be ok now
__________________

Last edited by Voi; 05-15-2010 at 13:05.
Voi is offline
wrecked_
Veteran Member
Join Date: Jan 2010
Location: New York (GMT-5)
Old 05-15-2010 , 13:15   Re: Play MP3 to victims teammates only
Reply With Quote #7

Quote:
Originally Posted by Voi View Post
untested, but this should work like you want it:
<code>
No.

Code:
#include <amxmodx> #include <cstrike> new mp3list[][] = {     "file1.mp3",     "file2.mp3",     "file3.mp3",     "file4.mp3" } new bool:b_Allow[33] public plugin_init() {     register_plugin( "Sounds", "1.1", "Wrecked" )         register_logevent( "LogEventRoundEnd", 2, "1=Round_End" )     register_event( "DeathMsg", "EventDeathMsg", "a" )         register_clcmd( "say /allowmusic", "CmdSwitchAllow" )     register_clcmd( "say_team /allowmusic", "CmdSwitchAllow" ) } public client_connect( id ) {     b_Allow[id] = true } public CmdSwitchAllow( id ) {     b_Allow[id] = b_Allow[id] ? false : true         client_print( id, print_chat, "Death Sounds Enabled: %s", b_Allow[id] ? "Enabled" : "Disabled" )         return PLUGIN_HANDLED; } public LogEventRoundEnd() {     client_cmd( 0, "mp3 stop" ) } public EventDeathMsg() {     new victim = read_data( 2 )     new CsTeams:victeam = cs_get_user_team( victim )         new iPlayers[32]     new iNum         get_players( iPlayers, iNum )         new id         new rnum = random( sizeof mp3list )         for( new i = 0; i < iNum; i++ )     {         id = iPlayers[i]                 if( is_user_alive( id ) && ( id != victim ) && b_Allow[id] && ( victeam == cs_get_user_team( id ) ) )         {             client_cmd( id, "mp3 play %s", mp3list[rnum] )         }     } }

This one won't play the sound to the victim. You said you only wanted it to the victim's team. If you'd like it to play to the victim as well, just let me know.
__________________
[ Paid Requests ]
DO NOT PM ME ABOUT BLOCKMAKER
NO PRIVATE SUPPORT

Last edited by wrecked_; 05-15-2010 at 14:00.
wrecked_ is offline
Rirre
Veteran Member
Join Date: Nov 2006
Old 05-15-2010 , 13:20   Re: Play MP3 to victims teammates only
Reply With Quote #8

Forgot to ment that dead people should not hear any sound at all.
Rirre is offline
wrecked_
Veteran Member
Join Date: Jan 2010
Location: New York (GMT-5)
Old 05-15-2010 , 13:22   Re: Play MP3 to victims teammates only
Reply With Quote #9

Quote:
Originally Posted by Rirre View Post
Forgot to ment that dead people should not hear any sound at all.
Yep, that's there, too.
__________________
[ Paid Requests ]
DO NOT PM ME ABOUT BLOCKMAKER
NO PRIVATE SUPPORT
wrecked_ is offline
Rirre
Veteran Member
Join Date: Nov 2006
Old 05-15-2010 , 13:51   Re: Play MP3 to victims teammates only
Reply With Quote #10

Thx guys, wrecked_'s version works
EDIT: Could you make a cmd for user(s) to disable which don't want to hear them all the time?

Last edited by Rirre; 05-15-2010 at 13:56.
Rirre 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 03:49.


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