15.07.2016, 16:40
Avoid repeating large chunks of almost identical code and use some variables instead. Rewritten:
And for your sake, I hope you don't still have it in OnPlayerUpdate.
PHP код:
public payday(playerid)
{
for(new i = 0, j = GetPlayerPoolSize(); i <= j; i++)
{
if(!IsPlayerConnected(i))
continue;
new
money,
message[100];
switch(PlayerInfo[playerid][PayDay])
{
case 1: money = 3500;
case 2: money = 1500;
case 3: money = 750;
default: money = 500;
}
GivePlayerMoney(i, money);
SendClientMessage(i, COLOR_GREEN, "_______ BANK OF LOS SANTOS _______ ");
format(message, sizeof message, "BANK:{FFFFFF} You've received $%d from the goverment.", money);
SendClientMessage(i, COLOR_GREEN, message);
if(PlayerInfo[playerid][PayDay] <= 3)
{
format(message, sizeof message, "[ ! ] SERVER: As a new player, with play time: [ %d ]. You've been given $%d.", PlayerInfo[playerid][PayDay], money);
SendClientMessage(i, COLOR_LIGHTRED, message);
}
else
{
SendClientMessage(i, COLOR_LIGHTRED, "[ ! ] SERVER: As a normal player, you'll only be given 500$.");
SendClientMessage(i, COLOR_LIGHTRED, "[ ! ] SERVER: If you wish a raisen paycheck. Check forums donation section.");
}
SendClientMessage(i, COLOR_GREEN, "___________________________________");
format(message, sizeof message, "~w~PAYDAY, USD %d.", money);
GameTextForPlayer(i, message, 5000, 4);
}
printf("SERVER: Payday has been executed. :)");
return 1;
}