Payday system bugged
#1

My payday system is bugged and I cant seem to find any were where it could be causing it.
But the bug is that when the payday is triggerd only one person on the server will actually get a paycheck.
Everyone will get the gametext saying "Payday" but they wont get the "SendClientMessage" or the money in their bank account.

For example if there are 10 players on the server and the payday is triggered... Only one person will get the "SendClientMessage" and actually get paid.

Код:
forward Payday();

public OnGameModeInit()
SetTimer("Payday",6000000,1);
Код:
public Payday()
{
     //random pay MAX: $40,000

    new string[128], string2[128];
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
	    new payday = PlayerInfo[i][pBank] * 3/100;
	    new factionpay = random(30000);
	    new factionpay6 = random(100000) + 50000;
		new tax = payday + factionpay * 3/100;
		new tax2 = payday * 3/100;
		new total = payday + factionpay - tax;
		new total2= payday - tax2;
		new factotal1 = factionpay6 - tax2;
		new factotal2 = factotal1 + payday;

    	if(IsPlayerConnected(i))
    	{

		    format(string,sizeof(string),"~b~Payday: ~p~$%d", payday);
		    GameTextForAll(string, 5000, 5);
		    SendClientMessage(i, -1, "=====================Payday========================");
		    if(PlayerInfo[i][pFaction] == 1)
			{
   				if(PlayerInfo[i][pFacRank] == 1)
		        {
		            new string3[128], str4[128], str5[128];
	             //   new factionpay = random(30000);
					format(string3, sizeof(string3), "Salary: $%d", factionpay);
					SendClientMessage(i, -1, string3);
					format(str5, sizeof(str5), "Taxes: $%d", tax);
					SendClientMessage(i, -1, str5);
					format(string2, sizeof(string2), "Your paycheck: $%d", payday);
					SendClientMessage(i, -1, string2);
					SendClientMessage(i, -1, "--------------------------------");
		   			format(str4, sizeof(str4), "Total payday: $%d", total);
		   			SendClientMessage(i, -1, str4);
		   			PlayerInfo[i][pBank] += total;
					return 1;
		        }
		        else if(PlayerInfo[i][pFacRank] == 2)
		        {
		            new string3[128], str4[128], str5[128];
	           //     new factionpay = random(30000);
					format(string3, sizeof(string3), "Salary: $%d", factionpay);
					SendClientMessage(i, -1, string3);
					format(str5, sizeof(str5), "Taxes: $%d", tax);
					SendClientMessage(i, -1, str5);
					format(string2, sizeof(string2), "Your paycheck: $%d", payday);
					SendClientMessage(i, -1, string2);
					SendClientMessage(i, -1, "--------------------------------");
		   			format(str4, sizeof(str4), "Total payday: $%d", total);
		   			SendClientMessage(i, -1, str4);
		   			PlayerInfo[i][pBank] += total;
					return 1;
		        }
		        else if(PlayerInfo[i][pFacRank] == 3)
		        {
		            new string3[128], str4[128], str5[128];
	           //     new factionpay = random(30000);
					format(string3, sizeof(string3), "Salary: $%d", factionpay);
					SendClientMessage(i, -1, string3);
					format(str5, sizeof(str5), "Taxes: $%d", tax);
					SendClientMessage(i, -1, str5);
					format(string2, sizeof(string2), "Your paycheck: $%d", payday);
					SendClientMessage(i, -1, string2);
					SendClientMessage(i, -1, "--------------------------------");
		   			format(str4, sizeof(str4), "Total payday: $%d", total);
		   			SendClientMessage(i, -1, str4);
		   			PlayerInfo[i][pBank] += total;
					return 1;
		        }
		        else if(PlayerInfo[i][pFacRank] == 4)
		        {
		            new string3[128], str4[128], str5[128];
	           //     new factionpay = random(30000);
					format(string3, sizeof(string3), "Salary: $%d", factionpay);
					SendClientMessage(i, -1, string3);
					format(str5, sizeof(str5), "Taxes: $%d", tax);
					SendClientMessage(i, -1, str5);
					format(string2, sizeof(string2), "Your paycheck: $%d", payday);
					SendClientMessage(i, -1, string2);
					SendClientMessage(i, -1, "--------------------------------");
		   			format(str4, sizeof(str4), "Total payday: $%d", total);
		   			SendClientMessage(i, -1, str4);
		   			PlayerInfo[i][pBank] += total;
					return 1;
		        }
		        else if(PlayerInfo[i][pFacRank] == 5)
		        {
		            new string3[128], str4[128], str5[128];
	           //     new factionpay = random(30000);
					format(string3, sizeof(string3), "Salary: $%d", factionpay);
					SendClientMessage(i, -1, string3);
					format(str5, sizeof(str5), "Taxes: $%d", tax);
					SendClientMessage(i, -1, str5);
					format(string2, sizeof(string2), "Your paycheck: $%d", payday);
					SendClientMessage(i, -1, string2);
					SendClientMessage(i, -1, "--------------------------------");
		   			format(str4, sizeof(str4), "Total payday: $%d", total);
		   			SendClientMessage(i, -1, str4);
		   			PlayerInfo[i][pBank] += total;
					return 1;
		        }
		        else if(PlayerInfo[i][pFacRank] == 6)
		        {
		            new string3[128], str4[128], str5[128], str6[128];
	           //     new factionpay = random(30000);
					format(string3, sizeof(string3), "Salary: $%d", factotal2);
					SendClientMessage(i, -1, string3);
					format(str5, sizeof(str5), "Taxes: $%d", tax);
					SendClientMessage(i, -1, str5);
					format(string2, sizeof(string2), "Your paycheck: $%d", payday);
					SendClientMessage(i, -1, string2);
					SendClientMessage(i, -1, "--------------------------------");
		   			format(str4, sizeof(str4), "Total payday: $%d", total);
		   			SendClientMessage(i, -1, str4);
		   			format(str6, sizeof(str6), "New account balance: $%d", PlayerInfo[i][pBank]);
		   			SendClientMessage(i, -1, str6);
		   			PlayerInfo[i][pBank] += factotal2;
					return 1;
		        }
		        else if(PlayerInfo[i][pFacLeader] == 1)
		        {

		        }
	    	}
	    	else if(PlayerInfo[i][pFaction] == 3)
	    	{
	        	if(PlayerInfo[i][pFacRank] == 1)
	        	{
		            new string3[128], str4[128], str5[128];
	             //   new factionpay = random(30000);
					format(string3, sizeof(string3), "Salary: $%d", factionpay);
					SendClientMessage(i, -1, string3);
					format(str5, sizeof(str5), "Taxes: $%d", tax);
					SendClientMessage(i, -1, str5);
					format(string2, sizeof(string2), "Your paycheck: $%d", payday);
					SendClientMessage(i, -1, string2);
					SendClientMessage(i, -1, "--------------------------------");
		   			format(str4, sizeof(str4), "Total payday: $%d", total);
		   			SendClientMessage(i, -1, str4);
		   			PlayerInfo[i][pBank] += total;
					return 1;
	        	}
		        else if(PlayerInfo[i][pFacRank] == 2)
		        {
		            new string3[128], str4[128], str5[128];
	           //     new factionpay = random(30000);
					format(string3, sizeof(string3), "Salary: $%d", factionpay);
					SendClientMessage(i, -1, string3);
					format(str5, sizeof(str5), "Taxes: $%d", tax);
					SendClientMessage(i, -1, str5);
					format(string2, sizeof(string2), "Your paycheck: $%d", payday);
					SendClientMessage(i, -1, string2);
					SendClientMessage(i, -1, "--------------------------------");
		   			format(str4, sizeof(str4), "Total payday: $%d", total);
		   			SendClientMessage(i, -1, str4);
		   			PlayerInfo[i][pBank] += total;
					return 1;
	        	}
		        else if(PlayerInfo[i][pFacRank] == 3)
		        {
		            new string3[128], str4[128], str5[128];
	           //     new factionpay = random(30000);
					format(string3, sizeof(string3), "Salary: $%d", factionpay);
					SendClientMessage(i, -1, string3);
					format(str5, sizeof(str5), "Taxes: $%d", tax);
					SendClientMessage(i, -1, str5);
					format(string2, sizeof(string2), "Your paycheck: $%d", payday);
					SendClientMessage(i, -1, string2);
					SendClientMessage(i, -1, "--------------------------------");
		   			format(str4, sizeof(str4), "Total payday: $%d", total);
		   			SendClientMessage(i, -1, str4);
		   			PlayerInfo[i][pBank] += total;
					return 1;
		        }
		        else if(PlayerInfo[i][pFacRank] == 4)
		        {
		            new string3[128], str4[128], str5[128];
	           //     new factionpay = random(30000);
					format(string3, sizeof(string3), "Salary: $%d", factionpay);
					SendClientMessage(i, -1, string3);
					format(str5, sizeof(str5), "Taxes: $%d", tax);
					SendClientMessage(i, -1, str5);
					format(string2, sizeof(string2), "Your paycheck: $%d", payday);
					SendClientMessage(i, -1, string2);
					SendClientMessage(i, -1, "--------------------------------");
		   			format(str4, sizeof(str4), "Total payday: $%d", total);
		   			SendClientMessage(i, -1, str4);
		   			PlayerInfo[i][pBank] += total;
					return 1;
		        }
		        else if(PlayerInfo[i][pFacRank] == 5)
		        {
		            new string3[128], str4[128], str5[128];
	           //     new factionpay = random(30000);
					format(string3, sizeof(string3), "Salary: $%d", factionpay);
					SendClientMessage(i, -1, string3);
					format(str5, sizeof(str5), "Taxes: $%d", tax);
					SendClientMessage(i, -1, str5);
					format(string2, sizeof(string2), "Your paycheck: $%d", payday);
					SendClientMessage(i, -1, string2);
					SendClientMessage(i, -1, "--------------------------------");
		   			format(str4, sizeof(str4), "Total payday: $%d", total);
		   			SendClientMessage(i, -1, str4);
		   			PlayerInfo[i][pBank] += total;
					return 1;
		        }
		        else if(PlayerInfo[i][pFacRank] == 6)
		        {
		            new string3[128], str4[128], str5[128], str6[128];
	           //     new factionpay = random(30000);
					format(string3, sizeof(string3), "Salary: $%d", factotal2);
					SendClientMessage(i, -1, string3);
					format(str5, sizeof(str5), "Taxes: $%d", tax);
					SendClientMessage(i, -1, str5);
					format(string2, sizeof(string2), "Your paycheck: $%d", payday);
					SendClientMessage(i, -1, string2);
					SendClientMessage(i, -1, "--------------------------------");
		   			format(str4, sizeof(str4), "Total payday: $%d", total);
		   			SendClientMessage(i, -1, str4);
		   			format(str6, sizeof(str6), "New account balance: $%d", PlayerInfo[i][pBank]);
		   			SendClientMessage(i, -1, str6);
		   			PlayerInfo[i][pBank] += factotal2;
					return 1;
		        }
	    	}
			else if(PlayerInfo[i][pFaction] == 6)
		    {
		        if(PlayerInfo[i][pFacRank] == 1)
		        {
		            new string3[128], str4[128], str5[128];
	             //   new factionpay = random(30000);
					format(string3, sizeof(string3), "Salary: $%d", factionpay);
					SendClientMessage(i, -1, string3);
					format(str5, sizeof(str5), "Taxes: $%d", tax);
					SendClientMessage(i, -1, str5);
					format(string2, sizeof(string2), "Your paycheck: $%d", payday);
					SendClientMessage(i, -1, string2);
					SendClientMessage(i, -1, "--------------------------------");
		   			format(str4, sizeof(str4), "Total payday: $%d", total);
		   			SendClientMessage(i, -1, str4);
		   			PlayerInfo[i][pBank] += total;
					return 1;
		        }
		        else if(PlayerInfo[i][pFacRank] == 2)
		        {
		            new string3[128], str4[128], str5[128];
	           //     new factionpay = random(30000);
					format(string3, sizeof(string3), "Salary: $%d", factionpay);
					SendClientMessage(i, -1, string3);
					format(str5, sizeof(str5), "Taxes: $%d", tax);
					SendClientMessage(i, -1, str5);
					format(string2, sizeof(string2), "Your paycheck: $%d", payday);
					SendClientMessage(i, -1, string2);
					SendClientMessage(i, -1, "--------------------------------");
		   			format(str4, sizeof(str4), "Total payday: $%d", total);
		   			SendClientMessage(i, -1, str4);
		   			PlayerInfo[i][pBank] += total;
					return 1;
		        }
		        else if(PlayerInfo[i][pFacRank] == 3)
		        {
		            new string3[128], str4[128], str5[128];
	           //     new factionpay = random(30000);
					format(string3, sizeof(string3), "Salary: $%d", factionpay);
					SendClientMessage(i, -1, string3);
					format(str5, sizeof(str5), "Taxes: $%d", tax);
					SendClientMessage(i, -1, str5);
					format(string2, sizeof(string2), "Your paycheck: $%d", payday);
					SendClientMessage(i, -1, string2);
					SendClientMessage(i, -1, "--------------------------------");
		   			format(str4, sizeof(str4), "Total payday: $%d", total);
		   			SendClientMessage(i, -1, str4);
		   			PlayerInfo[i][pBank] += total;
					return 1;
		        }
		        else if(PlayerInfo[i][pFacRank] == 4)
		        {
		            new string3[128], str4[128], str5[128];
	           //     new factionpay = random(30000);
					format(string3, sizeof(string3), "Salary: $%d", factionpay);
					SendClientMessage(i, -1, string3);
					format(str5, sizeof(str5), "Taxes: $%d", tax);
					SendClientMessage(i, -1, str5);
					format(string2, sizeof(string2), "Your paycheck: $%d", payday);
					SendClientMessage(i, -1, string2);
					SendClientMessage(i, -1, "--------------------------------");
		   			format(str4, sizeof(str4), "Total payday: $%d", total);
		   			SendClientMessage(i, -1, str4);
		   			PlayerInfo[i][pBank] += total;
					return 1;
		        }
		        else if(PlayerInfo[i][pFacRank] == 5)
		        {
		            new string3[128], str4[128], str5[128];
	           //     new factionpay = random(30000);
					format(string3, sizeof(string3), "Salary: $%d", factionpay);
					SendClientMessage(i, -1, string3);
					format(str5, sizeof(str5), "Taxes: $%d", tax);
					SendClientMessage(i, -1, str5);
					format(string2, sizeof(string2), "Your paycheck: $%d", payday);
					SendClientMessage(i, -1, string2);
					SendClientMessage(i, -1, "--------------------------------");
		   			format(str4, sizeof(str4), "Total payday: $%d", total);
		   			SendClientMessage(i, -1, str4);
		   			PlayerInfo[i][pBank] += total;
					return 1;
		        }
		        else if(PlayerInfo[i][pFacRank] == 6)
		        {
		            new string3[128], str4[128], str5[128], str6[128];
	           //     new factionpay = random(30000);
					format(string3, sizeof(string3), "Salary: $%d", factotal2);
					SendClientMessage(i, -1, string3);
					format(str5, sizeof(str5), "Taxes: $%d", tax);
					SendClientMessage(i, -1, str5);
					format(string2, sizeof(string2), "Your paycheck: $%d", payday);
					SendClientMessage(i, -1, string2);
					SendClientMessage(i, -1, "--------------------------------");
		   			format(str4, sizeof(str4), "Total payday: $%d", total);
		   			SendClientMessage(i, -1, str4);
		   			format(str6, sizeof(str6), "New account balance: $%d", PlayerInfo[i][pBank]);
		   			SendClientMessage(i, -1, str6);
		   			PlayerInfo[i][pBank] += factotal2;
					return 1;
		        }
	    	}
	    	else
	    	{
		        new str3[128], str4[128];
	        //    new factionpay = random(30000);
		    	format(string2, sizeof(string2), "Your paycheck: $%d", payday);
		    	SendClientMessage(i, -1, string2);
		    	format(str3, sizeof(str3), "Taxes: $%d", tax2);
		        SendClientMessage(i, -1, str3);
		    	SendClientMessage(i, -1, "--------------------------------");
		    	format(str4, sizeof(str4), "Total: $%d", total2);
		    	SendClientMessage(i, -1, str4);
		    	PlayerInfo[i][pBank] += total;
	    	}
	    	SendClientMessage(i, -1, "---------------------------------------------------");
	   		// GivePlayerMoney(i,payday);
   		}
	}
    return 1;
}
Full code: http://pastebin.com/dPUZBrWc

Please could someone help me fix this.
Thanks
Reply
#2

The error comes because you have
pawn Код:
return 1;
at the end of every option. Your code basically does this:
Send ID:0 his paycheck depending on his faction and rank and then return.

This basically stops the loop. To fix this issue; remove all of the
pawn Код:
return 1;
at the end of each option. That way it will send that player his paycheck; and then move onto ID:1.

Example:
pawn Код:
if(PlayerInfo[i][pFaction] == 1)
            {
                if(PlayerInfo[i][pFacRank] == 1)
                {
                    new string3[128], str4[128], str5[128];
                 //   new factionpay = random(30000);
                    format(string3, sizeof(string3), "Salary: $%d", factionpay);
                    SendClientMessage(i, -1, string3);
                    format(str5, sizeof(str5), "Taxes: $%d", tax);
                    SendClientMessage(i, -1, str5);
                    format(string2, sizeof(string2), "Your paycheck: $%d", payday);
                    SendClientMessage(i, -1, string2);
                    SendClientMessage(i, -1, "--------------------------------");
                    format(str4, sizeof(str4), "Total payday: $%d", total);
                    SendClientMessage(i, -1, str4);
                    PlayerInfo[i][pBank] += total;
                    return 1;
                }
Should become
pawn Код:
if(PlayerInfo[i][pFaction] == 1)
            {
                if(PlayerInfo[i][pFacRank] == 1)
                {
                    new string3[128], str4[128], str5[128];
                 //   new factionpay = random(30000);
                    format(string3, sizeof(string3), "Salary: $%d", factionpay);
                    SendClientMessage(i, -1, string3);
                    format(str5, sizeof(str5), "Taxes: $%d", tax);
                    SendClientMessage(i, -1, str5);
                    format(string2, sizeof(string2), "Your paycheck: $%d", payday);
                    SendClientMessage(i, -1, string2);
                    SendClientMessage(i, -1, "--------------------------------");
                    format(str4, sizeof(str4), "Total payday: $%d", total);
                    SendClientMessage(i, -1, str4);
                    PlayerInfo[i][pBank] += total;
                }
Reply
#3

Thank you so much! Been going threw it for days now and couldnt fix it but didnt noticed I put the return 1;

+Rep
Reply
#4

Np
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)