• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Pawn] Random Players
#7
(2020-10-25, 07:56 PM)Pinch Wrote:
(2020-10-25, 05:59 PM)Pr0fit Wrote:
(2020-10-25, 04:13 PM)Expert* Wrote: I can make a function for that with no extra includes. YSI is amazing but if you dont want to use it it's up to you.



1. What if there is only 5 online. We fail the function or pick them ?

2 What if there is only 1 or 2 people online, do we pick them or fail the function ?



Oh, that would be lovely if you can, since I don't understand much in coding.



Well, if possible, if there are 10 people, the function would only work then.



Also, players shouldn't repeat in that function, if that's possible as well.



And thank you, and everyone else for answering!

I'm on it, I'll edit the comment once I finish writing the function as I'm writing on my android



Code:
randomPlayerFunction()

{

? ? const

? ? ? ? MAX_RND_PLAYERS = 5,

? ? ? ? MIN_RND_ONLINE = 10;

? ? ? ?

? ? if (Iter_Count(Player) < MIN_RND_ONLINE) return 0;

? ?

? ? new

? ? ? ? tmpIDs[MAX_RND_PLAYERS] = INVALID_PLAYER_ID,

? ? ? ? counter;

? ? ? ?

? ? while(tmpIDs[MAX_RND_PLAYERS - 1] == INVALID_PLAYER_ID)

? ? {

? ? ? ? new

? ? ? ? ? ? val = Iter_Random(Player);

? ? ? ? ? ?

? ? ? ? for(new i = 0; i < MAX_RND_PLAYERS; )

? ? ? ? {

? ? ? ? ? ? if(tmpIDs[i] == val)

? ? ? ? ? ? ? ? break;

? ? ? ? ? ? ? ?

? ? ? ? ? ? if(i == MAX_RND_PLAYERS)

? ? ? ? ? ? {

? ? ? ? ? ? ? ? tmpIDs[counter] = val;

? ? ? ? ? ? ? ? counter ;

? ? ? ? ? ? }

? ? ? ? }

? ? }

? ?

? ? for(new id = 0; id < MAX_RND_PLAYERS; 﨧)

? ? {

? ? ? ? // code

? ? ? ? // usage ex

? ? ? ? printf("ID: %i", tmpIDs[id]);

? ? }

? ? return 1;

}



This should work

I will give it a try tomorrow. Thank you so much! :)
  Reply


Messages In This Thread
Random Players - by Pr0fit - 2020-10-25, 01:02 PM
RE: Random Players - by Jonies - 2020-10-25, 01:27 PM
RE: Random Players - by Josh - 2020-10-25, 03:19 PM
RE: Random Players - by Expert* - 2020-10-25, 04:13 PM
RE: Random Players - by Pr0fit - 2020-10-25, 05:59 PM
RE: Random Players - by Pinch - 2020-10-25, 07:56 PM
RE: Random Players - by Pr0fit - 2020-10-25, 08:50 PM

Forum Jump: