Paycheck system not working Logs here
#1

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:

PHP код:
[20:41:17] [debugRun 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] [debugAMX 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 
function that is called by command /darpaycheck:
PHP код:
public:PayDay2()
{
    for(new 
050i++)
    {
        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(ipaytext0[i]);
                                
TextDrawShowForPlayer(ipaytext1[i]);
                                
TextDrawShowForPlayer(ipaytext2[i]);
                                
TextDrawShowForPlayer(ipaytext3[i]);
                                
TextDrawShowForPlayer(ipaytext4[i]);
                                
TextDrawShowForPlayer(ipaytext5[i]);
                                
TextDrawShowForPlayer(ipaytext6[i]);
                                
TextDrawShowForPlayer(ipaytext7[i]);
                                
TextDrawShowForPlayer(ipaytext8[i]);
                                
TextDrawShowForPlayer(ipaytext9[i]);
                                
TextDrawShowForPlayer(ipaytext10[i]);
                                
TextDrawShowForPlayer(ipaytext11[i]);
                                
TextDrawShowForPlayer(ipaytext12[i]);
                                
TextDrawShowForPlayer(ipaytext13[i]);
                                
TextDrawShowForPlayer(ipaytext14[i]);
                                
TextDrawShowForPlayer(ipaytext15[i]);
                                
TextDrawShowForPlayer(ipaytext16[i]);
                                
TextDrawShowForPlayer(ipaytext17[i]);
                                
TextDrawShowForPlayer(ipaytext18[i]);
                                
TextDrawShowForPlayer(ipaytext19[i]);
                                
TextDrawShowForPlayer(ipaytext20[i]);
                                
TextDrawShowForPlayer(ipaytext21[i]);
                                
TextDrawShowForPlayer(ipaytext22[i]);
                                
TextDrawShowForPlayer(ipaytext23[i]);
                                
TextDrawShowForPlayer(ipaytext24[i]);
                                
TextDrawShowForPlayer(ipaytext27[i]);
                                
TextDrawShowForPlayer(ipaytext28[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(wstringsizeof(wstring), "PARABENS!!!! Й o teu aniversбrio, fizeste agora %d anos!"PlayerInfo[i][pAge]);
                                        
SendClientMessage(i,COLOR_WHITE,wstring);
                                    }
                                    else if(
PlayerInfo[i][pMeses] > && PlayerInfo[i][pMeses] < 12)
                                    {
                                        
format(wstringsizeof(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 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(wstringsizeof(wstring), "Bonus Vip:$%d [ Golds restantes: %d]"randvipcheckPlayerInfo[i][pVipActive]);
                              
SendClientMessage(i,COLOR_LIGHTYELLOW2wstring);
                        }
                        if(
PlayerInfo[i][pFaction] != 255)
                        {
                            new 
GetFaction DynamicFactions[PlayerInfo[i][pFaction]][fType];
                            if(
GetFaction == || GetFaction == || GetFaction == || GetFaction == || GetFaction == 6)
                            {
                                 if(
rank == 1)
                                {
                                    
PlayerInfo[i][pBank] += DynamicFactionsSalary[faction][fSalary1];
                                    
DynamicFactions[faction][fBank]-=DynamicFactionsSalary[faction][fSalary1];
                                    
salariofac[i] = DynamicFactionsSalary[faction][fSalary1];
                                    
format(wstringsizeof(wstring), "Salario: $%d [ Rank: %s ] [Balanзo Faction:$%d ]"DynamicFactionsSalary[faction][fSalary1], DynamicFactions[faction][fRank1], DynamicFactions[faction][fBank]);
                                    
SendClientMessage(i,COLOR_LIGHTYELLOW2wstring);
                                }
                                 else if(
rank == 2)
                                {
                                    
PlayerInfo[i][pBank] += DynamicFactionsSalary[faction][fSalary2];
                                    
DynamicFactions[faction][fBank]-= DynamicFactionsSalary[faction][fSalary2];
                                    
salariofac[i] = DynamicFactionsSalary[faction][fSalary2];
                                    
format(wstringsizeof(wstring), "Salario: $%d [ Rank: %s ] [Balanзo Faction:$%d ]"DynamicFactionsSalary[faction][fSalary2], DynamicFactions[faction][fRank2], DynamicFactions[faction][fBank]);
                                    
SendClientMessage(i,COLOR_LIGHTYELLOW2wstring);
                                }
                                 else if(
rank == 3)
                                {
                                    
PlayerInfo[i][pBank] += DynamicFactionsSalary[faction][fSalary3];
                                    
DynamicFactions[faction][fBank]-= DynamicFactionsSalary[faction][fSalary3];
                                    
salariofac[i] = DynamicFactionsSalary[faction][fSalary3];
                                    
format(wstringsizeof(wstring), "Salario: $%d [ Rank: %s ] "DynamicFactionsSalary[faction][fSalary3], DynamicFactions[faction][fRank3]);
                                    
SendClientMessage(i,COLOR_LIGHTYELLOW2wstring);
                                }
                                 else if(
rank == 4)
                                {
                                    
PlayerInfo[i][pBank] += DynamicFactionsSalary[faction][fSalary4];
                                    
DynamicFactions[faction][fBank]-= DynamicFactionsSalary[faction][fSalary4];
                                    
salariofac[i] = DynamicFactionsSalary[faction][fSalary4];
                                    
format(wstringsizeof(wstring), "Salario: $%d [ Rank: %s ] "DynamicFactionsSalary[faction][fSalary4], DynamicFactions[faction][fRank4]);
                                    
SendClientMessage(i,COLOR_LIGHTYELLOW2wstring);
                                }
                                 else if(
rank == 5)
                                {
                                    
PlayerInfo[i][pBank] += DynamicFactionsSalary[faction][fSalary5];
                                    
DynamicFactions[faction][fBank]-= DynamicFactionsSalary[faction][fSalary5];
                                    
salariofac[i] = DynamicFactionsSalary[faction][fSalary5];
                                    
format(wstringsizeof(wstring), "Salario: $%d [ Rank: %s ] "DynamicFactionsSalary[faction][fSalary5], DynamicFactions[faction][fRank5]);
                                    
SendClientMessage(i,COLOR_LIGHTYELLOW2wstring);
                                }
                                 else if(
rank == 6)
                                {
                                    
PlayerInfo[i][pBank] += DynamicFactionsSalary[faction][fSalary6];
                                    
DynamicFactions[faction][fBank]-= DynamicFactionsSalary[faction][fSalary6];
                                    
salariofac[i] = DynamicFactionsSalary[faction][fSalary6];
                                    
format(wstringsizeof(wstring), "Salario: $%d [ Rank: %s ] "DynamicFactionsSalary[faction][fSalary6], DynamicFactions[faction][fRank6]);
                                    
SendClientMessage(i,COLOR_LIGHTYELLOW2wstring);
                                }
                                 else if(
rank == 7)
                                {
                                    
PlayerInfo[i][pBank] += DynamicFactionsSalary[faction][fSalary7];
                                    
DynamicFactions[faction][fBank]-= DynamicFactionsSalary[faction][fSalary7];
                                    
salariofac[i] = DynamicFactionsSalary[faction][fSalary7];
                                    
format(wstringsizeof(wstring), "Salario: $%d [ Rank: %s ] "DynamicFactionsSalary[faction][fSalary7], DynamicFactions[faction][fRank7]);
                                    
SendClientMessage(i,COLOR_LIGHTYELLOW2wstring);
                                }
                                 else if(
rank == 8)
                                {
                                    
PlayerInfo[i][pBank] += DynamicFactionsSalary[faction][fSalary8];
                                    
DynamicFactions[faction][fBank]-= DynamicFactionsSalary[faction][fSalary8];
                                    
salariofac[i] = DynamicFactionsSalary[faction][fSalary8];
                                    
format(wstringsizeof(wstring), "Salario: $%d [ Rank: %s ] "DynamicFactionsSalary[faction][fSalary8], DynamicFactions[faction][fRank8]);
                                    
SendClientMessage(i,COLOR_LIGHTYELLOW2wstring);
                                }
                                 else if(
rank == 9)
                                {
                                    
PlayerInfo[i][pBank] += DynamicFactionsSalary[faction][fSalary9];
                                    
DynamicFactions[faction][fBank]-= DynamicFactionsSalary[faction][fSalary9];
                                    
salariofac[i] = DynamicFactionsSalary[faction][fSalary9];
                                    
format(wstringsizeof(wstring), "Salario: $%d [ Rank: %s ] "DynamicFactionsSalary[faction][fSalary9], DynamicFactions[faction][fRank9]);
                                    
SendClientMessage(i,COLOR_LIGHTYELLOW2wstring);
                                }
                                 else if(
rank == 10)
                                {
                                    
PlayerInfo[i][pBank] += DynamicFactionsSalary[faction][fSalary10];
                                    
DynamicFactions[faction][fBank]-= DynamicFactionsSalary[faction][fSalary10];
                                    
salariofac[i] = DynamicFactionsSalary[faction][fSalary10];
                                    
format(wstringsizeof(wstring), "Salario: $%d [ Rank: %s ] "DynamicFactionsSalary[faction][fSalary10], DynamicFactions[faction][fRank10]);
                                    
SendClientMessage(i,COLOR_LIGHTYELLOW2wstring);
                                }
                            }
                        }
                        new 
nxtlevel PlayerInfo[i][pLevel]+1;
                        new 
expamount nxtlevel*3;
                        if(
PlayerInfo[i][pExp] == expamount)
                        {
                               
format(wstringsizeof(wstring), "Boa! Mudaste de nivel! - Novo nivel: %d."nxtlevel);
                            
SendClientMessage(i,COLOR_LIGHTYELLOW2wstring);
                            
PlayerInfo[i][pLevel]++;
                               
format(wstringsizeof(wstring), "O teu proximo alvo й %d pontos de expriencia."expamount);
                            
SendClientMessage(i,COLOR_LIGHTYELLOW2wstring);
                            
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(expsizeof(exp), "%d/%d",PlayerInfo[i][pExp],expamount);
                                        
TextDrawSetString(paytext12[i], exp);
                                        new 
irs[128];
                                        
format(irssizeof(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(num1sizeof(num1), "%d"PlayerNumber[0][i]);
                                        
format(num2sizeof(num2), "%d"PlayerNumber[1][i]);
                                        
format(num3sizeof(num3), "%d"PlayerNumber[2][i]);
                                        
format(num4sizeof(num4), "%d"PlayerNumber[3][i]);
                                        
format(num5sizeof(num5), "%d"PlayerNumber[4][i]);
                                        
format(star1sizeof(star1), "%d"PlayerStar[0][i]);
                                        
format(star2sizeof(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"10000false"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;

Reply
#2

You go through a 50 loop up top, then set MAX_PLAYERS under it.

Should use GetPlayerPoolSize to make the loop and the subsequent array for the players.

MAX_PLAYERS = 500, Your loop = 50.

Even though chances are this has nothing to do with it.


Are you also using the right compiler options for CrashDetect?
Reply
#3

I have put crashdetect on compiler debug and it showed me the line. It was not what you said but thanks for trying to help. It was

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;
}

it should look for a player key first and it did not. So house limit is 254 and many have 255 in house key that means they dont have any house. Thats what was causing the problem

its fixed now. Thanks everyone for helping
Reply
#4

Good stuff, and good for you to come back and state what it was...
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)