PayDay just called if playerid is 0
#1

Код:
forward MinuteCheck();
public MinuteCheck()
{
	static
	    Float:hp;

    foreach (Player, i)
	{
	    if (!PlayerData[i][pLogged] && !PlayerData[i][pCharacter])
	        continue;

        PlayerData[i][pMinutes]++;
        
		if (PlayerData[i][pMinutes] >= 60)
       	{
           	PlayerData[i][pMinutes] = 0;
			PlayerData[i][pPlayingHours]++;
		}
		if (PlayerData[i][pInjured])
		{
		    GetPlayerHealth(i, hp);
		    SetPlayerHealth(i, hp - 10.0);
		}
	}
	new
 		time[3];

	gettime(time[0], time[1], time[2]);
 	time[0] = FixHour(time[0]);

	if ((time[0] > g_Hour[0]) || (time[0] == 0 && g_Hour[0] == 23))
	{
		g_Hour[0] = time[0];
  		SetWorldTime(g_Hour[0]);
               SendClientMessageToAllEx(COLOR_WHITE, "The time is now %d:00.", g_Hour[0]);  // Tested and called
		PayDay(); // Here the error
	}
 	for (new i = 0; i != MAX_DRUG_PLANTS; i ++) if (PlantData[i][plantExists] && PlantData[i][plantDrugs] < Plant_MaxGrams(PlantData[i][plantType])) {
	    PlantData[i][plantDrugs]++;

	    Plant_Refresh(i);
	    Plant_Save(i);
	}
	return 1;
}
Payday Code:
Код:
PayDay()
{
	foreach(Player, i)
	{
	    if (GetPVarInt(i, "PayCheck") >= 25)
		{
	 		PlayerData[i][pExp]++;
	  		new
			  	paycheck = GetPVarInt(i, "PayCheck"),
				interest = PlayerData[i][pBankMoney] / 20,
				totalmoney = (paycheck - Tax_Percent(paycheck)) + interest;

			PlayerData[i][pBankMoney] += totalmoney;

			SendClientMessage(i, DEFAULT_COLOR, "________ BANK STATEMENT ________");
			SendClientMessageEx(i, COLOR_WHITE, "Paycheck: %s |  Tax Money: %s", FormatNumber(paycheck), FormatNumber(Tax_Percent(paycheck)));
    		SendClientMessageEx(i, COLOR_WHITE, "Balance: %s  |  Interest rate: 0.5%", FormatNumber(PlayerData[i][pBankMoney]));
     		SendClientMessageEx(i, COLOR_WHITE, "Interest gained: %s", FormatNumber(interest));
			SendClientMessage(i, COLOR_GRAD4, "________________________________");
  			SendClientMessageEx(i, COLOR_WHITE, "New account balance: %s", FormatNumber(PlayerData[i][pBankMoney]));
    		SendClientMessageEx(i, COLOR_WHITE, "Paycheck (Taxes and profits applied): $%s", FormatNumber(totalmoney));
			GameTextForPlayer(i, "~p~PayDay~n~~w~Paycheck", 5000, 1);
            DeletePVar(i, "PayCheck");
			return 1;
		}
		else
		{
		    SendClientMessageEx(i, COLOR_LIGHTRED, "* You haven't played long enough to obtain a paycheck.");
            DeletePVar(i, "PayCheck");
			return 1;
		}
	}
	return 1;
}
Reply
#2

Anyone?
Reply
#3

What is problem, i mean any error or something??
Reply
#4

I think you should make it per player instead of foreach.
Reply
#5

try this:
pawn Код:
PayDay()
{
    for(new i = 0;i < MAX_PLAYERS;i++)
    {
        if(IsPlayerConnected(i)
        {
        if (GetPVarInt(i, "PayCheck") >= 25)
        {
            PlayerData[i][pExp]++;
            new
                paycheck = GetPVarInt(i, "PayCheck"),
                interest = PlayerData[i][pBankMoney] / 20,
                totalmoney = (paycheck - Tax_Percent(paycheck)) + interest;

            PlayerData[i][pBankMoney] += totalmoney;

            SendClientMessage(i, DEFAULT_COLOR, "________ BANK STATEMENT ________");
            SendClientMessageEx(i, COLOR_WHITE, "Paycheck: %s |  Tax Money: %s", FormatNumber(paycheck), FormatNumber(Tax_Percent(paycheck)));
            SendClientMessageEx(i, COLOR_WHITE, "Balance: %s  |  Interest rate: 0.5%", FormatNumber(PlayerData[i][pBankMoney]));
            SendClientMessageEx(i, COLOR_WHITE, "Interest gained: %s", FormatNumber(interest));
            SendClientMessage(i, COLOR_GRAD4, "________________________________");
            SendClientMessageEx(i, COLOR_WHITE, "New account balance: %s", FormatNumber(PlayerData[i][pBankMoney]));
            SendClientMessageEx(i, COLOR_WHITE, "Paycheck (Taxes and profits applied): $%s", FormatNumber(totalmoney));
            GameTextForPlayer(i, "~p~PayDay~n~~w~Paycheck", 5000, 1);
            DeletePVar(i, "PayCheck");
            return 1;
        }
        else
        {
            SendClientMessageEx(i, COLOR_LIGHTRED, "* You haven't played long enough to obtain a paycheck.");
            DeletePVar(i, "PayCheck");
            return 1;
        }
    }
       }
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)