Vehicles - Instantly Crashing Players - WTF
#1

at this code, i put under on game mode init
Code:
	LoadPlayerVehicles(playerid);
then when a player is registering, After the player put his desired password in dialog box and then register the player instantly crash and there are some messages saying "Failed to load vehicle type: 451 bla bla bla" and when the player reconnect and then register again, everything will be okay. How can i fix this bug at my server.

STOCK
pawn Code:
stock LoadPlayerVehicles(playerid)
{
    new playername[MAX_PLAYER_NAME];
    GetPlayerName(playerid, playername, sizeof(playername));
    printf(" Loading %s's vehicles.", playername);
    for(new v = 0; v < MAX_PLAYERVEHICLES; v++)
    {
        if(PlayerVehicleInfo[playerid][v][pvModelId] != 0 && PlayerVehicleInfo[playerid][v][pvImpounded] == 0)
        {

            PlayerCars++;
            if(PlayerVehicleInfo[playerid][v][pvLocked] == 1) LockPlayerVehicle(playerid, PlayerVehicleInfo[playerid][v][pvId], PlayerVehicleInfo[playerid][v][pvLock]);


        }
        else if(PlayerVehicleInfo[playerid][v][pvModelId] == 0 && PlayerVehicleInfo[playerid][v][pvImpounded] != 0)
            PlayerVehicleInfo[playerid][v][pvImpounded] = 0;
    }
    LoadAllPlayerVehicleMods(playerid);
}
And some peoples saying the problem is, it creating false vehicle modfication causing to bug and crash the player, If this is your response, heres the code
pawn Code:
stock LoadAllPlayerVehicleMods(playerid)
{
    print(" Loading all vehicles mods.");
    for(new v = 0; v < MAX_PLAYERVEHICLES; v++)
    {
        if(PlayerVehicleInfo[playerid][v][pvModelId] != 0 && PlayerVehicleInfo[playerid][v][pvImpounded] == 0)
        {
            new paintjob = PlayerVehicleInfo[playerid][v][pvPaintJob];
            new color1 = PlayerVehicleInfo[playerid][v][pvColor1];
            new color2 = PlayerVehicleInfo[playerid][v][pvColor2];
            if(PlayerVehicleInfo[playerid][v][pvPaintJob] != -1)
            {
                ChangeVehiclePaintjob(PlayerVehicleInfo[playerid][v][pvId], paintjob);
            }
            ChangeVehicleColor(PlayerVehicleInfo[playerid][v][pvId], color1, color2);
            for(new m = 0; m < MAX_MODS; m++)
            {
                if (PlayerVehicleInfo[playerid][v][pvMods][m] >= 1000 && PlayerVehicleInfo[playerid][v][pvMods][m] <= 1193)
                {
                    if (InvalidModCheck(GetVehicleModel(PlayerVehicleInfo[playerid][v][pvId]),PlayerVehicleInfo[playerid][v][pvMods][m]))
                    {
                        AddVehicleComponent(PlayerVehicleInfo[playerid][v][pvId], PlayerVehicleInfo[playerid][v][pvMods][m]);
                    }
                    else
                    {
                        printf("Removing invalid mod %d from model %d of %s", PlayerVehicleInfo[playerid][v][pvMods][m], GetVehicleModel(PlayerVehicleInfo[playerid][v][pvId]), GetPlayerNameEx(playerid));
                        PlayerVehicleInfo[playerid][v][pvMods][m] = 0;
                    }
                }
            }
        }
    }
}
Reply
#2

Hello Again

I used Crashdetect plugin and after the crash heres the result
Array is out of bounds
Code:
[20:37:25] [debug] Run time error 4: "Array index out of bounds"
[20:37:25] [debug]  Accessing element at index 999 past array upper bound 500
[20:37:25] [debug] AMX backtrace:
[20:37:25] [debug] #0 00070ea8 in public OnPlayerStateChange (0x00000000, 0x00000001, 0x00000008) from RGRP.amx
OnPlayerStateChange: http://pastebin.com/wwAUvibC
Reply
#3

"Accessing element at index 999 past array upper bound 500"
means your array is too small, therefore, when he tries to access a specific cell that is greater than the size set, it returns an error.

For example :
if you have an array per player and the max. first dimesion's size is MAX_PLAYERS (500)
pawn Code:
new score[MAX_PLAYERS];
then when you'll try to access 501, it will return the error - array out of bounds.

exmaple 2:
if you store vehicles ids in arrays and the max. array size is set to 600, and you try to create 601 vehicles, it will return this error.
Reply
#4

Quote:
Originally Posted by xkirill
View Post
"Accessing element at index 999 past array upper bound 500"
means your array is too small, therefore, when he tries to access a specific cell that is greater than the size set, it returns an error.

For example :
if you have an array per player and the max. first dimesion's size is MAX_PLAYERS (500)
pawn Code:
new score[MAX_PLAYERS];
then when you'll try to access 501, it will return the error - array out of bounds.

exmaple 2:
if you store vehicles ids in arrays and the max. array size is set to 600, and you try to create 601 vehicles, it will return this error.
so confused.

Can you please find the error at the codes on pastebin ?
Reply
#5

and how do i find the lines that crashdetect report? thanks!!!
Reply
#6

bump :\
Reply
#7

anyone pleaze? @Dugi

@Kalcor
@Testers?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)