SA-MP Forums Archive
Please help me on this - 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)
+--- Thread: Please help me on this (/showthread.php?tid=660808)



Please help me on this - akib - 14.11.2018

How to do it?

Example:
Код:
1000
5000
600
788
96666
....
I want to give player money from it

Код:
GivePlayerMoney(line);
P.S : Without using 'random' function to do it


Re: Please help me on this - YourWhalecum - 14.11.2018

Quote:
Originally Posted by akib
Посмотреть сообщение
How to do it?

Example:
Код:
1000
5000
600
788
96666
....
I want to give player money from it

Код:
GivePlayerMoney(line);
P.S : Without using 'random' function to do it
Can you explain what those first numbers are for?
Код:
1000
5000
600
788
96666



Re: Please help me on this - akib - 14.11.2018

Quote:
Originally Posted by YourWhalecum
Посмотреть сообщение
Can you explain what those first numbers are for?
Код:
1000
5000
600
788
96666
These numbers are random, manually added by admins or owner, just suppose like this
PHP код:
format(msg,sizeof(msg),"1000\n5000\n600\n788\n96666"); 
and i have to show it like this
PHP код:
GivePlayerMoney(line); 
Line will be selected one by one,

1st time it should be GivePlayerMoney(playerid,1000);
2nd time it should be GivePlayerMoney(playerid,5000);


Re: Please help me on this - aristoffky - 14.11.2018

You use arrays for this.


Re: Please help me on this - aristoffky - 14.11.2018

Код:
new myArray[1][5];

myArray[1][1] = 1000;
myArray[1][2] = 5000;
etc. etc.


Re: Please help me on this - khRamin78 - 14.11.2018

Quote:
Originally Posted by akib
Посмотреть сообщение
These numbers are random, manually added by admins or owner, just suppose like this
PHP код:
format(msg,sizeof(msg),"1000\n5000\n600\n788\n96666"); 
and i have to show it like this
PHP код:
GivePlayerMoney(line); 
Line will be selected one by one,

1st time it should be GivePlayerMoney(playerid,1000);
2nd time it should be GivePlayerMoney(playerid,5000);
PHP код:
new array[10]; // 10 = max numbers that will be randomeed can be any thing
array[0] = 1000;
array[
1] = 5000;
array[
2] = 600;
array[
3] = 788;
array[
4] = 96666;
new 
ran;
do
{
    
ran random(sizeof(array));
}while(array[
ran] != 0);
array[
ran] >> your random number 



Re: Please help me on this - aristoffky - 14.11.2018

Quote:
Originally Posted by khRamin78
Посмотреть сообщение
PHP код:
new array[10]; // 10 = max numbers that will be randomeed can be any thing
array[0] = 1000;
array[
1] = 5000;
array[
2] = 600;
array[
3] = 788;
array[
4] = 96666;
new 
ran;
do
{
    
ran random(sizeof(array));
}while(array[
ran] != 0);
array[
ran] >> your random number 
actually this ^
dunno why i went into multidimensional arrays when one dimension is probs enough for him.


Re: Please help me on this - khRamin78 - 14.11.2018

Quote:
Originally Posted by aristoffky
Посмотреть сообщение
actually this ^
dunno why i went into multidimensional arrays when one dimension is probs enough for him.
actually multidimensional arrays would be needed if he wants te seperate random numbers for each admin

like at the same time 2x admins type /randomnumbers 100 200 155 300 & /randomnumbers 20 56 8 9788 451 22

in that case it will be needed and be some like this :
PHP код:
new array[MAX_PLAYERS][10];
array[
first admin playerid][10];
array[
second admin playerid][10]; 
but it wouldn't happen and needed i think


Re: Please help me on this - akib - 14.11.2018

Thanks all for your reply.

But all ans have a limited array, i need infinity array, there can be 10values or 100values or 1000values or can be 123values


Re: Please help me on this - khRamin78 - 14.11.2018

Quote:
Originally Posted by ******
Посмотреть сообщение
Why do you not want to use random, how do you intend to select a number?
he wants to make custom random cmd between some int's like


/customrandom 1 2 3 100 50

the randomed numbers will be 1 or 2 or 3 or 100 or 50