What's wrong with my /fishes command?
#9

Well you'd have to use the 'random' function for that.
What you could do was something like this:

pawn Код:
new
    iRand = random(87)
;

if( iRand < 10 ) // 0 - 9
{
    iRand = 0
}
else if( iRand < 20 ) // 10 - 19
{
    iRand = 1;
}
else if( iRand < 30 ) // 20 - 29
{
    iRand = 2;
}
else if( iRand < 40 ) // 30 - 39
{
    iRand = 3;
}
else if( iRand < 50 ) // 40 - 49
{
    iRand = 4;
}
else if( iRand < 60 ) // 50 - 59
{
    iRand = 5;
}
else
{
    iRand -= 54;
}
Here I created a random value from 0 to 86.
Your array has only 33 indexes - this is why I have to check its value.
With the code above, the numbers 0-9 will give you the first index ("Shark"), 10-19 will give you the next one, et cetera.
If your randomly chosen value is 60 or more, it will simply set the moneybags.
Moneybag #1 is on index 6, so value 60 should be index 6, and we all know that 60 - 54 = 6, hence the "iRand -= 54;" expression.

If you want less change of getting moneybags, increase the integer used in the 'random' function call by a number dividible by 6, as you have 6 fishes, then change the if-statements to match it.

To then select your index, you simply have to do this:

pawn Код:
FishNames[ iRand ]

//example:
format( string, sizeof( string ), "%s", FishNames[ iRand ] );
I hope you understand and can and will take this to good use - good luck!
Reply


Messages In This Thread
What's wrong with my /fishes command? - by AphexCCFC - 08.02.2013, 18:57
Re: What's wrong with my /fishes command? - by LarzI - 08.02.2013, 18:59
Re: What's wrong with my /fishes command? - by AphexCCFC - 08.02.2013, 19:12
Re: What's wrong with my /fishes command? - by LarzI - 08.02.2013, 19:22
Re: What's wrong with my /fishes command? - by AphexCCFC - 08.02.2013, 19:23
Re: What's wrong with my /fishes command? - by AphexCCFC - 08.02.2013, 19:28
Re: What's wrong with my /fishes command? - by LarzI - 08.02.2013, 19:28
Re: What's wrong with my /fishes command? - by AphexCCFC - 08.02.2013, 19:38
Re: What's wrong with my /fishes command? - by LarzI - 08.02.2013, 19:52
Re: What's wrong with my /fishes command? - by AphexCCFC - 08.02.2013, 20:18

Forum Jump:


Users browsing this thread: 1 Guest(s)