15.08.2016, 01:12
Hi guys,
So my paycheck system only works properly for id 0 and then doesnt work for anyone else and i get this on the logs:
function that is called by command /darpaycheck:
So my paycheck system only works properly for id 0 and then doesnt work for anyone else and i get this on the logs:
PHP код:
[20:41:17] [debug] Run time error 4: "Array index out of bounds"
[20:41:17] [debug] Accessing element at index 255 past array upper bound 254
[20:41:17] [debug] AMX backtrace:
[20:41:17] [debug] #0 002e0770 in public PayDay2 () from I-RP.amx
[20:41:17] [debug] #1 0015bfcc in public OnPlayerCommandText (2, 5653488) from I-RP.amx
PHP код:
public:PayDay2()
{
for(new i = 0; i < 50; i++)
{
if(IsPlayerConnected(i))
{
if(gPlayerLogged[i] == 1)
{
if(PlayerInfo[i][pContBank] == 0)
{
SendClientMessage(i,COLOR_RED,"{FF0000}[Erro]: {FFFFFF}Infelizmente nгo criaste conta bancбria, logo nгo recebeste paycheck!");
}
else
{
new wstring[113];
new randcheck = 300 + random(650);
new randvipcheck = 1500 + random(1500);
new interest = (PlayerInfo[i][pBank]/1000)*(intrate);
new randtax = cash5;
new rotas[MAX_PLAYERS];
new salariofac[MAX_PLAYERS];
new faction = PlayerInfo[i][pFaction];
new rank = PlayerInfo[i][pRank];
PlayerPlayMusic(i);
Plantardn[i] = 0;
TextDrawShowForPlayer(i, paytext0[i]);
TextDrawShowForPlayer(i, paytext1[i]);
TextDrawShowForPlayer(i, paytext2[i]);
TextDrawShowForPlayer(i, paytext3[i]);
TextDrawShowForPlayer(i, paytext4[i]);
TextDrawShowForPlayer(i, paytext5[i]);
TextDrawShowForPlayer(i, paytext6[i]);
TextDrawShowForPlayer(i, paytext7[i]);
TextDrawShowForPlayer(i, paytext8[i]);
TextDrawShowForPlayer(i, paytext9[i]);
TextDrawShowForPlayer(i, paytext10[i]);
TextDrawShowForPlayer(i, paytext11[i]);
TextDrawShowForPlayer(i, paytext12[i]);
TextDrawShowForPlayer(i, paytext13[i]);
TextDrawShowForPlayer(i, paytext14[i]);
TextDrawShowForPlayer(i, paytext15[i]);
TextDrawShowForPlayer(i, paytext16[i]);
TextDrawShowForPlayer(i, paytext17[i]);
TextDrawShowForPlayer(i, paytext18[i]);
TextDrawShowForPlayer(i, paytext19[i]);
TextDrawShowForPlayer(i, paytext20[i]);
TextDrawShowForPlayer(i, paytext21[i]);
TextDrawShowForPlayer(i, paytext22[i]);
TextDrawShowForPlayer(i, paytext23[i]);
TextDrawShowForPlayer(i, paytext24[i]);
TextDrawShowForPlayer(i, paytext27[i]);
TextDrawShowForPlayer(i, paytext28[i]);
if(PlayerInfo[i][pQuinzedias] == 2)
{
PlayerInfo[i][pQuinzedias] = 0;
PlayerInfo[i][pMeses]++;
if(PlayerInfo[i][pMeses] == 12)
{
PlayerInfo[i][pMeses] = 0;
PlayerInfo[i][pAge]++;
format(wstring, sizeof(wstring), "PARABENS!!!! Й o teu aniversбrio, fizeste agora %d anos!", PlayerInfo[i][pAge]);
SendClientMessage(i,COLOR_WHITE,wstring);
}
else if(PlayerInfo[i][pMeses] > 0 && PlayerInfo[i][pMeses] < 12)
{
format(wstring, sizeof(wstring), "Tens agora %d anos e %d meses.", PlayerInfo[i][pAge], PlayerInfo[i][pMeses]);
SendClientMessage(i,COLOR_WHITE,wstring);
}
}
if(PlayerInfo[i][pNRotasE] >= 1)
{
new price;
if(PlayerInfo[i][pCursEng] == 1)
{
price = 100*PlayerInfo[i][pNivelJob];
}
else
{
price = 50*PlayerInfo[i][pNivelJob];
}
PlayerInfo[i][pBank] += price*PlayerInfo[i][pNRotasE];
rotas[i] = price*PlayerInfo[i][pNRotasE];
PlayerInfo[i][pNRotasE] = 0;
}
new succeed = 1 + random(40);
if(succeed == 1)
{
PlayerInfo[i][pGripe] = 1;
}
else if(succeed == 2)
{
PlayerInfo[i][pDoresDeCabeca] = 1;
}
else if(succeed == 3)
{
PlayerInfo[i][pDiaReia] = 1;
}
if(PlayerInfo[i][pEmprestimo] > 0)
{
new EDE = PlayerInfo[i][pEmprestimoC];
PlayerInfo[i][pEmprestimo] = PlayerInfo[i][pEmprestimo] - 1000;
PlayerInfo[i][pBank] -= 1000;
Businesses[EDE][Till] = Businesses[EDE][Till] + 1000;
if(PlayerInfo[i][pEmprestimo] <= 0)
{
PlayerInfo[i][pEmprestimo] = 0;
PlayerInfo[i][pEmprestimoC] = 255;
}
}
if(PlayerInfo[i][pAluguer] >= 1)
{
new PDAC = PlayerInfo[i][pAluguer];
new CDCA = PlayerInfo[i][pHouseKey];
PlayerInfo[i][pBank] -= PDAC;
Houses[CDCA][Money] = Houses[CDCA][Money] + PDAC;
}
PlayerInfo[i][pBank] += interest;
PlayerInfo[i][pBank] -= randtax;
PlayerInfo[i][pBank] += randcheck;
PlayerInfo[i][pPayCheck] = 0;
PlayerInfo[i][pExp]++;
PlayerInfo[i][pPlayingHours] += 1;
DynamicFactions[6][fBank] += randtax;
if(PlayerInfo[i][pVipActive] != 0)
{
PlayerInfo[i][pBank] += randvipcheck;
PlayerInfo[i][pVipActive] = PlayerInfo[i][pVipActive] - 1;
format(wstring, sizeof(wstring), "Bonus Vip:$%d [ Golds restantes: %d]", randvipcheck, PlayerInfo[i][pVipActive]);
SendClientMessage(i,COLOR_LIGHTYELLOW2, wstring);
}
if(PlayerInfo[i][pFaction] != 255)
{
new GetFaction = DynamicFactions[PlayerInfo[i][pFaction]][fType];
if(GetFaction == 1 || GetFaction == 2 || GetFaction == 3 || GetFaction == 4 || GetFaction == 6)
{
if(rank == 1)
{
PlayerInfo[i][pBank] += DynamicFactionsSalary[faction][fSalary1];
DynamicFactions[faction][fBank]-=DynamicFactionsSalary[faction][fSalary1];
salariofac[i] = DynamicFactionsSalary[faction][fSalary1];
format(wstring, sizeof(wstring), "Salario: $%d [ Rank: %s ] [Balanзo Faction:$%d ]", DynamicFactionsSalary[faction][fSalary1], DynamicFactions[faction][fRank1], DynamicFactions[faction][fBank]);
SendClientMessage(i,COLOR_LIGHTYELLOW2, wstring);
}
else if(rank == 2)
{
PlayerInfo[i][pBank] += DynamicFactionsSalary[faction][fSalary2];
DynamicFactions[faction][fBank]-= DynamicFactionsSalary[faction][fSalary2];
salariofac[i] = DynamicFactionsSalary[faction][fSalary2];
format(wstring, sizeof(wstring), "Salario: $%d [ Rank: %s ] [Balanзo Faction:$%d ]", DynamicFactionsSalary[faction][fSalary2], DynamicFactions[faction][fRank2], DynamicFactions[faction][fBank]);
SendClientMessage(i,COLOR_LIGHTYELLOW2, wstring);
}
else if(rank == 3)
{
PlayerInfo[i][pBank] += DynamicFactionsSalary[faction][fSalary3];
DynamicFactions[faction][fBank]-= DynamicFactionsSalary[faction][fSalary3];
salariofac[i] = DynamicFactionsSalary[faction][fSalary3];
format(wstring, sizeof(wstring), "Salario: $%d [ Rank: %s ] ", DynamicFactionsSalary[faction][fSalary3], DynamicFactions[faction][fRank3]);
SendClientMessage(i,COLOR_LIGHTYELLOW2, wstring);
}
else if(rank == 4)
{
PlayerInfo[i][pBank] += DynamicFactionsSalary[faction][fSalary4];
DynamicFactions[faction][fBank]-= DynamicFactionsSalary[faction][fSalary4];
salariofac[i] = DynamicFactionsSalary[faction][fSalary4];
format(wstring, sizeof(wstring), "Salario: $%d [ Rank: %s ] ", DynamicFactionsSalary[faction][fSalary4], DynamicFactions[faction][fRank4]);
SendClientMessage(i,COLOR_LIGHTYELLOW2, wstring);
}
else if(rank == 5)
{
PlayerInfo[i][pBank] += DynamicFactionsSalary[faction][fSalary5];
DynamicFactions[faction][fBank]-= DynamicFactionsSalary[faction][fSalary5];
salariofac[i] = DynamicFactionsSalary[faction][fSalary5];
format(wstring, sizeof(wstring), "Salario: $%d [ Rank: %s ] ", DynamicFactionsSalary[faction][fSalary5], DynamicFactions[faction][fRank5]);
SendClientMessage(i,COLOR_LIGHTYELLOW2, wstring);
}
else if(rank == 6)
{
PlayerInfo[i][pBank] += DynamicFactionsSalary[faction][fSalary6];
DynamicFactions[faction][fBank]-= DynamicFactionsSalary[faction][fSalary6];
salariofac[i] = DynamicFactionsSalary[faction][fSalary6];
format(wstring, sizeof(wstring), "Salario: $%d [ Rank: %s ] ", DynamicFactionsSalary[faction][fSalary6], DynamicFactions[faction][fRank6]);
SendClientMessage(i,COLOR_LIGHTYELLOW2, wstring);
}
else if(rank == 7)
{
PlayerInfo[i][pBank] += DynamicFactionsSalary[faction][fSalary7];
DynamicFactions[faction][fBank]-= DynamicFactionsSalary[faction][fSalary7];
salariofac[i] = DynamicFactionsSalary[faction][fSalary7];
format(wstring, sizeof(wstring), "Salario: $%d [ Rank: %s ] ", DynamicFactionsSalary[faction][fSalary7], DynamicFactions[faction][fRank7]);
SendClientMessage(i,COLOR_LIGHTYELLOW2, wstring);
}
else if(rank == 8)
{
PlayerInfo[i][pBank] += DynamicFactionsSalary[faction][fSalary8];
DynamicFactions[faction][fBank]-= DynamicFactionsSalary[faction][fSalary8];
salariofac[i] = DynamicFactionsSalary[faction][fSalary8];
format(wstring, sizeof(wstring), "Salario: $%d [ Rank: %s ] ", DynamicFactionsSalary[faction][fSalary8], DynamicFactions[faction][fRank8]);
SendClientMessage(i,COLOR_LIGHTYELLOW2, wstring);
}
else if(rank == 9)
{
PlayerInfo[i][pBank] += DynamicFactionsSalary[faction][fSalary9];
DynamicFactions[faction][fBank]-= DynamicFactionsSalary[faction][fSalary9];
salariofac[i] = DynamicFactionsSalary[faction][fSalary9];
format(wstring, sizeof(wstring), "Salario: $%d [ Rank: %s ] ", DynamicFactionsSalary[faction][fSalary9], DynamicFactions[faction][fRank9]);
SendClientMessage(i,COLOR_LIGHTYELLOW2, wstring);
}
else if(rank == 10)
{
PlayerInfo[i][pBank] += DynamicFactionsSalary[faction][fSalary10];
DynamicFactions[faction][fBank]-= DynamicFactionsSalary[faction][fSalary10];
salariofac[i] = DynamicFactionsSalary[faction][fSalary10];
format(wstring, sizeof(wstring), "Salario: $%d [ Rank: %s ] ", DynamicFactionsSalary[faction][fSalary10], DynamicFactions[faction][fRank10]);
SendClientMessage(i,COLOR_LIGHTYELLOW2, wstring);
}
}
}
new nxtlevel = PlayerInfo[i][pLevel]+1;
new expamount = nxtlevel*3;
if(PlayerInfo[i][pExp] == expamount)
{
format(wstring, sizeof(wstring), "Boa! Mudaste de nivel! - Novo nivel: %d.", nxtlevel);
SendClientMessage(i,COLOR_LIGHTYELLOW2, wstring);
PlayerInfo[i][pLevel]++;
format(wstring, sizeof(wstring), "O teu proximo alvo й %d pontos de expriencia.", expamount);
SendClientMessage(i,COLOR_LIGHTYELLOW2, wstring);
PlayerInfo[i][pExp] = 0;
}
if ((aevento) == 1)
{
PlayerInfo[i][pBank] += 200;
SendClientMessage(i,COLOR_GREEN, "[EVENTO]: Recebeste um bonus de 200$ graзas ao evento");
}
new salariofinal;
salariofinal = randcheck + salariofac[i] + rotas[i];
new salario[128];
format(salario,sizeof(salario), "%d", salariofinal);
TextDrawSetString(paytext10[i], salario);
new novobalanco[128];
format(novobalanco,sizeof(novobalanco), "%d", PlayerInfo[i][pBank]);
TextDrawSetString(paytext11[i], novobalanco);
new exp[128];
format(exp, sizeof(exp), "%d/%d",PlayerInfo[i][pExp],expamount);
TextDrawSetString(paytext12[i], exp);
new irs[128];
format(irs, sizeof(irs),"-%d", randtax);
TextDrawSetString(paytext13[i], irs);
if(PlayerInfo[i][pEmprestimo] > 0)
{
TextDrawSetString(paytext14[i], "-1000$");
}
else
{
TextDrawSetString(paytext14[i], "0$");
}
new renda[128];
format(renda,sizeof(renda), "-%d", PlayerInfo[i][pAluguer]);
TextDrawSetString(paytext15[i], renda);
new num1[128];
new num2[128];
new num3[128];
new num4[128];
new num5[128];
new star1[128];
new star2[128];
format(num1, sizeof(num1), "%d", PlayerNumber[0][i]);
format(num2, sizeof(num2), "%d", PlayerNumber[1][i]);
format(num3, sizeof(num3), "%d", PlayerNumber[2][i]);
format(num4, sizeof(num4), "%d", PlayerNumber[3][i]);
format(num5, sizeof(num5), "%d", PlayerNumber[4][i]);
format(star1, sizeof(star1), "%d", PlayerStar[0][i]);
format(star2, sizeof(star2), "%d", PlayerStar[1][i]);
TextDrawSetString(paytext18[i], num1);
TextDrawSetString(paytext19[i], num2);
TextDrawSetString(paytext20[i], num3);
TextDrawSetString(paytext21[i], num4);
TextDrawSetString(paytext22[i], num5);
TextDrawSetString(paytext23[i], star1);
TextDrawSetString(paytext24[i], star2);
SetTimerEx("paynovo", 10000, false, "i", i);
}
}
else
{
SendClientMessage(i,COLOR_WHITE,"{1E90FF}[INFO]: {FFFFFF} Nгo jogaste tempo suficiente para receberes o paycheck.");
}
}
else
{
SendClientMessage(i,COLOR_WHITE,"{1E90FF}[INFO]: {FFFFFF} Nao estas logado, nao recebeste o paycheck.");
}
}
return 1;
}