SA-MP Forums Archive
PayDay problem - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: PayDay problem (/showthread.php?tid=159875)



PayDay problem - Willow - 14.07.2010

Hi, I have serious problem with my payday function..

(my payday function below) Problem is: when I put return 1; under the function - payday dont work, but if I dont put return 1;, it works, but the function gets call every milisecond... I have settimerex under my onplayerlogin..

Код:
forward PayDay(playerid);
public PayDay(playerid)
{
	for(new i=0; i < MAX_PLAYERS; i++)
 	{
 	    new bmoney;
	 	new string[200];
	 	format(string, sizeof(string), "~p~payday!");
		GameTextForPlayer(i,string,7000,6);
 	    if(gTeam[i] == POLICE) { PMoney[i] = 1000 * Rank[i]; }
 	    else if(gTeam[i] == FBI) { PMoney[i] = 2000 * Rank[i]; }
 	    else if(gTeam[i] == MEDIC) { PMoney[i] = 800 * Rank[i]; }
 	    else if(gTeam[i] == TAXLIM) { PMoney[i] = 500 * Rank[i]; }
		else if(gTeam[i] == WARRIORS) { PMoney[i] = 700 * Rank[i]; }
 	    else if(gTeam[i] == KNIGHT) { PMoney[i] = 700 * Rank[i]; }
 	    else if(gTeam[i] == YAKUZA) { PMoney[i] = 700 * Rank[i]; }
		if(Rank[i] == 6) { PMoney[i] += 1000; }
		TaxMoney[i] = PMoney[i] / 100 * 5;
		bmoney = PBAccount[i] / 100 * 1 + PBAccount[i];
 		SendClientMessage(i, COLOR_GREEN, "||----- Payday -----||");
		format(string, sizeof(string),  "|| salary: %d 		  ||", PMoney[i]);
		SendClientMessage(i, COLOR_WHITE, string);
		format(string, sizeof(string),  "|| other: %d 		  ||", PayCheck[i]);
		SendClientMessage(i, COLOR_WHITE, string);
		format(string, sizeof(string),  "|| Tax: %d (5 percent) ||", TaxMoney[i]);
		SendClientMessage(i, COLOR_WHITE, string);
		format(string, sizeof(string),  "|| Bank: %d (+1 percent) ||", bmoney);
		SendClientMessage(i, COLOR_WHITE, string);
		SendClientMessage(i, COLOR_GREEN, "||-----------------------||");
		GivePlayerMoney(i, PMoney[i]);
		GivePlayerMoney(i, PayCheck[i]);
		GivePlayerMoney(i, -TaxMoney[i]);
		//GivePlayerMoney(i, -Drugs[i]);
		if(WantedLevel[i] >= 1) { WantedLevel[i] -= 1; }
		if(GetPlayerMoney(i) < 0) { SetPlayerInJail(i); IsInDebt[i] = 1; }
		RespectPoints[i] += 1;
		PayCheck[i] = 0;
		print("payday"); // this is the return 1 im talking about
		return 1;
	}
	return 1;
}



Re: PayDay problem - Finn - 14.07.2010

You have print("payday"); in a loop. Try putting it AFTER the loop, right at the second return you have in your code.

Also remove the return from the loop or it won't work for other players than ID 0.


Re: PayDay problem - bigcomfycouch - 14.07.2010

Why are you looping through all players if it's the payday for only a single player (based on your parameters)?