Raised This Month: $32 Target: $400
 8% 

How to play sound when the scoreboard shows?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
MihaiGamerXD
Member
Join Date: Aug 2018
Old 11-10-2018 , 07:42   How to play sound when the scoreboard shows?
Reply With Quote #1

Sorry for what I said, I was angry, but I swear I won't do anything bad, but I just need help for playing a sound when the scoreboard shows.

When the scoreboard shows, I need to play different sound like:

PHP Code:
if (ct_score t_score//The sound must play like "Yes!"
else if (ct_score t_score//The sound must play like "No!" 
I tried all of these variables, but it didn't work!
So please help me!
MihaiGamerXD is offline
Old 11-10-2018, 08:04
MihaiGamerXD
This message has been deleted by MihaiGamerXD. Reason: FINALLY FIXED!
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 11-10-2018 , 13:50   Re: How to play sound when the scoreboard shows?
Reply With Quote #2

I would think you could hook intermission and play your sound then.
__________________
fysiks is offline
MihaiGamerXD
Member
Join Date: Aug 2018
Old 11-18-2018 , 09:50   Re: How to play sound when the scoreboard shows?
Reply With Quote #3

Quote:
Originally Posted by fysiks View Post
I would think you could hook intermission and play your sound then.
All about on why didn't work is because of cs_get_user_vip, why?

because:

PHP Code:
public TheEnd(id) {
    if (
cs_get_user_team(id) == CS_TEAM_CT) {
        if (
cs_get_user_vip(id)) { //If you do it withou is_user_alive, it will not work
            
client_cmd("spk %s",vip)
        }
        else {
            
client_cmd("spk %s",yes)
        }
    }
    else if (
cs_get_user_team(id) == CS_TEAM_T) {
        
client_cmd("spk %s",no)
    }

And in that case I tried 2 thinks:

1:
PHP Code:
public TheEnd(id) {
    if (
cs_get_user_team(id) == CS_TEAM_CT) {
        if (
is_user_alive(id)) {
            if (
cs_get_user_vip(id)) {
                
client_cmd("spk %s",vip)
            }
            else {
                
client_cmd("spk %s",yes)
            }
        }
    }
    else if (
cs_get_user_team(id) == CS_TEAM_T) {
        
client_cmd("spk %s",no)
    }

2:
PHP Code:
static get[33]

public 
onSpawn(id) {
    if (
is_user_alive(id)) {
        if (
cs_get_user_vip(id)) {
            
get[id] = true
        
}
    }
}

public 
TheEnd(id) {
    if (
cs_get_user_team(id) == CS_TEAM_CT) {
        if (
vip[id]) {
            
client_cmd("spk %s",vip)
        }
        else {
            
client_cmd("spk %s",yes)
        }
    }
    else if (
cs_get_user_team(id) == CS_TEAM_T) {
        
client_cmd("spk %s",no)
    }

But nothing worked! Any ideas? You know I also registered the events!
MihaiGamerXD is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 11-18-2018 , 15:03   Re: How to play sound when the scoreboard shows?
Reply With Quote #4

If you are hooking intermission it is not a user-specific event, it is a global event and does not provide a player index. In any global event you need to use get_player() and loop through all the players to call functions for those players.

You should post your full code for us to be able to better understand what it is that you are doing.
__________________

Last edited by fysiks; 11-18-2018 at 15:04.
fysiks is offline
MihaiGamerXD
Member
Join Date: Aug 2018
Old 11-21-2018 , 12:14   Re: How to play sound when the scoreboard shows?
Reply With Quote #5

Full code is:
PHP Code:
include <amxmodex>
include <
amxmisc>
include <
cstrike>

new const 
yes[] = "yes.wav"
new const no[] = "no.wav"
new const protected[] = "protected.wav"

new ct_score 0
new t_score 0

public plugin_precache() {
    
precache_sound(yes)
    
precache_sound(no)
    
precache_sound(protected)
}

public 
plugin_init() {
    
register_plugin("Music","1.0","MihaiGamerXD")
    
register_logevent("Yes",6,"3=CTs_Win")
    
register_logevent("No",6,"3=Terrorists_Win")
    
register_logevent("No",6,"3=VIP_Assassinated")
    
register_logevent("No",6,"3=VIP_Not_Escaped")
    
register_logevent("Yes",6,"1=Escaped_As_VIP")
    
register_event("30","TheEnd","a")
}

public 
Yes() {
    
ct_score++
}

public 
No() {
    
t_score++
}

public 
TheEnd(id) { //Here's the problem and you're right
    
if (ct_score t_score) {
        if (
cs_get_user_vip(id)) {
            
client_cmd(id,"spk %s",protected)
        }
        else {
            
client_cmd(id,"spk %s",yes)
        }
    }
    else if(
ct_score t_score) {
        
client_cmd(id,"spk %s",no)
    }

And... please, show me an example for get_player().
MihaiGamerXD is offline
iceeedr
Veteran Member
Join Date: Apr 2017
Location: Brazil
Old 11-21-2018 , 13:22   Re: How to play sound when the scoreboard shows?
Reply With Quote #6

PHP Code:
public TheEnd() 
{
    new 
iPlayers[32], iNumid
    get_players
(iPlayersiNum"ch"// "ch" to exclude HLTV and bots
    
for(new 0iNumi++)
    {
        
id iPlayers [i]

        if (
ct_score t_score
        {
            if (
cs_get_user_vip(id)) 
                
client_cmd(id,"spk %s",protected)

            else 
                
client_cmd(id,"spk %s",yes)
        }
        else if(
ct_score t_score
            
client_cmd(id,"spk %s",no)
    }

Not tested, I wrote on mobile.
__________________


Quote:
Originally Posted by fysiks View Post
Please stop trying to help. You appear to just be posting random stuff. Wait until you actually understand more about AMX Mod X and how the game works.
https://iceeedr.com.br/

Last edited by iceeedr; 11-21-2018 at 13:28.
iceeedr is offline
Send a message via Skype™ to iceeedr
MihaiGamerXD
Member
Join Date: Aug 2018
Old 11-22-2018 , 12:55   Re: How to play sound when the scoreboard shows?
Reply With Quote #7

Quote:
Originally Posted by iceeedr View Post
PHP Code:
public theend() 
{
    new 
iplayers[32], inumid
    get_players
(iplayersinum"ch"// "ch" to exclude hltv and bots
    
for(new 0inumi++)
    {
        
id iplayers [i]

        if (
ct_score t_score
        {
            if (
cs_get_user_vip(id)) 
                
client_cmd(id,"spk %s",protected)

            else 
                
client_cmd(id,"spk %s",yes)
        }
        else if(
ct_score t_score
            
client_cmd(id,"spk %s",no)
    }

not tested, i wrote on mobile.
thank you! It worked! Now i'm ready to show you what have i done!
MihaiGamerXD is offline
Reply


Thread Tools
Display Modes

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 19:32.


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