Random Skins
#1

Hello everyone. Is there anyway of making random skins depending on if you're a male or female? If so, can you show me?
Reply
#2

pawn Код:
switch(random(amount of female skins))
{
     case 0: SetPlayerSkin// Skin 1 and so on.
}

// Same goes for males.
Reply
#3

Quote:
Originally Posted by Kitten
Посмотреть сообщение
pawn Код:
switch(random(amount of female skins))
{
     case 0: SetPlayerSkin// Skin 1 and so on.
}

// Same goes for males.
Thank you, does that also make all of the skins female? And if I want to make a dialog that says "Male" or "Female", and the player clicks on "Male", how would it know what skin to give it?
Reply
#4

Make two arrays:

pawn Код:
new gMaleSkins[] = {0,1,2,3,4,5,6,7,8,14,15,16, /* etc, etc, etc */ };
new gFemaleSkins[] = {9,10,11,12,13,17, /* etc, etc, etc */ };
Then you can just use those to select one at random.
Reply
#5

pawn Код:
stock IsMale(skinid)
{
    new const Females[] =
    {
    9,10,11,12,13,31,38,39,40,41,53,54,55,56,63,64,69,75,76,77,85,87,88,89,90,91,92,93,129,130,131,138,139,140,141,    145,148,150,151,
    152,157,169,172,178,190,191,192,193,194,195,196,197,198,199,201,205,207,211,214,215,216,218,219,224,225,226,    231,232,233,237,238,
    243,244,245,246,251,256,257,263,298
    };
    for(new i = 0; i < sizeof(Females); i++)
    {
        if(skinid == Females[i]) return 0;
    }
    return 1;
}
Reply
#6

Quote:
Originally Posted by MP2
Посмотреть сообщение
pawn Код:
stock IsMale(skinid)
{
    new const Females[] =
    {
    9,10,11,12,13,31,38,39,40,41,53,54,55,56,63,64,69,75,76,77,85,87,88,89,90,91,92,93,129,130,131,138,139,140,141,    145,148,150,151,
    152,157,169,172,178,190,191,192,193,194,195,196,197,198,199,201,205,207,211,214,215,216,218,219,224,225,226,    231,232,233,237,238,
    243,244,245,246,251,256,257,263,298
    };
    for(new i = 0; i < sizeof(Females); i++)
    {
        if(skinid == Females[i]) return 0;
    }
    return 1;
}
Thank you mate. Also I was wondering, is that it? Is that all I need to put for the gender selection or do I have to put in stock IsFemale(skinid) too?

And another question. I have made this
pawn Код:
stock MaleFemale(playerid)
{
    new string[100];
    format(string, 100, "Please select your gender below:", PlayerName(playerid));
    ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_MSGBOX, "Male or Female?", string, "Male", "Female");
}
How can I make it so when the player clicks on Male, it will spawn a random male skin? And is there any sort of saving solution for this? Thanks a lot guys!
Reply
#7

pawn Код:
OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(dialogid == DIALOG_REGISTER)
    {
        if(response)//male response
        {
            //function here
        }
        if(!response)//female response
        {
            //function here
        }
    }
}
Use this.
Reply
#8

Quote:
Originally Posted by JhnzRep
Посмотреть сообщение
pawn Код:
OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(dialogid == DIALOG_REGISTER)
    {
        if(response)//male response
        {
            //function here
        }
        if(!response)//female response
        {
            //function here
        }
    }
}
Use this.
Could be optimized to this.
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    switch(dialogid)
    {
        case DIALOG_REGISTER:
        {
            if(response)// male response
            {
                // male code
            }
            // female code here
            return 1;
        }
    }
    return 1;
}
Switch statements are much more efficient than the else-if structure, and you don't need to check for both buttons.

EDIT:

On topic, if you have two arrays. One containing the male skins and vice versa. You would use the random function to select a random skin.

pawn Код:
if(response)// male response
{
    PlayerSkin[playerid] = maleArray[random(sizeof(maleArray))];
}
Reply
#9

Quote:
Originally Posted by Vince
Посмотреть сообщение
Make two arrays:

pawn Код:
new gMaleSkins[] = {0,1,2,3,4,5,6,7,8,14,15,16, /* etc, etc, etc */ };
new gFemaleSkins[] = {9,10,11,12,13,17, /* etc, etc, etc */ };
Then you can just use those to select one at random.
Quote:
Originally Posted by MP2
Посмотреть сообщение
pawn Код:
stock IsMale(skinid)
{
    new const Females[] =
    {
    9,10,11,12,13,31,38,39,40,41,53,54,55,56,63,64,69,75,76,77,85,87,88,89,90,91,92,93,129,130,131,138,139,140,141,    145,148,150,151,
    152,157,169,172,178,190,191,192,193,194,195,196,197,198,199,201,205,207,211,214,215,216,218,219,224,225,226,    231,232,233,237,238,
    243,244,245,246,251,256,257,263,298
    };
    for(new i = 0; i < sizeof(Females); i++)
    {
        if(skinid == Females[i]) return 0;
    }
    return 1;
}
Hmm so which one of these should I be using? The one by Vince or the one by MP2?
Reply
#10

pawn Код:
new FemaleSkins[] = {
    9,10,11,12,13,31,38,39,40,41,53,54,55,56,63,64,69,75,76,77,85,87,88,89,90,91,92,93,129,130,131,138,139,140,141,145,148,150,151,
    152,157,169,172,178,190,191,192,193,194,195,196,197,198,199,201,205,207,211,214,215,216,218,219,224,225,226,231,232,233,237,238,
    243,244,245,246,251,256,257,263,298
};
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    switch(dialogid)
    {
        case DIALOG_REGISTER:
        {
            if(response)
            {
                new rand = random(sizeof(MaleSkins));
                SetPlayerSkin(playerid, MaleSkins[rand]);
            }
            else
            {
                new rand = random(sizeof(FemaleSkins));
                SetPlayerSkin(playerid, FemaleSkins[rand]);
            }
        }
    }
    return 1;
}
You need to make the MaleSkins array too.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)