[Tutorial] Random Function
#2

Nice of you to write this tutorial, but a couple of things:
Firstly, you didn't actually randomize anything - you just have a variable called Randoming, which contains junk because you didn't give it any value, and you're trying to switch its value - but it doesn't have any, so you'll have to add this:
pawn Код:
new Randoming;

public OnPlayerSpawn(playerid)
{
    Randoming = random(2);
    switch(Randoming)
    {
        //
    }
    return 1;
}
Second thing is, you can actually make this far easier with two-dimensional arrays:

pawn Код:
new randstuff[2][4] = {
{float: 1305.25, float: 524.19, float: 15.04, 100},
{float: 1240.61, float: 1351.35, float: 12.54, 200}
};

public OnPlayerSpawn(playerid)
{
    new RandomIze = random(sizeof(randstuff));
    SetPlayerPos(playerid, randstuff[RandomIze][0], randstuff[RandomIze][1], randstuff[RandomIze][2]);
    GivePlayerMoney(playerid, randstuff[RandomIze][3]);
    return 1;
}
This will actually save you up a lot of writing space.
Reply


Messages In This Thread
Random Function - by Private200 - 09.04.2013, 20:57
Re: Random Function - by [XST]O_x - 09.04.2013, 21:10
Re: Random Function - by Private200 - 09.04.2013, 21:33

Forum Jump:


Users browsing this thread: 1 Guest(s)