Random Skins
#1

Is there a way too set a random skin to a Player ?
I Allready searcht on Wiki, But can't find anyone.

Does Somebody knows?

Regrads,
Gforcez
Reply
#2

pawn Код:
IsValidSkin(skinid) //Thanks Sergei
{
    if(0 < skinid < 300)
    {
        switch(skinid)
        {
            case 3, 4, 5, 6, 8, 42, 65, 74, 86,
            119, 149, 208, 273, 289: return 0;
        }
        return 1;
    }
    return 0;
}

public OnPlayerSpawn(playerid)
{
  new skin = random(300);
  while(!IsValidSkin(skin))
  {
    skin = random(300);
  }
  SetPlayerSkin(playerid, skin);
  return 1;
}
This gives them a random skin everytime they spawn
Reply
#3

Quote:
Originally Posted by Hiddos
Посмотреть сообщение
pawn Код:
IsValidSkin(skinid) //Thanks Sergei
{
    if(0 < skinid < 300)
    {
        switch(skinid)
        {
            case 3, 4, 5, 6, 8, 42, 65, 74, 86,
            119, 149, 208, 273, 289: return 0;
        }
        return 1;
    }
    return 0;
}

public OnPlayerSpawn(playerid)
{
  new skin = random(300);
  while(!IsValidSkin(skin))
  {
    skin = random(300);
  }
  SetPlayerSkin(playerid, skin);
  return 1;
}
This gives them a random skin everytime they spawn
Thanks, But i want to give the player a random skins from this variable:

pawn Код:
new Skins_Peds[4][1] =
{
    {60},
    {7},
    {101},
    {170}
};
Do you know how to create that ?
Reply
#4

pawn Код:
new Skins_Peds[] = {60, 7, 101, 170}; // This doesn't need to be a multidimensional array.
pawn Код:
stock SetPlayerRandomSkin(playerid)
{
    SetPlayerSkin(playerid, Skins_Peds[random(sizeof(Skins_Peds))]); // This uses a random value between 0 and the size of the array Skins_Peds -1 (0 to 3).
}
pawn Код:
public OnPlayerDoSomething(playerid) // OnPlayerConnect for example.
{
    ...
    SetPlayerRandomSkin(playerid); // Use your function anywhere you like.
    ...
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)