Loop won't break correctly (Timer) - 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: Loop won't break correctly (Timer) (
/showthread.php?tid=608544)
Loop won't break correctly (Timer) -
Dokins - 02.06.2016
Players seem to get spammed with 'you did not qualify for a paycheck' if they haven't.. It runs on the hour every hour but it repeats itself, how do I combat this? I want it to break after it has reached all online players.
pawn Код:
if(TMins == 60)
{ //this resets the mins to 00 one it reaches 60
THrs ++;
TMins = 00;
foreach(Player, i)
{
if(IsPlayerConnected(i))
{
SetPlayerTime(i,THrs,TMins);
if(LoggedIn[i])
{
if(LastPayday[i] < 60)
{
SendClientMessage(i, COLOUR_PURPLE, "You did not qualify for a paycheck as you have not played for enough time.");
}
if(LastPayday[i] >= 60)
{
doPayDay(i);
}
if(DrunkLevel[i] != 0)
{
DrunkLevel[i] -= 0.015;
if(DrunkLevel[i] < 0.08)
{
SetPlayerDrunkLevel(i, 0);
}
if(DrunkLevel[i] > 0.08 && DrunkLevel[i] < 0.2)
{
SetPlayerDrunkLevel(i, 0);
}
if(DrunkLevel[i] > 0.2 && DrunkLevel[i] < 0.5)
{
SetPlayerDrunkLevel(i, 20000);
}
if(DrunkLevel[i] > 0.5 && DrunkLevel[i] < 1.0)
{
SetPlayerDrunkLevel(i, 30000);
}
if(DrunkLevel[i] > 1.0)
{
SetPlayerDrunkLevel(i, 50000);
}
}
}
}
}
}
Re: Loop won't break correctly (Timer) -
Stinged - 02.06.2016
Use break;
Re: Loop won't break correctly (Timer) -
Dokins - 02.06.2016
Still not resolved.
Thanks.
Re: Loop won't break correctly (Timer) -
oMa37 - 02.06.2016
EDIT: ah, you solved it.
Try this:
PHP код:
if(TMins == 60)
{ //this resets the mins to 00 one it reaches 60
THrs ++;
TMins = 00;
foreach(Player, i)
{
if(IsPlayerConnected(i))
{
SetPlayerTime(i,THrs,TMins);
if(LoggedIn[i])
{
if(LastPayday[i] < 60)
{
SendClientMessage(i, COLOUR_PURPLE, "You did not qualify for a paycheck as you have not played for enough time.");
}
if(LastPayday[i] >= 60)
{
doPayDay(i);
}
if(DrunkLevel[i] != 0)
{
DrunkLevel[i] -= 0.015;
if(DrunkLevel[i] < 0.08)
{
SetPlayerDrunkLevel(i, 0);
}
if(DrunkLevel[i] > 0.08 && DrunkLevel[i] < 0.2)
{
SetPlayerDrunkLevel(i, 0);
}
if(DrunkLevel[i] > 0.2 && DrunkLevel[i] < 0.5)
{
SetPlayerDrunkLevel(i, 20000);
}
if(DrunkLevel[i] > 0.5 && DrunkLevel[i] < 1.0)
{
SetPlayerDrunkLevel(i, 30000);
}
if(DrunkLevel[i] > 1.0)
{
SetPlayerDrunkLevel(i, 50000);
}
}
}
}
break;
}
}
Re: Loop won't break correctly (Timer) -
Dokins - 02.06.2016
I didn't actually, I realise I used a different timer, didn't seem to work.
I'll try that, thanks!
Re: Loop won't break correctly (Timer) -
Dokins - 02.06.2016
UPDATE: Didn't seem to fix it, issue remains.
Re: Loop won't break correctly (Timer) -
Dayrion - 02.06.2016
Try this maybe :
PHP код:
if(TMins == 60)
{ //this resets the mins to 00 one it reaches 60
THrs ++;
TMins = 00;
foreach(new i : Player)
{
SetPlayerTime(i,THrs,TMins);
if(LoggedIn[i])
{
if(LastPayday[i] < 60)
{
SendClientMessage(i, COLOUR_PURPLE, "You did not qualify for a paycheck as you have not played for enough time.");
}
else if(LastPayday[i] >= 60)
{
doPayDay(i);
}
if(DrunkLevel[i] != 0)
{
DrunkLevel[i] -= 0.015;
if(DrunkLevel[i] < 0.08)
{
SetPlayerDrunkLevel(i, 0);
}
else if(DrunkLevel[i] >= 0.08 && DrunkLevel[i] < 0.2)
{
SetPlayerDrunkLevel(i, 0);
}
else if(DrunkLevel[i] >= 0.2 && DrunkLevel[i] < 0.5)
{
SetPlayerDrunkLevel(i, 20000);
}
else if(DrunkLevel[i] >= 0.5 && DrunkLevel[i] < 1.0)
{
SetPlayerDrunkLevel(i, 30000);
}
else if(DrunkLevel[i] >= 1.0)
{
SetPlayerDrunkLevel(i, 50000);
}
}
return 1;
}
else break;
}
}