Random Skins - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Random Skins (
/showthread.php?tid=187743)
Random Skins -
Gforcez - 04.11.2010
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
Re: Random Skins -
Hiddos - 04.11.2010
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
Re: Random Skins -
Gforcez - 04.11.2010
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 ?
Re: Random Skins -
Miguel - 04.11.2010
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;
}