SA-MP Forums Archive
[Ajuda] Bug OnPlayerStateChange - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: Non-English (https://sampforum.blast.hk/forumdisplay.php?fid=9)
+--- Forum: Languages (https://sampforum.blast.hk/forumdisplay.php?fid=33)
+---- Forum: Português/Portuguese (https://sampforum.blast.hk/forumdisplay.php?fid=34)
+---- Thread: [Ajuda] Bug OnPlayerStateChange (/showthread.php?tid=674462)



Bug OnPlayerStateChange - Poseidon4625 - 20.04.2020

Pessoal estou tendo problema na callback, alguйm sabe oque pode ser?

PHP Code:
[02:21:28] [debugRun time error 4"Array index out of bounds"
[02:21:28] [debug]  Attempted to read/write array element at index 121 in array of size 121
[02:21:28] [debugAMX backtrace:
[
02:21:28] [debug#0 0003f840 in public OnPlayerStateChange (0, 2, 1) in Servidor.amx
[02:21:30] [debugRun time error 4"Array index out of bounds"
[02:21:30] [debug]  Attempted to read/write array element at index 121 in array of size 121
[02:21:30] [debugAMX backtrace:
[
02:21:30] [debug#0 0003f840 in public OnPlayerStateChange (1, 2, 1) in Servidor.amx
[02:24:48] [debugRun time error 4"Array index out of bounds"
[02:24:48] [debug]  Attempted to read/write array element at index 121 in array of size 121
[02:24:48] [debugAMX backtrace:
[
02:24:48] [debug#0 0003f840 in public OnPlayerStateChange (0, 2, 1) in Servidor.amx
[02:25:13] [debugRun time error 4"Array index out of bounds"
[02:25:13] [debug]  Attempted to read/write array element at index 121 in array of size 121
[02:25:13] [debugAMX backtrace:
[
02:25:13] [debug#0 0003f840 in public OnPlayerStateChange (1, 2, 1) in Servidor.amx 


se alguйm souber oque й, agradeзo.


PHP Code:
public OnPlayerStateChange(playeridnewstateoldstate)
{
    new 
Float:posicao[3];
    new 
modelo GetVehicleModel(GetPlayerVehicleID(playerid));
    if(
oldstate == PLAYER_STATE_ONFOOT && newstate == PLAYER_STATE_DRIVER)
    {
        
GetVehiclePos(GetPlayerVehicleID(playerid), v@_P[0][playerid], v@_P[1][playerid], v@_P[2][playerid]);
        
TSTimer[playerid] = SetTimerEx("E@_At"2000true"i"playerid);
    }
     if(
newstate == PLAYER_STATE_DRIVER)
    {
        if(
GetPlayerVehicleID(playerid) >= vehiclesI[0] && GetPlayerVehicleID(playerid) <= vehiclesI[sizeof(vehiclesI) - 1])
        {
            if(
PlayerInfo[playerid][pTransProf] != 1)return Ret(playerid);
        }
        if(
GetPlayerVehicleID(playerid) >= Motoboys[0] && GetPlayerVehicleID(playerid) <= Motoboys[sizeof(Motoboys) - 1])
        {
            if(
PlayerInfo[playerid][pProfissao] != 1)return Ret(playerid);
        }
        if(
GetPlayerVehicleID(playerid) >= EntregadorJ[0] && GetPlayerVehicleID(playerid) <= EntregadorJ[sizeof(EntregadorJ) - 1])
        {
            if(
PlayerInfo[playerid][pProfissao] != 2)return Ret(playerid);
        }
        if(
GetPlayerVehicleID(playerid) >= EntregadorC[0] && GetPlayerVehicleID(playerid) <= EntregadorC[sizeof(EntregadorC) - 1])
        {
            if(
PlayerInfo[playerid][pProfissao] != 3)return Ret(playerid);
        }
        if(
barcos(GetPlayerVehicleID(playerid)) ||avioes(GetPlayerVehicleID(playerid)) ||Motocicletas(GetPlayerVehicleID(playerid)) || carros(GetPlayerVehicleID(playerid)) || VeiculoDiesel(GetPlayerVehicleID(playerid)))
        {
            
SendClientMessage(playerid,Amarelo,"| INFO | Para Ligar ou Desligar o Veнculo Aperte 'Y'!");
            
ShowPlayerVelocimetro(playerid);
        }
    }else{
        
HidePlayerVelocimetro(playerid);
    }
    if(
oldstate == PLAYER_STATE_DRIVER)
    {
        new 
string[95];
        
GetVehicleParamsEx(GetPlayerVehicleID(playerid),engine,lights,alarm,doors,bonnet,boot,objective);
        if(
barcos(GetPlayerVehicleID(playerid)) ||avioes(GetPlayerVehicleID(playerid)) ||Motocicletas(GetPlayerVehicleID(playerid)) || carros(GetPlayerVehicleID(playerid)) || VeiculoDiesel(GetPlayerVehicleID(playerid)))
        {
            
SetVehicleParamsEx(GetPlayerVehicleID(playerid), VEHICLE_PARAMS_OFFlightsalarmdoorsbonnetbootobjective);
        }
        if(
NewGlobal[playerid] == 500)
        {
            if(
VeiculoDiesel(GetPlayerVehicleID(playerid)) || barcos(GetPlayerVehicleID(playerid)))
            {
                
format(stringsizeof (string),"| INFO | Vocк Abasteceu Alguns Litros de {FFF000}Diesel {FFFFFF}e Pagou {008000}$%d",GranaB[playerid]);
                
SendClientMessage(playerid, -1,string);
                
perexc(playerid);
            }
            if(
Motocicletas(GetPlayerVehicleID(playerid)) || carros(GetPlayerVehicleID(playerid)))
            {
                
format(stringsizeof (string),"| INFO | Vocк Abasteceu Alguns Litros de {FFF000}Gasolina {FFFFFF}e Pagou {008000}$%d",GranaB[playerid]);
                
SendClientMessage(playerid, -1,string);
                
perexc(playerid);
            }
            if(
avioes(GetPlayerVehicleID(playerid)))
            {
                
format(stringsizeof (string),"| INFO | Vocк Abasteceu Alguns Litros de {FFF000}QAV/1 {FFFFFF}e Pagou {008000}$%d",GranaB[playerid]);
                
SendClientMessage(playerid, -1,string);
                
perexc(playerid);
            }
        }
        if(
pegvehicle[playerid] == true)
        {
            
SendClientMessage(playerid,Amarelo,"| AVISO | Vocк Tem 90 Segundos Para Voltar ao Veнculo da Profissгo!");
            
TempProf[playerid] = SetTimerEx("CancelamentoProf"90000false"i"playerid);
            
Timer[6][playerid] = SetTimerEx("temps"1000true"i"playerid);
            
SetPVarInt(playerid,"SaiuVehicle",90);
        }
    }
    if(
newstate == PLAYER_STATE_DRIVER)
    {
        if(
modelo == 430 )
        {
            if(
PlayerInfo[playerid][pHELG] == false)
            {
                
SendClientMessage(playeridVermelho"| ERRO | Vocк Nгo Tem Habilitaзгo Especial 'HELG'!");
                
GetPlayerPos(playerid,posicao[0],posicao[1],posicao[2]);
                
SetPlayerPos(playerid,posicao[0],posicao[1],posicao[2]+1);
               }
        }
        if(
modelo == 476 || modelo == 520 || modelo == 425 || modelo == 548 || modelo == 447 )
        {
            if(
PlayerInfo[playerid][pHEAG] == false)
            {
                
SendClientMessage(playeridVermelho"| ERRO | Vocк Nгo Tem Habilitaзгo Especial 'HEAG'!");
                
GetPlayerPos(playerid,posicao[0],posicao[1],posicao[2]);
                
SetPlayerPos(playerid,posicao[0],posicao[1],posicao[2]+1);
               }
        }
        if(
modelo == 432 || modelo == 433 || modelo == 470 )
        {
            if(
PlayerInfo[playerid][pHEVG] == false)
            {
                
SendClientMessage(playeridVermelho"| ERRO | Vocк Nгo Tem Habilitaзгo Especial 'HEVG'!");
                
GetPlayerPos(playerid,posicao[0],posicao[1],posicao[2]);
                
SetPlayerPos(playerid,posicao[0],posicao[1],posicao[2]+1);
               }
        }
        if(
GetPVarInt(playerid,"TestO")>= 1)
        {
        }else{
            if(
modelo == 448 || modelo == 461 || modelo == 462 || modelo == 463 || modelo == 468 || modelo == 471 || modelo == 521 || modelo == 581 || modelo == 586)
            {
                 if(
PlayerInfo[playerid][pMotos] == false)
                {
                    
SendClientMessage(playeridVermelho"| ERRO | Vocк Nгo Tem Habilitaзгo Para Conduzir Motos!");
                    
GetPlayerPos(playerid,posicao[0],posicao[1],posicao[2]);
                    
SetPlayerPos(playerid,posicao[0],posicao[1],posicao[2]+1);
                }
            }
            if(
modelo == 403 || modelo == 406 || modelo == 443 || modelo == 514 || modelo == 515)
            {
                 if(
PlayerInfo[playerid][pCarretas] == false)
                {
                    
SendClientMessage(playeridVermelho"| ERRO | Vocк Nгo Tem Habilitaзгo Para Conduzir Carretas!");
                    
GetPlayerPos(playerid,posicao[0],posicao[1],posicao[2]);
                    
SetPlayerPos(playerid,posicao[0],posicao[1],posicao[2]+1);
                }
            }
            if(
modelo == 446 || modelo == 452 || modelo == 453 || modelo == 454 || modelo == 472 || modelo == 473 || modelo == 484 || modelo == 493 || modelo == 595)
            {
                 if(
PlayerInfo[playerid][pBarcos] == false)
                {
                    
SendClientMessage(playeridVermelho"| ERRO | Vocк Nгo Tem Habilitaзгo Para Conduzir Barcos!");
                    
GetPlayerPos(playerid,posicao[0],posicao[1],posicao[2]);
                    
SetPlayerPos(playerid,posicao[0],posicao[1],posicao[2]+1);
                }
            }
            if(
modelo == 460 || modelo == 511 || modelo == 512 || modelo == 513 || modelo == 519 || modelo == 553 || modelo == 577 || modelo == 592 || modelo == 593)
            {
                 if(
PlayerInfo[playerid][pAvioes] == false)
                {
                    
SendClientMessage(playeridVermelho"| ERRO | Vocк Nгo Tem Habilitaзгo Para Conduzir Aviхes!");
                    
GetPlayerPos(playerid,posicao[0],posicao[1],posicao[2]);
                    
SetPlayerPos(playerid,posicao[0],posicao[1],posicao[2]+1);
                }
            }
            if(
modelo == 417 || modelo == 447 || modelo == 469 || modelo == 487 || modelo == 488 || modelo == 497 || modelo == 548 || modelo == 563)
            {
                 if(
PlayerInfo[playerid][pHelicopteros] == false)
                {
                    
SendClientMessage(playeridVermelho"| ERRO | Vocк Nгo Tem Habilitaзгo Para Conduzir Helicуpteros!");
                    
GetPlayerPos(playerid,posicao[0],posicao[1],posicao[2]);
                    
SetPlayerPos(playerid,posicao[0],posicao[1],posicao[2]+1);
                }
            }
            if(
modelo == 431 || modelo == 437)
            {
                 if(
PlayerInfo[playerid][pOnibus] == false)
                {
                    
SendClientMessage(playeridVermelho"| ERRO | Vocк Nгo Tem Habilitaзгo Para Conduzir Фnibus!");
                    
GetPlayerPos(playerid,posicao[0],posicao[1],posicao[2]);
                    
SetPlayerPos(playerid,posicao[0],posicao[1],posicao[2]+1);
                }
            }
            if(
modelo == 407 || modelo == 428 || modelo == 427 || modelo == 455 || modelo == 456 || modelo == 443 || modelo == 408 || modelo == 424 || modelo == 478 || modelo == 609
            
|| modelo == 406 || modelo == 407 || modelo == 544 || modelo == 573 || modelo == 578 || modelo == 424 || modelo == 544)
            {
                 if(
PlayerInfo[playerid][pCaminhoes] == false)
                {
                    
SendClientMessage(playeridVermelho"| ERRO | Vocк Nгo Tem Habilitaзгo Para Conduzir Caminhхes!");
                    
GetPlayerPos(playerid,posicao[0],posicao[1],posicao[2]);
                    
SetPlayerPos(playerid,posicao[0],posicao[1],posicao[2]+1);
                }
            }
            for(new 
0122i++)
            {
                if(
modelo == VehiclesCarros[i])
                {
                    if(
PlayerInfo[playerid][pCarros] == false)
                    {
                        
SendClientMessage(playeridVermelho"| ERRO | Vocк Nгo Tem Habilitaзгo Para Conduzir Carros!");
                        
GetPlayerPos(playerid,posicao[0],posicao[1],posicao[2]);
                        
SetPlayerPos(playerid,posicao[0],posicao[1],posicao[2]+1);
                    }
                }
            }
            if((
GetTickCount() - GetPVarInt(playerid"cartime")) < 100)
            {
                
SetPVarInt(playerid"carspam"GetPVarInt(playerid"carspam") + 1);
                if(
GetPVarInt(playerid"carspam") >= 5)
                {
                    new 
cs_string[85 MAX_PLAYER_NAME],namePlayerState[MAX_PLAYER_NAME];
                    
GetPlayerName(playeridnamePlayerStatesizeof(namePlayerState));
                    
format(cs_string,sizeof(cs_string),"| INFO | O(A) Jogador(a) %s Foi Kickado(a) Pelo Anti-Cheater ( Motivo: Car Spam. )",namePlayerState);
                    
SendClientMessageToAll(Vermelho,cs_string);
                    return 
SavePlayer(playerid), Kick(playerid);
                }
            }
            
SetPVarInt(playerid"cartime"GetTickCount());
        }
    }
    return 
1;




Re: Bug OnPlayerStateChange - Poseidon4625 - 20.04.2020

alguйm?


Re: Bug OnPlayerStateChange - RiqueP - 20.04.2020

Normalmente esse erro é apontado quando você tenta acessar um valor de uma array maior do que o limite dela. Exemplo:
PHP Code:
new matriz[10];
matriz[12] = 1



Re: Bug OnPlayerStateChange - Poseidon4625 - 20.04.2020

Quote:
Originally Posted by RiqueP
View Post
Normalmente esse erro й apontado quando vocк tenta acessar um valor de uma array maior do que o limite dela. Exemplo:
PHP Code:
new matriz[10];
matriz[12] = 1
Entendi, obrigado.