random select player?
#7

Quote:
Originally Posted by g1venchy
Посмотреть сообщение
PHP код:
RandomPlayerID(){
    new 
ValidPlayers[MAX_PLAYERS],cnt;
    for(new 
i,i2=GetPlayerPoolSize(); i2i++)if(IsPlayerConnected(i))ValidPlayers[cnt++]=i;
    return 
cnt==0?-1:ValidPlayers[random(cnt)];

Made the same mistake.
GetPlayerPoolSize returns the amount of connected players. For example: 10.
If someone got the ID 11 cause he logged in after ID 10, but ID 10 has been disconnected, he won't be a part of the loop.
Reply


Messages In This Thread
random select player? - by 3417512908 - 19.10.2018, 09:52
Re: random select player? - by GangstaSunny. - 19.10.2018, 15:14
Re: random select player? - by Threshold - 19.10.2018, 15:20
Re: random select player? - by GangstaSunny. - 19.10.2018, 15:28
Re: random select player? - by jasperschellekens - 19.10.2018, 15:38
Re: random select player? - by g1venchy - 19.10.2018, 15:57
Re: random select player? - by GangstaSunny. - 19.10.2018, 17:18
Re: random select player? - by g1venchy - 19.10.2018, 19:38
Re: random select player? - by GangstaSunny. - 19.10.2018, 21:24
Re: random select player? - by GTLS - 21.10.2018, 09:48

Forum Jump:


Users browsing this thread: 1 Guest(s)