Solved Inputting/Triggering Sounds While Selecting Palettes

Question that is answered or resolved.

maxman

Well-known member
I'm trying to include sounds while selecting remaps in the select screen, but no matter how many times I tried, any given sound plays randomly while toggling up/down directions. It's not playing one sound per selecting a remap. For instance, when I press up to the first alternate palette from the default palette, I want one sound to play everytime up/down is pressed. Also, I'm trying not to use script tags for this, but they do work at my disposal when things don't work out for me. However, for this one, it doesn't trigger the sound to play everytime it's toggled with up/down.

C:
anim waiting
@script
if(openborvariant("in_selectscreen")){
    void self = getlocalvar("self");
    int index = getentityproperty(self, "playerindex");
    int hold = getplayerproperty(index, "keys");
    int press = getplayerproperty(index, "newkeys");
    int map = getentityproperty(self, "map");

    void sfx01 = loadsample("data/sounds/heroes/terry/06_terry_00000.wav");
    void sfx02 = loadsample("data/sounds/heroes/terry/06_terry_00001.wav");
    void sfx03 = loadsample("data/sounds/heroes/terry/06_terry_00002.wav");
    void sfx04 = loadsample("data/sounds/heroes/terry/06_terry_00002.wav");

    if(getlocalvar("remapSFX") == NULL()){
        /*if(
        (press & openborconstant("FLAG_MOVEDOWN") )
        || (press & openborconstant("FLAG_MOVEUP") )
         )
        {
            playsample(sfx01, 0, 120, 120, 100, 0);
            setlocalvar("remapSFX", 1);
        }*/

        if(map == 0 && press & openborconstant("FLAG_MOVEUP") ){
            playsample(sfx01, 0, 120, 120, 100, 0);
            setlocalvar("remapSFX", 1);
        }

        if(map == 1 && press & openborconstant("FLAG_MOVEUP") ){
            playsample(sfx02, 0, 120, 120, 100, 0);
            setlocalvar("remapSFX", 1);
        }

        if(map == 2 && press & openborconstant("FLAG_MOVEUP") ){
            playsample(sfx03, 0, 120, 120, 100, 0);
            setlocalvar("remapSFX", 1);
        }
    }

    if(getlocalvar("remapSFX") != NULL()){
        setlocalvar("remapSFX", NULL());
    }
}
@end_script
    offset 140 188
    loop 1
    delay 10
    frame data/chars/heroes/KOF_2K3_Terry_Sprite.7z/0_0.png
    frame data/chars/heroes/KOF_2K3_Terry_Sprite.7z/0_1.png
    frame data/chars/heroes/KOF_2K3_Terry_Sprite.7z/0_2.png
    frame data/chars/heroes/KOF_2K3_Terry_Sprite.7z/0_3.png
    frame data/chars/heroes/KOF_2K3_Terry_Sprite.7z/0_4.png
    frame data/chars/heroes/KOF_2K3_Terry_Sprite.7z/0_5.png
    frame data/chars/heroes/KOF_2K3_Terry_Sprite.7z/0_6.png
    frame data/chars/heroes/KOF_2K3_Terry_Sprite.7z/0_7.png

I also tried keyscript with it, but no sound is playing at all.

How can I get a different sound to play when selecting each remap with up/down?
 
Last edited:
I'm trying to include sounds while selecting remaps in the select screen, but no matter how many times I tried, any given sound plays randomly while toggling up/down directions. It's not playing one sound per selecting a remap. For instance, when I press up to the first alternate palette from the default palette, I want one sound to play everytime up/down is pressed. Also, I'm trying not to use script tags for this, but they do work at my disposal when things don't work out for me. However, for this one, it doesn't trigger the sound to play everytime it's toggled with up/down.

C:
anim waiting
@script
if(openborvariant("in_selectscreen")){
    void self = getlocalvar("self");
    int index = getentityproperty(self, "playerindex");
    int hold = getplayerproperty(index, "keys");
    int press = getplayerproperty(index, "newkeys");
    int map = getentityproperty(self, "map");

    void sfx01 = loadsample("data/sounds/heroes/terry/06_terry_00000.wav");
    void sfx02 = loadsample("data/sounds/heroes/terry/06_terry_00001.wav");
    void sfx03 = loadsample("data/sounds/heroes/terry/06_terry_00002.wav");
    void sfx04 = loadsample("data/sounds/heroes/terry/06_terry_00002.wav");

    if(getlocalvar("remapSFX") == NULL()){
        /*if(
        (press & openborconstant("FLAG_MOVEDOWN") )
        || (press & openborconstant("FLAG_MOVEUP") )
         )
        {
            playsample(sfx01, 0, 120, 120, 100, 0);
            setlocalvar("remapSFX", 1);
        }*/

        if(map == 0 && press & openborconstant("FLAG_MOVEUP") ){
            playsample(sfx01, 0, 120, 120, 100, 0);
            setlocalvar("remapSFX", 1);
        }

        if(map == 1 && press & openborconstant("FLAG_MOVEUP") ){
            playsample(sfx02, 0, 120, 120, 100, 0);
            setlocalvar("remapSFX", 1);
        }

        if(map == 2 && press & openborconstant("FLAG_MOVEUP") ){
            playsample(sfx03, 0, 120, 120, 100, 0);
            setlocalvar("remapSFX", 1);
        }
    }

    if(getlocalvar("remapSFX") != NULL()){
        setlocalvar("remapSFX", NULL());
    }
}
@end_script
    offset 140 188
    loop 1
    delay 10
    frame data/chars/heroes/KOF_2K3_Terry_Sprite.7z/0_0.png
    frame data/chars/heroes/KOF_2K3_Terry_Sprite.7z/0_1.png
    frame data/chars/heroes/KOF_2K3_Terry_Sprite.7z/0_2.png
    frame data/chars/heroes/KOF_2K3_Terry_Sprite.7z/0_3.png
    frame data/chars/heroes/KOF_2K3_Terry_Sprite.7z/0_4.png
    frame data/chars/heroes/KOF_2K3_Terry_Sprite.7z/0_5.png
    frame data/chars/heroes/KOF_2K3_Terry_Sprite.7z/0_6.png
    frame data/chars/heroes/KOF_2K3_Terry_Sprite.7z/0_7.png

I also tried keyscript with it, but no sound is playing at all.

How can I get a different sound to play when selecting each remap with up/down?
I suggest to use keyall.c even to do this task. Here's an example of how to play a different sound based on the palette number.

Code:
void main(){

    if(openborvariant("in_selectscreen")){
        void sample;
        int player = getlocalvar("player");
        int map = getplayerproperty(player, "colourmap");
        int volume = openborvariant("effectvol");
        int speed = 100;
        int loop = 0;
        
        if(map == 0)
        {
            sample = loadsample("data/sounds/Beep.wav");
        }
        else
        if(map == 1)
        {
            sample = loadsample("data/sounds/Beep2.wav");
        }

        if(playerkeys(player, 1, "moveup") || playerkeys(player, 1, "movedown"))
        {
            playsample(sample, 0, volume, volume, speed, loop);
        }
    }
}

 
Thanks for the sample, Kratus. How do you specifically call a model name in keyall.c like that? I tried to use the player property of "model" for naming the player's name, but it crashed after I put the player's name in the conditions. So I started using the entity property for the player's name. I would like to have each character have their own sounds when selecting palettes.

Also, when I want to press up once starting from default palette to the 1st alternate palette just like the menu scripts, one different sound plays.

This is my attempt at making the sound play, but couldn't adjust some global keys for selecting certain palettes.
C:
void selectPal(){
    if(openborvariant("in_selectscreen")){
        void sample;
        int player = getlocalvar("player");
    int ent = getplayerproperty(player, "ent");
        int map = getplayerproperty(player, "colourmap");
        int volume = openborvariant("effectvol");
        int speed = 100;


    void name = getentityproperty(ent, "name");



        if(name == "Terry"){

        if(map == 0)
        {
            sample = loadsample("data/sounds/tel.wav");
        }
        else
        if(map == 1)
        {
            sample = loadsample("data/sounds/phone.wav");
        }
        else
        if(map == 2)
        {
            sample = loadsample("data/sounds/ralf.wav");
        }
        else
        if(map == 3)
        {
            sample = loadsample("data/sounds/beep2.wav");
        }

    }


    else if(name == "Clark"){

        if(map == 0)
        {
            sample = loadsample("data/sounds/geese1.wav");
        }
        else
        if(map == 1)
        {
            sample = loadsample("data/sounds/eiji.wav");
        }
        else
        if(map == 2)
        {
            sample = loadsample("data/sounds/gong.wav");
        }
        else
        if(map == 3)
        {
            sample = loadsample("data/sounds/1up.wav");
        }

    } else {

        if(map == 0)
        {
            sample = loadsample("data/sounds/Beep.wav");
        }
        else
        if(map == 1)
        {
            sample = loadsample("data/sounds/klunk.wav");
        }
        else
        if(map == 2)
        {
            sample = loadsample("data/sounds/money.wav");
        }
        else
        if(map == 3)
        {
            sample = loadsample("data/sounds/hanzo.wav");
        }

    }

        if(playerkeys(player, 1, "moveup") || playerkeys(player, 1, "movedown"))
        {
            playsample(sample, 0, volume, volume, speed, loop);
        }

    }
}
 
How do you specifically call a model name in keyall.c like that?
In global events, especially inside the select screen (where many engine routines are disabled), usually I call a model name using this line:

Code:
void name1 = getplayerproperty(0, "name"); //PLAYER 1 NAME
void name2 = getplayerproperty(1, "name"); //PLAYER 2 NAME
void name3 = getplayerproperty(2, "name"); //PLAYER 3 NAME
void name4 = getplayerproperty(3, "name"); //PLAYER 4 NAME

Also, when I want to press up once starting from default palette to the 1st alternate palette just like the menu scripts, one different sound plays.
Sorry buddy, I didn't understand this problem exactly. The script is clearly defining a sound on each key press, unless you have more palettes than the ones listed in the script.

This is my attempt at making the sound play, but couldn't adjust some global keys for selecting certain palettes.
What is not working exactly?
 
Sorry buddy, I didn't understand this problem exactly. The script is clearly defining a sound on each key press, unless you have more palettes than the ones listed in the script.
Sorry for being vague and not pointing out correctly in the beginning. What I mean is that when you press down to go to the last alternate palette (map 3), the first sound (beep.wav) that's used for the first/default palette (map 0) plays. When you press down again to the second to the last palette (map 2), the sound (1up.wav) from the last palette plays.

C:
void selectPal(){
    if(openborvariant("in_selectscreen")){
        void sample;
        int player = getlocalvar("player");
        int ent = getplayerproperty(player, "ent");
        int map = getplayerproperty(player, "colourmap");
        int volume = openborvariant("effectvol");
        int speed = 100;
        int loop = 0;
    //int min = 0;
    //int max = 3;
    //int add = 1;
    //int moveup = playerkeys(player, 1, "moveup");
    //int movedown = playerkeys(player, 1, "movedown");
    //int mapSelect = getglobalvar("mapSelect");

    void name = getentityproperty(ent, "name");


        if(map == 0)
        {
            sample = loadsample("data/sounds/Beep.wav");
        }
        else
        if(map == 1)
        {
            sample = loadsample("data/sounds/klunk.wav");
        }
        else
        if(map == 2)
        {
            sample = loadsample("data/sounds/money.wav");
        }
        else
        if(map == 3)
        {
            sample = loadsample("data/sounds/1up.wav");
        }


        if(playerkeys(player, 1, "moveup") || playerkeys(player, 1, "movedown"))
        {
            playsample(sample, 0, volume, volume, speed, loop);
        }

    }
}
What is not working exactly?
It was for toggling the down button on specific alternate and default palettes. I didn't bother assigning the playerkeys at first.

(A couple of hours later)
P.S. I just figured it out, thanks to your scripts. I started to assign playerkeys and added specific SFX to test. I gave the if-else conditions to specific character names with specifically given SFX along with up/down keys.

Here's what I have so far.

C:
void selectPal(){
    if(openborvariant("in_selectscreen")){
        void sample;
        int player = getlocalvar("player");
        int ent = getplayerproperty(player, "ent");
        int map = getplayerproperty(player, "colourmap");
        int volume = openborvariant("effectvol");
        int speed = 100;
        int loop = 0;

        int moveup = playerkeys(player, 1, "moveup");
        int movedown = playerkeys(player, 1, "movedown");

        void sfx01 = loadsample("data/sounds/Beep.wav");
        void sfx02 = loadsample("data/sounds/klunk.wav");
        void sfx03 = loadsample("data/sounds/money.wav");
        void sfx04 = loadsample("data/sounds/1up.wav");

        void sfx05 = loadsample("data/sounds/Beep2.wav");
        void sfx06 = loadsample("data/sounds/get.wav");
        void sfx07 = loadsample("data/sounds/slide.wav");
        void sfx08 = loadsample("data/sounds/phone.wav");

        void sfx09 = loadsample("data/sounds/exp.wav");
        void sfx10 = loadsample("data/sounds/gong.wav");
        void sfx11 = loadsample("data/sounds/fall.wav");
        void sfx12 = loadsample("data/sounds/tel.wav");

        void name1 = getplayerproperty(0, "name"); //PLAYER 1 NAME
        void name2 = getplayerproperty(1, "name"); //PLAYER 2 NAME
        void name3 = getplayerproperty(2, "name"); //PLAYER 3 NAME
        void name4 = getplayerproperty(3, "name"); //PLAYER 4 NAME

        if(name1 == "Terry" || name2 == "Terry" || name3 == "Terry" || name4 == "Terry" ){


            if(moveup){
                if(map == 0){
                    playsample(sfx01, 0, volume, volume, speed, loop); // Alternate palette 01
                }

                if(map == 1){
                    playsample(sfx02, 0, volume, volume, speed, loop); // Alternate palette 2
                }

                if(map == 2){
                    playsample(sfx03, 0, volume, volume, speed, loop); // Alt pal 3
                }

                if(map == 3){
                    playsample(sfx04, 0, volume, volume, speed, loop); // default
                }
            }

            if(movedown){
                if(map == 0){
                    playsample(sfx03, 0, volume, volume, speed, loop); // Last palette
                }

                if(map == 3){
                    playsample(sfx02, 0, volume, volume, speed, loop); // Second to last
                }

                if(map == 2){
                    playsample(sfx01, 0, volume, volume, speed, loop); // Alt 1
                }

                if(map == 1){
                    playsample(sfx04, 0, volume, volume, speed, loop); // Default
                }
            }

        }

        else if(name1 == "Clark" || name2 == "Clark" || name3 == "Clark" || name4 == "Clark" ){

            if(moveup){
                if(map == 0){
                    playsample(sfx09, 0, volume, volume, speed, loop); // Alternate palette 01
                }

                if(map == 1){
                    playsample(sfx10, 0, volume, volume, speed, loop); // Alternate palette 2
                }

                if(map == 2){
                    playsample(sfx11, 0, volume, volume, speed, loop); // Alt pal 3
                }

                if(map == 3){
                    playsample(sfx12, 0, volume, volume, speed, loop); // default
                }
            }

            if(movedown){
                if(map == 0){
                    playsample(sfx11, 0, volume, volume, speed, loop); // Last palette
                }

                if(map == 3){
                    playsample(sfx10, 0, volume, volume, speed, loop); // Second to last
                }

                if(map == 2){
                    playsample(sfx09, 0, volume, volume, speed, loop); // Alt 1
                }

                if(map == 1){
                    playsample(sfx12, 0, volume, volume, speed, loop); // Default
                }
            }

        }


        else {

            if(moveup){
                if(map == 0){
                    playsample(sfx05, 0, volume, volume, speed, loop); // Alternate palette 01
                }

                if(map == 1){
                    playsample(sfx06, 0, volume, volume, speed, loop); // Alternate palette 2
                }

                if(map == 2){
                    playsample(sfx07, 0, volume, volume, speed, loop); // Alt pal 3
                }

                if(map == 3){
                    playsample(sfx08, 0, volume, volume, speed, loop); // default
                }
            }

            if(movedown){
                if(map == 0){
                    playsample(sfx07, 0, volume, volume, speed, loop); // Last palette
                }

                if(map == 3){
                    playsample(sfx06, 0, volume, volume, speed, loop); // Second to last
                }

                if(map == 2){
                    playsample(sfx05, 0, volume, volume, speed, loop); // Alt 1
                }

                if(map == 1){
                    playsample(sfx08, 0, volume, volume, speed, loop); // Default
                }
            }

        }
   
    }
}

 
Last edited:
(A couple of hours later)
P.S. I just figured it out, thanks to your scripts. I started to assign playerkeys and added specific SFX to test. I gave the if-else conditions to specific character names with specifically given SFX along with up/down keys.
Is it working fine now? I didn't test but I think the problem with the sound order may be due to the keyall.c working after the inputs are processed by the engine.
I suggest making some tests using the inputall.c, which works before the engine process inputs, this way the sample will be defined before the key press detection and not after. However, it's only present in the engine v4.
 
Is it working fine now?
With assigning the variables of SFX, keys, and player names with if-else conditions, I think so.

I didn't test but I think the problem with the sound order may be due to the keyall.c working after the inputs are processed by the engine.
I do not know what the real problem is with that. However, it was just a test for leaving the sound effects for other characters without their names declared. I'm only going to specify names for given SFX. The ones I left with only two palettes were just tests (but I forgot to leave them as only two SFX; Oops). I'll change them with given SFX per palette available. I do seem to like it unless you suggest me what's better to improve.

I suggest making some tests using the inputall.c, which works before the engine process inputs, this way the sample will be defined before the key press detection and not after. However, it's only present in the engine v4.
I'm still using v3 for this, but do you know what feature works like inputall.c in v3 other than keyall.c? If not, what do you think can work for v3?
 
Last edited:
do you know what feature works like inputall.c in v3 other than keyall.c? If not, what do you think can work for v3?
For v3 you can use the update.c (not the updated.c), this way you can capture inputs before they are processed by the engine (same as I'm doing with the custom pause menu).
 
For v3 you can use the update.c (not the updated.c), this way you can capture inputs before they are processed by the engine (same as I'm doing with the custom pause menu).
I changed my modifications and transferred it to update.c. I think this is better with update.c.

My current input of update.c.
C:
void selectPal(){
    if(openborvariant("in_selectscreen")){ // START WITH SELECT SCREEN
        int player = getlocalvar("player");
        int map = getplayerproperty(player, "colourmap");
        int volume = openborvariant("effectvol");
        int speed = 100;
        int loop = 0;

        int moveup = playerkeys(player, 1, "moveup");
        int movedown = playerkeys(player, 1, "movedown");

        void sfx01 = loadsample("data/sounds/Beep.wav");
        void sfx02 = loadsample("data/sounds/klunk.wav");
        void sfx03 = loadsample("data/sounds/money.wav");
        void sfx04 = loadsample("data/sounds/1up.wav");

        void sfx05 = loadsample("data/sounds/Beep2.wav");
        void sfx06 = loadsample("data/sounds/get.wav");
        void sfx07 = loadsample("data/sounds/slide.wav");
        void sfx08 = loadsample("data/sounds/phone.wav");

        void sfx09 = loadsample("data/sounds/exp.wav");
        void sfx10 = loadsample("data/sounds/gong.wav");
        void sfx11 = loadsample("data/sounds/fall.wav");
        void sfx12 = loadsample("data/sounds/tel.wav");

        void name1 = getplayerproperty(0, "name"); //PLAYER 1 NAME
        void name2 = getplayerproperty(1, "name"); //PLAYER 2 NAME
        void name3 = getplayerproperty(2, "name"); //PLAYER 3 NAME
        void name4 = getplayerproperty(3, "name"); //PLAYER 4 NAME


        if(name1 == "Terry" || name2 == "Terry" || name3 == "Terry" || name4 == "Terry" ){


            if(moveup){
                if(map == 0){
                    playsample(sfx01, 0, volume, volume, speed, loop); // Alternate palette 01
                }

                if(map == 1){
                    playsample(sfx02, 0, volume, volume, speed, loop); // Alternate palette 2
                }

                if(map == 2){
                    playsample(sfx03, 0, volume, volume, speed, loop); // Alt pal 3
                }

                if(map == 3){
                    playsample(sfx04, 0, volume, volume, speed, loop); // default
                }
            }

            if(movedown){
                if(map == 0){
                    playsample(sfx03, 0, volume, volume, speed, loop); // Last palette
                }

                if(map == 3){
                    playsample(sfx02, 0, volume, volume, speed, loop); // Second to last
                }

                if(map == 2){
                    playsample(sfx01, 0, volume, volume, speed, loop); // Alt 1
                }

                if(map == 1){
                    playsample(sfx04, 0, volume, volume, speed, loop); // Default
                }
            }

        }


        else if(name1 == "Clark" || name2 == "Clark" || name3 == "Clark" || name4 == "Clark" ){


            if(moveup){
                if(map == 0){
                    playsample(sfx09, 0, volume, volume, speed, loop); // Alternate palette 01
                }

                if(map == 1){
                    playsample(sfx10, 0, volume, volume, speed, loop); // Alternate palette 2
                }

                if(map == 2){
                    playsample(sfx11, 0, volume, volume, speed, loop); // Alt pal 3
                }

                if(map == 3){
                    playsample(sfx12, 0, volume, volume, speed, loop); // default
                }
            }

            if(movedown){
                if(map == 0){
                    playsample(sfx11, 0, volume, volume, speed, loop); // Last palette
                }

                if(map == 3){
                    playsample(sfx10, 0, volume, volume, speed, loop); // Second to last
                }

                if(map == 2){
                    playsample(sfx09, 0, volume, volume, speed, loop); // Alt 1
                }

                if(map == 1){
                    playsample(sfx12, 0, volume, volume, speed, loop); // Default
                }
            }

        }


        else {

            if(moveup || movedown){
                if(map == 0){
                    playsample(sfx05, 0, volume, volume, speed, loop);
                }

                if(map == 1){
                    playsample(sfx06, 0, volume, volume, speed, loop);
                }
            }

        }
   
    }
}

Thank you very much, Kratus. I think this problem is solved.
 
Last edited:
@Kratus When I select a character, the character plays anim select, but when I press up/down, I hear my input sounds every time I press them. How can I disable the sound(s) to be silent or have no sound from being heard during anim select?
 
Glad the problem is solved :)
It's possible to adapt the code to not care about which character is selected and just play the sound whenever we press up or down in the select screen, right?
btw, this is something we could add in the engine itself - a new "beepx,wav", which would be played when you press up or down to select the palette.

Edit: here, I've adapted the code to work as I said before:

C-like:
void selectPal(){
        int player = getlocalvar("player");
        int map = getplayerproperty(player, "colourmap");
        int volume = openborvariant("effectvol");
        int speed = 100;
        int loop = 0;

        int moveup = playerkeys(player, 1, "moveup");
        int movedown = playerkeys(player, 1, "movedown");

        void sfx01 = loadsample("data/sounds/beep4.wav");
        
        if(moveup || movedown){
            playsample(sfx01, 0, volume, volume, speed, loop);
        } 
}

And just call it inside the IN_SELECT loop:

C-like:
if(openborvariant("in_selectscreen"))
    {   
        selectPal();
}
 
Last edited:
btw, this is something we could add in the engine itself - a new "beepx,wav", which would be played when you press up or down to select the palette.
Yeah, certainly it's a good idea. To be honest I even made it in my custom 7123 build (the old one used by the SOR2X), but I removed it during the v4 transition.
I will add to the engine update list, thanks buddy.

@Kratus When I select a character, the character plays anim select, but when I press up/down, I hear my input sounds every time I press them. How can I disable the sound(s) to be silent or have no sound from being heard during anim select?
You must set a variable as a flag at the first or second frame of the selected animation in order to tell the engine that the sound can't be played anymore.

However, due to many engine events disabled during the select screen, the playerindex detection may not work, so this solution will work for 1 player only.
To fix that you can alternatively use the playerkeys() event by detecting the "anybutton" press and then getting the index, like this (you can also use localvars, choose the one that fits better):

Code:
if(playerkeys(0, 1, "anybutton"))
{
    setglobalvar("noSoundP1", 1);
}

if(playerkeys(1, 1, "anybutton"))
{
    setglobalvar("noSoundP2", 1);
}

So, you can detect if these variables are NULL() or not, then allowing or not the sounds to be played for each player separately.
 
Last edited:
I have another problem this time. When I toggle up/down on other players, it doesn't work. Only player 1 does work. I tried using key#.c for players 2 and 3 so far, but there's no sound every time it's executed unlike player 1. How do you activate sound samples for other player indexes that don't work?

EDIT:
Nevermind. I just figured that I had to use player index numbers in order to work. Before I changed from this...

C:
        int P1 = getplayerproperty(0, "entity");
        int map = getplayerproperty(P1, "colourmap");
        int volume = openborvariant("effectvol");
        int speed = 100;
        int loop = 0;

        int moveup = playerkeys(P1, 1, "moveup");
        int movedown = playerkeys(P1, 1, "movedown");

        void name = getplayerproperty(P1, "name");

to this...

C:
        //int P1 = getplayerproperty(0, "entity");
        int map = getplayerproperty(0, "colourmap");
        int volume = openborvariant("effectvol");
        int speed = 100;
        int loop = 0;

        int moveup = playerkeys(0, 1, "moveup");
        int movedown = playerkeys(0, 1, "movedown");

        void name = getplayerproperty(0, "name");

After I applied the same to other player indexed with player index numbers and they really do work wonders/like a charm.

I don't need to call "entity" of the player property for this select screen, but only when I need to call it for certain actions in stages (or anything). (I won't need it unless I use specific entity properties.)

EDIT 2:
Now the only problem left right now is trying to disable up/down toggle sounds after selecting characters.
 
Last edited:
I tried doing this, but I'm totally lost on how to stop the sounds from playing. I can still hear them every time I press up/down. I don't know what variable flags I can use to stop this.

Code:
anim select
@script
if(frame == 0){
    if(playerkeys(0, 1, "moveup") || playerkeys(0, 1, "movedown"))
    {
        //setglobalvar("noSoundP1", 1);
        //setlocalvar("noSoundP1", 1);
    
        if(getlocalvar("noSoundP1") == NULL()){
            playsample("data/sounds/beep2.wav", 0, 0, 0, 100, 0);
            setlocalvar("noSoundP1", 1);
        }
    }

    if(playerkeys(1, 1, "anybutton"))
    {
        //setglobalvar("noSoundP2", 1);
        setlocalvar("noSoundP2", 1);
    }

    if(playerkeys(2, 1, "anybutton"))
    {
        //setglobalvar("noSoundP3", 1);
        setlocalvar("noSoundP3", 1);
    }
    
    
    
    if(getlocalvar("noSoundP1") != NULL()){
        setlocalvar("noSoundP1", NULL());
    }
}
@end_script
    offset 1 1
    delay 10
    frame data/chars/misc/empty.gif
    frame data/chars/misc/empty.gif
    frame data/chars/misc/empty.gif
    frame data/chars/misc/empty.gif
    frame data/chars/misc/empty.gif
    frame data/chars/misc/empty.gif
    frame data/chars/misc/empty.gif
    frame data/chars/misc/empty.gif
    frame data/chars/misc/empty.gif
    frame data/chars/misc/empty.gif
    frame data/chars/misc/empty.gif
    frame data/chars/misc/empty.gif
    frame data/chars/misc/empty.gif
    frame data/chars/misc/empty.gif

I'm having so much trouble of disabling the sound with up/down.
 
I'm having so much trouble of disabling the sound with up/down.
Please, try this script in your update.c, I tried to not change your structure too much.
I think that inline scripts may not help too much because you can't get the playerindex during the select screen, you need playerkeys() instead.

Code:
void main()
{
    selectPal(0);
    selectPal(1);
}

void selectPal(int player){
    if(openborvariant("in_selectscreen")){
        void name = getplayerproperty(player, "name");

        //CHECK IF THE PLAYER IS ACTIVE AND IF THE "NO SOUND" FLAG IS NOT SET
        if(name && getlocalvar("noSoundP"+player) == NULL()){

            int map = getplayerproperty(player, "colourmap");
            int volume = openborvariant("effectvol");
            int speed = 100;
            int loop = 0;
            
            int moveup = playerkeys(player, 1, "moveup");
            int movedown = playerkeys(player, 1, "movedown");
            int anybutton = playerkeys(player, 1, "anybutton");

            void sfx01 = loadsample("data/sounds/Beep.wav");
            void sfx02 = loadsample("data/sounds/klunk.wav");
            void sfx03 = loadsample("data/sounds/money.wav");
            void sfx04 = loadsample("data/sounds/1up.wav");

            void sfx05 = loadsample("data/sounds/Beep2.wav");
            void sfx06 = loadsample("data/sounds/get.wav");
            void sfx07 = loadsample("data/sounds/slide.wav");
            void sfx08 = loadsample("data/sounds/phone.wav");

            void sfx09 = loadsample("data/sounds/exp.wav");
            void sfx10 = loadsample("data/sounds/gong.wav");
            void sfx11 = loadsample("data/sounds/fall.wav");
            void sfx12 = loadsample("data/sounds/tel.wav");

            void sample;

            if(name == "Terry"){

                if(moveup){
                    if(map == 0){sample = sfx01;} // Alternate palette 01
                    if(map == 1){sample = sfx02;} // Alternate palette 02
                    if(map == 2){sample = sfx03;} // Alt pal 3
                    if(map == 3){sample = sfx04;} // default
                    playsample(sample, 0, volume, volume, speed, loop);
                }

                if(movedown){
                    if(map == 0){sample = sfx03;} // Last palette
                    if(map == 3){sample = sfx02;} // Second to last
                    if(map == 2){sample = sfx01;} // Alt 1
                    if(map == 1){sample = sfx04;} // Default
                    playsample(sample, 0, volume, volume, speed, loop);
                }
            }


            else if(name == "Clark" ){

                if(moveup){
                    if(map == 0){sample = sfx09;} // Alternate palette 01
                    if(map == 1){sample = sfx10;} // Alternate palette 02
                    if(map == 2){sample = sfx11;} // Alt pal 3
                    if(map == 3){sample = sfx12;} // default
                    playsample(sample, 0, volume, volume, speed, loop);
                }

                if(movedown){
                    if(map == 0){sample = sfx11;} // Last palette
                    if(map == 3){sample = sfx10;} // Second to last
                    if(map == 2){sample = sfx09;} // Alt 1
                    if(map == 1){sample = sfx12;} // Default
                    playsample(sample, 0, volume, volume, speed, loop);
                }
            }

            else {

                if(moveup || movedown){
                    if(map == 0){sample = sfx05;} // Alternate palette 01
                    if(map == 1){sample = sfx06;} // Alternate palette 02
                    playsample(sample, 0, volume, volume, speed, loop);
                }

                //SET "NO SOUND" FLAG IF THE CHARACTER IS CONFIRMED
                if(anybutton){
                    setlocalvar("noSoundP"+player, 1);
                }
            }
        }
    }
    else
    {
        //CLEAR "NO SOUND" FLAG FOR PLAYER 1 IF NOT IN THE SELECT SCREEN
        if(getlocalvar("noSoundP0") != NULL())
        {
            setlocalvar("noSoundP0", NULL());
        }

        //CLEAR "NO SOUND" FLAG FOR PLAYER 2 IF NOT IN THE SELECT SCREEN
        if(getlocalvar("noSoundP1") != NULL())
        {
            setlocalvar("noSoundP1", NULL());
        }
    }
}
 
Please, try this script in your update.c, I tried to not change your structure too much.
I think that inline scripts may not help too much because you can't get the playerindex during the select screen, you need playerkeys() instead.

Code:
void main()
{
    selectPal(0);
    selectPal(1);
}

void selectPal(int player){
    if(openborvariant("in_selectscreen")){
        void name = getplayerproperty(player, "name");

        //CHECK IF THE PLAYER IS ACTIVE AND IF THE "NO SOUND" FLAG IS NOT SET
        if(name && getlocalvar("noSoundP"+player) == NULL()){

            int map = getplayerproperty(player, "colourmap");
            int volume = openborvariant("effectvol");
            int speed = 100;
            int loop = 0;
           
            int moveup = playerkeys(player, 1, "moveup");
            int movedown = playerkeys(player, 1, "movedown");
            int anybutton = playerkeys(player, 1, "anybutton");

            void sfx01 = loadsample("data/sounds/Beep.wav");
            void sfx02 = loadsample("data/sounds/klunk.wav");
            void sfx03 = loadsample("data/sounds/money.wav");
            void sfx04 = loadsample("data/sounds/1up.wav");

            void sfx05 = loadsample("data/sounds/Beep2.wav");
            void sfx06 = loadsample("data/sounds/get.wav");
            void sfx07 = loadsample("data/sounds/slide.wav");
            void sfx08 = loadsample("data/sounds/phone.wav");

            void sfx09 = loadsample("data/sounds/exp.wav");
            void sfx10 = loadsample("data/sounds/gong.wav");
            void sfx11 = loadsample("data/sounds/fall.wav");
            void sfx12 = loadsample("data/sounds/tel.wav");

            void sample;

            if(name == "Terry"){

                if(moveup){
                    if(map == 0){sample = sfx01;} // Alternate palette 01
                    if(map == 1){sample = sfx02;} // Alternate palette 02
                    if(map == 2){sample = sfx03;} // Alt pal 3
                    if(map == 3){sample = sfx04;} // default
                    playsample(sample, 0, volume, volume, speed, loop);
                }

                if(movedown){
                    if(map == 0){sample = sfx03;} // Last palette
                    if(map == 3){sample = sfx02;} // Second to last
                    if(map == 2){sample = sfx01;} // Alt 1
                    if(map == 1){sample = sfx04;} // Default
                    playsample(sample, 0, volume, volume, speed, loop);
                }
            }


            else if(name == "Clark" ){

                if(moveup){
                    if(map == 0){sample = sfx09;} // Alternate palette 01
                    if(map == 1){sample = sfx10;} // Alternate palette 02
                    if(map == 2){sample = sfx11;} // Alt pal 3
                    if(map == 3){sample = sfx12;} // default
                    playsample(sample, 0, volume, volume, speed, loop);
                }

                if(movedown){
                    if(map == 0){sample = sfx11;} // Last palette
                    if(map == 3){sample = sfx10;} // Second to last
                    if(map == 2){sample = sfx09;} // Alt 1
                    if(map == 1){sample = sfx12;} // Default
                    playsample(sample, 0, volume, volume, speed, loop);
                }
            }

            else {

                if(moveup || movedown){
                    if(map == 0){sample = sfx05;} // Alternate palette 01
                    if(map == 1){sample = sfx06;} // Alternate palette 02
                    playsample(sample, 0, volume, volume, speed, loop);
                }

                //SET "NO SOUND" FLAG IF THE CHARACTER IS CONFIRMED
                if(anybutton){
                    setlocalvar("noSoundP"+player, 1);
                }
            }
        }
    }
    else
    {
        //CLEAR "NO SOUND" FLAG FOR PLAYER 1 IF NOT IN THE SELECT SCREEN
        if(getlocalvar("noSoundP0") != NULL())
        {
            setlocalvar("noSoundP0", NULL());
        }

        //CLEAR "NO SOUND" FLAG FOR PLAYER 2 IF NOT IN THE SELECT SCREEN
        if(getlocalvar("noSoundP1") != NULL())
        {
            setlocalvar("noSoundP1", NULL());
        }
    }
}

Thank you very much, Kratus. It works when I add the "noSound" flag in specific character names too. :) Plus, I added the clearing flags for both player 3 and player 4. I will be changing this script on the palette toggle sounds later, but for now, this is working really great! (y)(y) Much appreciated, man. ;)

C:
void selectPal(int player){
    if(openborvariant("in_selectscreen")){
        void name = getplayerproperty(player, "name");

        //CHECK IF THE PLAYER IS ACTIVE AND IF THE "NO SOUND" FLAG IS NOT SET
        if(name && getlocalvar("noSoundP"+player) == NULL()){

            int map = getplayerproperty(player, "colourmap");
            int volume = openborvariant("effectvol");
            int speed = 100;
            int loop = 0;
            
            int moveup = playerkeys(player, 1, "moveup");
            int movedown = playerkeys(player, 1, "movedown");
            int anybutton = playerkeys(player, 1, "anybutton");

            void sfx01 = loadsample("data/sounds/Beep.wav");
            void sfx02 = loadsample("data/sounds/klunk.wav");
            void sfx03 = loadsample("data/sounds/money.wav");
            void sfx04 = loadsample("data/sounds/1up.wav");

            void sfx05 = loadsample("data/sounds/Beep2.wav");
            void sfx06 = loadsample("data/sounds/get.wav");
            void sfx07 = loadsample("data/sounds/slide.wav");
            void sfx08 = loadsample("data/sounds/phone.wav");

            void sfx09 = loadsample("data/sounds/exp.wav");
            void sfx10 = loadsample("data/sounds/gong.wav");
            void sfx11 = loadsample("data/sounds/fall.wav");
            void sfx12 = loadsample("data/sounds/tel.wav");

            void sample;

            if(name == "Terry"){

                if(moveup){
                    if(map == 0){sample = sfx01;} // Alternate palette 01
                    if(map == 1){sample = sfx02;} // Alternate palette 02
                    if(map == 2){sample = sfx03;} // Alt pal 3
                    if(map == 3){sample = sfx04;} // default
                    playsample(sample, 0, volume, volume, speed, loop);
                }

                if(movedown){
                    if(map == 0){sample = sfx03;} // Last palette
                    if(map == 3){sample = sfx02;} // Second to last
                    if(map == 2){sample = sfx01;} // Alt 1
                    if(map == 1){sample = sfx04;} // Default
                    playsample(sample, 0, volume, volume, speed, loop);
                }

                if(anybutton){
                    setlocalvar("noSoundP"+player, 1);
                }

            }


            else if(name == "Clark" ){

                if(moveup){
                    if(map == 0){sample = sfx09;} // Alternate palette 01
                    if(map == 1){sample = sfx10;} // Alternate palette 02
                    if(map == 2){sample = sfx11;} // Alt pal 3
                    if(map == 3){sample = sfx12;} // default
                    playsample(sample, 0, volume, volume, speed, loop);
                }

                if(movedown){
                    if(map == 0){sample = sfx11;} // Last palette
                    if(map == 3){sample = sfx10;} // Second to last
                    if(map == 2){sample = sfx09;} // Alt 1
                    if(map == 1){sample = sfx12;} // Default
                    playsample(sample, 0, volume, volume, speed, loop);
                }


                if(anybutton){
                    setlocalvar("noSoundP"+player, 1);
                }
            }

            else {

                if(moveup || movedown){
                    if(map == 0){sample = sfx05;} // Alternate palette 01
                    if(map == 1){sample = sfx06;} // Alternate palette 02
                    playsample(sample, 0, volume, volume, speed, loop);
                }

                //SET "NO SOUND" FLAG IF THE CHARACTER IS CONFIRMED
                if(anybutton){
                    setlocalvar("noSoundP"+player, 1);
                }
            }
        }
    }
    else
    {
        //CLEAR "NO SOUND" FLAG FOR PLAYER 1 IF NOT IN THE SELECT SCREEN
        if(getlocalvar("noSoundP0") != NULL())
        {
            setlocalvar("noSoundP0", NULL());
        }

        //CLEAR "NO SOUND" FLAG FOR PLAYER 2 IF NOT IN THE SELECT SCREEN
        if(getlocalvar("noSoundP1") != NULL())
        {
            setlocalvar("noSoundP1", NULL());
        }

        //CLEAR "NO SOUND" FLAG FOR PLAYER 3 IF NOT IN THE SELECT SCREEN
        if(getlocalvar("noSoundP2") != NULL())
        {
            setlocalvar("noSoundP2", NULL());
        }

        //CLEAR "NO SOUND" FLAG FOR PLAYER 4 IF NOT IN THE SELECT SCREEN
        if(getlocalvar("noSoundP3") != NULL())
        {
            setlocalvar("noSoundP3", NULL());
        }
    }
}
 
Btw, I noticed that if you press up or down after selected the charcter, the sound will keep playing.
Is there a way to block this?
I didn't test my previous code but now I see the problem.
I fixed the no sound flag in this one, similar to @maxman fix but without the name management in case you don't need it.

Code:
void main()
{
    selectPal(0);
    selectPal(1);
    selectPal(2);
    selectPal(3);
}

void selectPal(int player){
    if(openborvariant("in_selectscreen")){
        void name = getplayerproperty(player, "name");

        //CHECK IF THE PLAYER IS ACTIVE AND IF THE "NO SOUND" FLAG IS NOT SET
        if(name && getlocalvar("noSoundP"+player) == NULL()){

            int map = getplayerproperty(player, "colourmap");
            int volume = openborvariant("effectvol");
            int speed = 100;
            int loop = 0;
            int moveup = playerkeys(player, 1, "moveup");
            int movedown = playerkeys(player, 1, "movedown");
            int anybutton = playerkeys(player, 1, "anybutton");
            void sfx01 = loadsample("data/sounds/Beep1wav.wav");
            void sfx02 = loadsample("data/sounds/Beep2wav.wav");
            void sample;

            if(moveup || movedown){
                if(map == 0){sample = sfx01;}
                if(map == 1){sample = sfx02;}
                playsample(sample, 0, volume, volume, speed, loop);
            }

            //SET "NO SOUND" FLAG IF THE CHARACTER IS CONFIRMED
            if(anybutton){
                setlocalvar("noSoundP"+player, 1);
            }
        }
    }
    else
    {
        //CLEAR "NO SOUND" FLAG FOR PLAYER 1 IF NOT IN THE SELECT SCREEN
        if(getlocalvar("noSoundP0") != NULL())
        {
            setlocalvar("noSoundP0", NULL());
        }

        //CLEAR "NO SOUND" FLAG FOR PLAYER 2 IF NOT IN THE SELECT SCREEN
        if(getlocalvar("noSoundP1") != NULL())
        {
            setlocalvar("noSoundP1", NULL());
        }
    }
}

EDIT: Adapted to 4 players.
 
Back
Top Bottom