Foreach return problem
#1

I have this public:
Код:
forward Plata();
public Plata()
{
new payday[830];
foreach(Player, i)
    {
    if(gPlayerLogged[i] == 1)
      {
		if(PlayerInfo[i][pPayDay] < 5) return SCM(i, -1, "*Niste igrali dovoljno dugo da bi dobili platu.");
                SCM(i, -1, "You get money!");
code code code...
      }
   }
return true;
}
And like you see, if PlayerInfo[i][pPayDay] < 5 it will return for that player.

And problem is in that line. When payday come, if playerid 0 have PlayerInfo[0][pPayDay] < 5, next player who is id 1 won't get anything(he had PlayerInfo[1][pPayDay] > 5, but he dont receive any message)

What is problem? Do this line return for all players or what is problem??


And i create command for that public:
Код:
YCMD:pokreniplatu(playerid, params[], help)
{
Plata();
SCM(playerid, COLOR_WHITE, "Payday started!");
return 1;
}
And when it return "*Niste igrali dovoljno dugo da bi dobili platu.", i dont receive this message "Payday started!" from command!
Reply
#2

NVM, Bless ****** translate.
Reply
#3

Delete return from the loop

Код:
if(PlayerInfo[i][pPayDay] < 5) SCM(...);
Reply
#4

CrashDetect does not issue error?

Quote:
Originally Posted by ball
Посмотреть сообщение
Delete return from the loop

Код:
if(PlayerInfo[i][pPayDay] < 5) SCM(...);
The problem is not only in this, if there was a problem only in the return of the he seen message "Payday started!".
Reply
#5

Quote:
Originally Posted by ball
Посмотреть сообщение
Delete return from the loop

Код:
if(PlayerInfo[i][pPayDay] < 5) SCM(...);
I need that return..



Crashdetect - i test this on online linux server...(Crashdetect only on home server)
Reply
#6

Quote:
Originally Posted by DusanInfinity
Посмотреть сообщение
I need that return..



Crashdetect - i test this on online linux server...(Crashdetect only on home server)
You can use a conutine.

Код:
forward Plata();
public Plata()
{
new payday[830];
foreach(Player, i)
    {
    if(gPlayerLogged[i] == 1)
      {
		if(PlayerInfo[i][pPayDay] < 5)
                {
                  SCM(i, -1, "*Niste igrali dovoljno dugo da bi dobili platu.");
                  conutine;
                }
                SCM(i, -1, "You get money!");
code code code...
      }
   }
return true;
}
Reply
#7

Confirm they are over 5 hours and process their pay. Avoids the return all together.

I don't think CrashDetect is for this at all.
Reply
#8

Quote:
Originally Posted by Sew_Sumi
Посмотреть сообщение
Confirm they are over 5 hours and process their pay. Avoids the return all together.
When all players have payday > 5, there is no problem, all get pay. But when just 1 player have payday < 5, and if that playerid is 200, all players who are 200+ id won't get pay...
Reply
#9

Then it's obviously because you are returning within the foreach.
Reply
#10

Okey i found one way, it must work good. Thank you all guys!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)