(2020-10-25, 05:59 PM)Pr0fit Wrote:I'm on it, I'll edit the comment once I finish writing the function as I'm writing on my android(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!
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
Using Pawn.CMD?
If you're doing so, this is the very first sign that you absolutely shouldn't utilize your all powerful P-Code knowledge in any of the scripting discussion topics.
If you're doing so, this is the very first sign that you absolutely shouldn't utilize your all powerful P-Code knowledge in any of the scripting discussion topics.