All of function not being called.
#1

Ive debugged this for like a hour and finally found what is not being called. I cant figure out why.

pawn Код:
public OnPlayerPickUpDynamicPickup(playerid, pickupid)
{
    for (new i=1; i < MAX_HOUSES; i++) if (pickupid == Houses[i][house_pickup])
    {
        Players[playerid][last_house_entrance] = i;
        if (IsHouseOwnedByPlayer(playerid, i)) GameTextForPlayer(playerid, "~y~Press ~r~~k~~VEHICLE_ENTER_EXIT~ ~y~to enter your house", 3000, 3);
        break;
    }
    for(new i; i<= MAX_VEHICLE_DEALERS; i++)
    {
        print("1");
        if(pickupid == DealershipPickup[i])
        {
            print("22");
            new String[1000], String2[30];
            for(new n; n<= 500; n++)
            {
                print("333");
                if(BCarInfo[n][BCDealer] == i)
                {
                    print("4444");
                    format(String2,sizeof(String2),"%s - $%d\n",BCarInfo[n][BCName],BCarInfo[n][BCPrice]);
                    strcat(String,String2);
                }
            }
            new DialogID = 500+i;
            printf("%i",playerid);
            printf("%i",DialogID);
            printf("%f",DealerInfo[i][VDName]);
            printf("%f",String);
            ShowPlayerDialog(playerid,DialogID,DIALOG_STYLE_LIST,DealerInfo[i][VDName],String,"Buy","Cancel");
            print("55555");
            return 1;
        }
    }
    return 1;
}
Everything here is not being called:
pawn Код:
new DialogID = 500+i;
            printf("%i",playerid);
            printf("%i",DialogID);
            printf("%f",DealerInfo[i][VDName]);
            printf("%f",String);
            ShowPlayerDialog(playerid,DialogID,DIALOG_STYLE_LIST,DealerInfo[i][VDName],String,"Buy","Cancel");
            print("55555");
            return 1;

Can anyone see why?
Reply
#2

pawn Код:
n<= 500
should be

pawn Код:
n < 500
if it's a player loop. Otherwise it will go out of bounds and crash the callback.
Reply
#3

Still not working.

Current Code
pawn Код:
public OnPlayerPickUpDynamicPickup(playerid, pickupid)
{
    for (new i=1; i < MAX_HOUSES; i++) if (pickupid == Houses[i][house_pickup])
    {
        Players[playerid][last_house_entrance] = i;
        if (IsHouseOwnedByPlayer(playerid, i)) GameTextForPlayer(playerid, "~y~Press ~r~~k~~VEHICLE_ENTER_EXIT~ ~y~to enter your house", 3000, 3);
        break;
    }
    for(new i; i< MAX_VEHICLE_DEALERS; i++)
    {
        print("1");
        if(pickupid == DealershipPickup[i])
        {
            print("22");
            new String[1000], String2[30];
            for(new n; n< 500; n++)
            {
                print("333");
                if(BCarInfo[n][BCDealer] == i)
                {
                    print("4444");
                    format(String2,sizeof(String2),"%s - $%d\n",BCarInfo[n][BCName],BCarInfo[n][BCPrice]);
                    strcat(String,String2);
                }
            }
            new DialogID = 500+i;
            printf("%i",playerid);
            printf("%i",DialogID);
            printf("%f",DealerInfo[i][VDName]);
            printf("%f",String);
            ShowPlayerDialog(playerid,DialogID,DIALOG_STYLE_LIST,DealerInfo[i][VDName],String,"Buy","Cancel");
            print("55555");
            return 1;
        }
    }
    return 1;
}
Reply
#4

It's probably silent-crashing. Run the crashdetect plugin- it should show something.
Reply
#5

Heres the error:

Код:
[21:31:11] [debug] Run time error 4: "Array index out of bounds"
[21:31:11] [debug]  Accessing element at index 132 past array upper bound 131
[21:31:11] [debug] AMX backtrace:
[21:31:11] [debug] #0 0000e0b8 in public OnPlayerPickUpDynamicPickup (0x00000000, 0x00000023) from MissionScript.amx
[21:31:11] [debug] #1 native Streamer_CallbackHook () [73defae0] from streamer.DLL
[21:31:11] [debug] #2 00000348 in public OnPlayerPickUpPickup (0x00000000, 0x00000000) from MissionScript.amx
Im assuming it means its overloading the string but the string. I dont know where it would do that though.
Reply
#6

Inside one of your loops you're trying to access an array with the index 132 but the limit is 131. Maybe MAX_PLAYERS is 131 but you're trying to loop 500 players or maybe MAX_HOUSES is 131 but the array is smaller. Maybe it's the dealerships.
Reply
#7

Quote:
Originally Posted by SuperViper
Посмотреть сообщение
Inside one of your loops you're trying to access an array with the index 132 but the limit is 131. Maybe MAX_PLAYERS is 131 but you're trying to loop 500 players or maybe MAX_HOUSES is 131 but the array is smaller. Maybe it's the dealerships.
Thank you so much. I was was letting it loop to 500 but there was only 131 in the enum that i defined. I fixed it by limiting it with sizeof(BCarInfo). It works now.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)