Get Random Helper Problem - 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: Get Random Helper Problem (
/showthread.php?tid=625265)
Get Random Helper Problem -
BUHA - 30.12.2016
Hi all, how could I do a script by which to select a completely random ID helper.
I tried to make this way but fail and I have no idea what's wrong if someone can help me?
PHP код:
foreach(Player, i)
{
if(PlayerInfo[i][pHelper] >= 1)
{
new randomhelp = random(i);
SCM(randomhelp, -1, "Test");
}
}
How should I do? - Sorry for my bad english, i use ****** translate
Re: Get Random Helper Problem -
SoLetsGO - 30.12.2016
So I think you have your PlayerInfo and in there you have the "pHelper" and you want to choose a random player where pHelper is greater than 0. So I do not get what you are doing there, i guess this is what you want:
PHP код:
new i = random(MAX_PLAYERS);
while( (!IsPlayerConnected(i)) || PlayerInfo[i][pHelper] < 1){
i = random(MAX_PLAYERS);
}
new randomhelp = i;
Re: Get Random Helper Problem -
BUHA - 30.12.2016
Quote:
Originally Posted by SoLetsGO
So I think you have your PlayerInfo and in there you have the "pHelper" and you want to choose a random player where pHelper is greater than 0. So I do not get what you are doing there, i guess this is what you want:
PHP код:
new i = random(MAX_PLAYERS);
while( (!IsPlayerConnected(i)) || PlayerInfo[i][pHelper] < 1){
i = random(MAX_PLAYERS);
}
new randomhelp = i;
|
thank you ! it's work
Re: Get Random Helper Problem -
Spmn - 30.12.2016
Quote:
Originally Posted by SoLetsGO
So I think you have your PlayerInfo and in there you have the "pHelper" and you want to choose a random player where pHelper is greater than 0. So I do not get what you are doing there, i guess this is what you want:
PHP код:
new i = random(MAX_PLAYERS);
while( (!IsPlayerConnected(i)) || PlayerInfo[i][pHelper] < 1){
i = random(MAX_PLAYERS);
}
new randomhelp = i;
|
If there's no helper online, then you just entered an infinite loop.
Create a foreach iterator for helpers and use Iter_Random()
Re: Get Random Helper Problem -
BUHA - 30.12.2016
Quote:
Originally Posted by Spmn
If there's no helper online, then you just entered an infinite loop.
Create a foreach iterator for helpers and use Iter_Random()
|
I already created a function by which to check if any helper on duty