[EDITED] Misc. Stats — disable/enable sounds for each Player

For scripting examples for learning how to use AMXX.
User avatar
Archive-Poster
Posts: 1367
Gender:
United States of America

[EDITED] Misc. Stats — disable/enable sounds for each Player

Post by Archive-Poster »

Hello. It's very simple, but userful mini tutorial.
Many players do not like distractions Misc. Stats sounds (like Headshot, Multi-Kill, One and only, etc.).
Let's be adding feature for disable this sounds personally for each Player.

miscstats.sma

86 string, after "new g_he_sync" add:

Code: Select all

new no_sounds[33]
180 string, after "register_event("StatusValue", "hideStatus", "be", "1=1", "2=0")" add:

Code: Select all

register_clcmd("say /no_sounds", "noSounds", 0, "- disable/enable Misc. Stats sounds (Headshot, Multi-Kill, etc.)") 
In empty place (like 204 string) add this function:

Code: Select all

public noSounds(id)
{
    if(no_sounds[id] == 1) {
        no_sounds[id] = 0
        client_cmd(id, "setinfo ^"no_sounds^" ^"^"")
        client_print(id, print_chat, "* Misc. Stats Sounds have been enabled (default)")
    } else {
        no_sounds[id] = 1
        client_cmd(id, "setinfo ^"no_sounds^" ^"1^"")
        client_print(id, print_chat, "* Misc. Stats Sounds have been disabled")
    }
} 
^ Here you can use Misc. Stats Language file for adding this two "print_chat" messages (better).

243 string, after "g_streakKills[id] = {0, 0}" add:

Code: Select all

new ns[2]
get_user_info(id, "no_sounds", ns, 1)
if (equali(ns, "1")) {
    no_sounds[id] = 1
} else {
    no_sounds[id] = 0
} 
Almost done. Add if/else checks for client_cmd() with "spk" commands.

428 string, from:

Code: Select all

client_cmd(g_LastAnnounce, "spk misc/oneandonly")
To:

Code: Select all

if (no_sounds[g_LastAnnounce] == 0) {
    client_cmd(g_LastAnnounce, "spk misc/oneandonly")
} 
495 string, from:

Code: Select all

client_cmd(killer, "spk misc/headshot")
client_cmd(victim, "spk misc/headshot") 
To:

Code: Select all

if (no_sounds[killer] == 0) {
    client_cmd(killer, "spk misc/headshot")
}
if (no_sounds[victim] == 0) {
    client_cmd(victim, "spk misc/headshot")
} 
776 string, from:

Code: Select all

client_cmd(players[i], "spk %s", sound)
To:

Code: Select all

if (no_sounds[players[i]] == 0) {
    client_cmd(players[i], "spk %s", sound)
} 
Done! Players can use "/no_sounds" switch say-command for disable/enable Misc. Stats sounds.
In attachment you can download edited "miscstats.sma" file (AMXX 1.8.2).
Attachments
miscstats.sma.zip
(5.53 KiB) Downloaded 7 times

Who is online

Users browsing this forum: No registered users and 1 guest