Raised This Month: $51 Target: $400
 12% 

Message sound for all


Post New Thread Reply   
 
Thread Tools Display Modes
DJEarthQuake
Veteran Member
Join Date: Jan 2014
Location: Astral planes
Old 01-06-2024 , 09:32   Re: Message sound for all
Reply With Quote #11

Precache is required it if not a stock sound.
__________________
DJEarthQuake is offline
mlibre
Veteran Member
Join Date: Nov 2015
Location: return PLUGIN_CONTINUE
Old 01-06-2024 , 11:19   Re: Message sound for all
Reply With Quote #12

Quote:
Originally Posted by R.1 View Post
... I don't want the sound from the vox folder, only my own sound
try this

PHP Code:
new const sound_list[][] =
{
    
"sound/music_1.wav",
    
"sound/music_2.mp3",
    
"sound/other/music_3.wav",
    
"sound/music_4.wav"
}

public 
plugin_precache()
{
    for(new 
isizeof sound_listi++)
    {
        if(
file_exists(sound_list[i]))
        {
            
precache_generic(sound_list[i])
        }
        else
        {
            
log_amx("** could not be loaded ^"%s^""sound_list[i])
        }
    }
}

stock play_sound(id)
{
    new 
random_sound random_num(0charsmax(sound_list))
    
    
client_cmd(id id 0"%s ^"%s^""containi(sound_list[random_sound], ".wav") == strlen(sound_list[random_sound]) - "spk" "mp3 play"sound_list[random_sound])

calling play_sound here

Code:
public say_cmd(id) {     new szMsg[254]     read_args(szMsg, charsmax(szMsg))     remove_quotes(szMsg)     if(szMsg[0] != '/')         play_sound(0) }


  • play_sound(0) = everyone listens to it
  • play_sound(id) = only you listen to it
__________________
mlibre is offline
DJEarthQuake
Veteran Member
Join Date: Jan 2014
Location: Astral planes
Old 01-06-2024 , 12:21   Re: Message sound for all
Reply With Quote #13

@mlibre. Good move assuring file is there before precaching.

Code:
        if(SzMsg[0] != '/')         {             if(SzMsg[1] != '/')             {                 client_cmd 0, "spk %s", SzTalkSnd             }         }

2 cells needed checked when I tested this to handle both freehand typing and using binds.
__________________

Last edited by DJEarthQuake; 01-08-2024 at 16:02.
DJEarthQuake is offline
Jhob94
AMX Mod X Donor
Join Date: Jul 2012
Old 01-06-2024 , 12:53   Re: Message sound for all
Reply With Quote #14

Containi is a much more expensive operation than remove quotes plus checking the slot 0.
I’ve no idea why you are still insisting on something that is a simple request.

Plus using containi will check every slot so it will ignore messages that contain / on the middle of the msg which is not what is requested. Also it becomes more expensive on big chat messages.

And not to forget that you are using containi instead of contain which means you have no idea what the hell you are doing. Containi is for upper/lower case which / is not affected.
__________________
Jhob94 is offline
R.1
Member
Join Date: Jan 2014
Location: Poland
Old 01-06-2024 , 14:10   Re: Message sound for all
Reply With Quote #15

@Jhob94 so what should the whole code look like?
R.1 is offline
Jhob94
AMX Mod X Donor
Join Date: Jul 2012
Old 01-06-2024 , 14:21   Re: Message sound for all
Reply With Quote #16

Grab my code, edit name of sound to the sound you want to use.
After that make a function for public plugin_precache
Inside do precache_sound(“yoursound”)
I am at mobile phone right now, maybe you manage to do it yourself
__________________
Jhob94 is offline
WATCH_D0GS UNITED
Senior Member
Join Date: Jan 2023
Old 01-06-2024 , 17:37   Re: Message sound for all
Reply With Quote #17

Quote:
Originally Posted by Jhob94 View Post
Containi is a much more expensive operation than remove quotes plus checking the slot 0.
I’ve no idea why you are still insisting on something that is a simple request.

Plus using containi will check every slot so it will ignore messages that contain / on the middle of the msg which is not what is requested. Also it becomes more expensive on big chat messages.

And not to forget that you are using containi instead of contain which means you have no idea what the hell you are doing. Containi is for upper/lower case which / is not affected.
PHP Code:
/**
 * Tests whether a string is found inside another string with case ignoring.
 *
 * @note This supports multi-byte characters (UTF-8) on comparison.
 *
 * @param source        String to search in.
 * @param string        Substring to find inside the original string.
 *
 * @return                -1 on failure (no match found). Any other value
 *                        indicates a position in the string where the match starts.
 */
native containi(const source[], const string[]); 
https://www.amxmodx.org/api/string/containi
https://github.com/alliedmodders/amx...odx/string.cpp
__________________
💻Know Our New Blog👄
🔗tube2downs.blogspot.com
WATCH_D0GS UNITED is offline
Jhob94
AMX Mod X Donor
Join Date: Jul 2012
Old 01-06-2024 , 18:04   Re: Message sound for all
Reply With Quote #18

Quote:
Originally Posted by WATCH_D0GS UNITED View Post
PHP Code:
/**
 * Tests whether a string is found inside another string with case ignoring.
 *
 * @note This supports multi-byte characters (UTF-8) on comparison.
 *
 * @param source        String to search in.
 * @param string        Substring to find inside the original string.
 *
 * @return                -1 on failure (no match found). Any other value
 *                        indicates a position in the string where the match starts.
 */
native containi(const source[], const string[]); 
https://www.amxmodx.org/api/string/containi
https://github.com/alliedmodders/amx...odx/string.cpp
Are you confirming or arguing?
Containi is upper/lower case for contain. Like equali is for equal
__________________
Jhob94 is offline
mlibre
Veteran Member
Join Date: Nov 2015
Location: return PLUGIN_CONTINUE
Old 01-06-2024 , 18:25   Re: Message sound for all
Reply With Quote #19

Quote:
Originally Posted by Jhob94 View Post
Containi is a much more expensive operation
PHP Code:
client_cmd(id id 0"%s ^"%s^""containi(sound_list[random_sound], ".wav") == strlen(sound_list[random_sound]) - "spk" "mp3 play"sound_list[random_sound]) 


PHP Code:
client_cmd(id id 0"%s ^"%s^""sound_list[random_sound][strlen(sound_list[random_sound]) - 1] == 'v' "spk" "mp3 play"sound_list[random_sound]) 
__________________
mlibre is offline
R.1
Member
Join Date: Jan 2014
Location: Poland
Old 01-06-2024 , 18:46   Re: Message sound for all
Reply With Quote #20

Quote:
Originally Posted by Jhob94 View Post
Grab my code, edit name of sound to the sound you want to use.
After that make a function for public plugin_precache
Inside do precache_sound(“yoursound”)
I am at mobile phone right now, maybe you manage to do it yourself
I'm not a programmer, so I need specialist help please help me with this code when you have time.
R.1 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 06:32.


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