Random
#1

Hi everyone, I got a little question about the random function.

Well, for my GM I need something that can set the skins of my characters random.

So for example:
/cops

then the player joins team cops (already made that ofc)
and he's skin will be set random.

I already did this:
Code:
new float: CopSkinsL1 [8] [1] =
{ //The skins:
	{280},
	{281},
    {282},
    {283},
    {265},
    {266},
    {267},
    {288}
};
and then I'm stuck....

Oh, yeah and can somebody explain me what that [1] means? or what should be in there...
Reply
#2

Skinid's are not floats.

This is all you need.

pawn Code:
new CopSkinsL1[] =
{
    280,
    281,
    282,
    283,
    265,
    266,
    267,
    288
};
pawn Code:
SetPlayerSkin(playerid,CopSkinsL1[random(sizeof(CopSkinsL1))];
Reply
#3

You don't need to declare the size. Stop posting shite.
Reply
#4

TO bmuk:

Ty, but then I get this error: error 001: expected token: ",", but found ";"
Code:
SetPlayerSkin(playerid,CopSkinsL1[random(sizeof(CopSkinsL1))];
Reply
#5

I forgot an ")" at the end.

Use this: SetPlayerSkin(playerid,CopSkinsL1[random(sizeof(CopSkinsL1))]);
Reply
#6

Woops, stupid I didn't notice it :P
anyways thanks alot mate!
Reply
#7

stock randomMix(...) return getarg(random(numargs()));

Then

SetPlayerSkin(playerid, randomMix(280, 281, 282, 283, 265, 266, 267, 268 ));

More easy, I think?
Reply
#8

Quote:
Originally Posted by Gh0sT_
View Post
stock randomMix(...) return getarg(random(numargs()));

Then

SetPlayerSkin(playerid, randomMix(280, 281, 282, 283, 265, 266, 267, 268 ));

More easy, I think?
Lol, not really IMO, sorry I appreciate your effort : )
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)