PHP код:
Payday()
{
foreach(new playerid: Player)
{
new moneyGiven, PhoneBill, Float:InterestRate, Interest, MinutesTabbed, MinutesReal, PlayerLevel, taxamount, exp, extra = 1;
if(MinutesConnected[playerid] < MINUTES_FOR_PAYDAY)
{
return SendClientMessage(playerid, COLOR_GRAD3, "You have not played long enough to receive a paycheck.");
}
printf("PlayerID3: %d", playerid);
//Interest Rates
if(PlayerInfo[playerid][pVIP] == 0)
{
InterestRate = 0.01;
}
else if(PlayerInfo[playerid][pVIP] == 1)
{
InterestRate = 0.015;
}
else if(PlayerInfo[playerid][pVIP] == 2)
{
InterestRate = 0.02;
}
else if(PlayerInfo[playerid][pVIP] == 3)
{
InterestRate = 0.03;
}
else
{
InterestRate = 0.01;
}
PhoneBill = floatround((PlayerInfo[playerid][pTexts] + PlayerInfo[playerid][pCalls])*0.75);
Interest = floatround(PlayerInfo[playerid][pBank] * InterestRate);
MinutesTabbed = floatround(totalTimeTab[playerid]/60);
MinutesReal = MinutesConnected[playerid] - MinutesTabbed;
if(MinutesReal <= 0)
{
MinutesReal = 1;
PlayerLevel = (PlayerInfo[playerid][pLevel] * 2) * MinutesReal;
}
else
{
PlayerLevel = (PlayerInfo[playerid][pLevel] * 2) * MinutesReal;
}
printf("Interest1: %f", InterestRate);
printf("Minutes Connected: %d", MinutesConnected[playerid]);
printf("Minutes Tabbed: %d", MinutesTabbed);
printf("Minutes Total: %d", MinutesReal);
moneyGiven = PlayerLevel + Interest - PhoneBill;
taxamount = floatround(tax*moneyGiven);
moneyGiven -= taxamount;
safeamount += taxamount;
SendClientMessage(playerid, COLOR_WHITE, "__________________ PAYDAY __________________");
SendClientMessageEx(playerid, COLOR_GRAD3, "Money: $%d", PlayerLevel);
SendClientMessageEx(playerid, COLOR_GRAD4, "%.3f Interest (Limit 10000): $%d", InterestRate, Interest);
SendClientMessageEx(playerid, COLOR_GRAD4, "Phone Bill: $%d", PhoneBill);
SendClientMessageEx(playerid, COLOR_GRAD4, "Tax: %.3f percent, $%d", tax, taxamount);
SendClientMessageEx(playerid, COLOR_GRAD5, "Total Money: $%d", moneyGiven);
new extraVariableTwo = 1;
if(DOUBLE_EXP_WEEK > extraVariableTwo)
{
exp = moneyGiven * DOUBLE_EXP_WEEK;
moneyGiven = exp;
SendClientMessageEx(playerid, COLOR_GRAD5, "New Total Money (Double EXP Enabled): $%d", exp);
}
if(PlayerInfo[playerid][pCash] > 0) SendClientMessage(playerid, COLOR_YELLOW, "Your paycheck has been deposited into your bank account.");
SendClientMessage(playerid, COLOR_WHITE, "____________________________________________");
if(PlayerInfo[playerid][pCash] <= 0) PlayerInfo[playerid][pCash] += floatround(moneyGiven);
else PlayerInfo[playerid][pBank] += floatround(moneyGiven);
PlayerInfo[playerid][pTexts] = 0;
PlayerInfo[playerid][pCalls] = 0;
totalTimeTab[playerid] = 0;
MinutesConnected[playerid] = 0;
PlayerInfo[playerid][pPlayingHours]++;
if(DOUBLE_EXP_WEEK > extra)
{
exp = 1 * DOUBLE_EXP_WEEK;
PlayerInfo[playerid][pEXP] += exp;
}
else
{
PlayerInfo[playerid][pEXP]++;
}
if(PlayerInfo[playerid][pEXP] >= PlayerInfo[playerid][pLevel]*REQUIRED_HOURS_PER_LEVEL)
{
PlayerInfo[playerid][pLevel]++;
PlayerInfo[playerid][pEXP] = 0;
SetPlayerScore(playerid, PlayerInfo[playerid][pLevel]);
SendClientMessageEx(playerid, COLOR_YELLOW, "You have leveled up to level %d. You must achieve %d more playing hours to receive level %d.", PlayerInfo[playerid][pLevel], REQUIRED_HOURS_PER_LEVEL, PlayerInfo[playerid][pLevel]+1);
}
}
return 1;
}
I am having trouble with this function because sometimes the code will give it to everyone and others it will only give it to one person. There is no if statement or anything to prevent the query from giving everyone a paycheck so I'm not sure what is going on here.