Mess up :S
#1

Hello, I have gone thought my job system, while testing out one of my jobs, I was getting debug warnings, I can't see where i've gone wrong.

Код:
[21:21:45] [debug] Run time error 4: "Array index out of bounds"
[21:21:45] [debug]  Accessing element at index 11 past array upper bound 7
[21:21:45] [debug] AMX backtrace:
[21:21:45] [debug] #0 0000103c in public OnPlayerEnterCheckpoint (0) from Jobs0.1.amx
[21:21:58] [debug] Run time error 4: "Array index out of bounds"
[21:21:58] [debug]  Accessing element at index 11 past array upper bound 7
[21:21:58] [debug] AMX backtrace:
[21:21:58] [debug] #0 0000103c in public OnPlayerEnterCheckpoint (0) from Jobs0.1.amx
[21:21:58] [debug] Run time error 4: "Array index out of bounds"
[21:21:58] [debug]  Accessing element at index 10 past array upper bound 7
[21:21:58] [debug] AMX backtrace:
[21:21:58] [debug] #0 0000103c in public OnPlayerEnterCheckpoint (0) from Jobs0.1.amx
[21:22:41] [debug] Run time error 4: "Array index out of bounds"
[21:22:41] [debug]  Accessing element at index 9 past array upper bound 7
[21:22:41] [debug] AMX backtrace:
[21:22:41] [debug] #0 0000103c in public OnPlayerEnterCheckpoint (0) from Jobs0.1.amx
[21:23:09] [debug] Run time error 4: "Array index out of bounds"
[21:23:09] [debug]  Accessing element at index 9 past array upper bound 7
[21:23:09] [debug] AMX backtrace:
[21:23:09] [debug] #0 0000103c in public OnPlayerEnterCheckpoint (0) from Jobs0.1.amx
[21:23:26] [debug] Run time error 4: "Array index out of bounds"
[21:23:26] [debug]  Accessing element at index 9 past array upper bound 7
[21:23:26] [debug] AMX backtrace:
[21:23:26] [debug] #0 0000103c in public OnPlayerEnterCheckpoint (0) from Jobs0.1.amx
[21:23:57] [debug] Run time error 4: "Array index out of bounds"
[21:23:57] [debug]  Accessing element at index 13 past array upper bound 7
[21:23:57] [debug] AMX backtrace:
[21:23:57] [debug] #0 0000103c in public OnPlayerEnterCheckpoint (0) from Jobs0.1.amx
pawn Код:
public OnPlayerEnterCheckpoint(playerid)
{
        if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 431)//Bus
    {
        switch (BusDriver[playerid])
        {
            case 1:
            {
                GameTextForPlayer(playerid, "~y~Go to the next bus stop!", 5, 500);
            }
            case 2:
            {
                GivePlayerMoney(playerid, 500);
            }
            case 3, 4, 6, 7, 8, 9, 10, 11:
            {
                GivePlayerMoney(playerid, 500);
            }
        }
        BusDriver[playerid] = BusDriver[playerid] + 1;
        if (BusDriver[playerid] == sizeof(BusCP))
        BusDriver[playerid] = 1;
        SetPlayerCheckpoint(playerid, BusCP[BusDriver[playerid] - 1][0], BusCP[BusDriver[playerid] - 1][1], BusCP[BusDriver[playerid] - 1][2], 5);//busstop2
        }
        if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 448)//Pizza
        {
        if(Pizzaboy[playerid] == 1)
        {
        new rand = random(sizeof(PizzaCP));
        SetPlayerCheckpoint(playerid, PizzaCP[rand][0], PizzaCP[rand][1], PizzaCP[rand][2], 5);
        GivePlayerMoney(playerid, PayRandom[rand][0]);
        GameTextForPlayer(playerid, "~y~Go deliver them pizzas", 1000, 5);
        }
        if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 481)//Paper
        {
        if(PaperBoy[playerid] == 1)
        {
        new rand = random(sizeof(PaperCP));
        SetPlayerCheckpoint(playerid, PaperCP[rand][0], PaperCP[rand][1], PaperCP[rand][2], 5);
        GivePlayerMoney(playerid, PaperPay[rand][0]);
        GameTextForPlayer(playerid, "~y~Go deliver them Papers", 1000, 5);
        {
    }
    }
  }
  }
}
Thank you if you know what's up, I will be grateful to get rid of this.
Reply
#2

Not really sure what is the cause but
pawn Код:
BusCP[BusDriver[playerid] - 1]
What if his id is 0 ?
Reply
#3

What do you mean by that?
Reply
#4

oh, my mistake, I thought it's playerid - 1


EDIT: Must note that you can sort this
BusDriver[playerid] = BusDriver[playerid] + 1;
into
BusDriver[playerid]++;


and is it intended to have an opening and closing barackets at the end without an event before it ?
Quote:

GivePlayerMoney(playerid, PaperPay[rand][0]);
GameTextForPlayer(playerid, "~y~Go deliver them Papers", 1000, 5);
{
}
}
}
}

Or you just removed the code ?
Reply
#5

I've gone though the jobs and pinned one job that triggers the debug, that is the pizzaboy job
pawn Код:
if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 448)//Pizza
        {
        if(Pizzaboy[playerid] == 1)
        {
        new rand = random(sizeof(PizzaCP));
        SetPlayerCheckpoint(playerid, PizzaCP[rand][0], PizzaCP[rand][1], PizzaCP[rand][2], 5);
        GivePlayerMoney(playerid, PayRandom[rand][0]);
        GameTextForPlayer(playerid, "~y~Go deliver them pizzas", 1000, 5);
        }
Reply
#6

pawn Код:
if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 448)//Pizza
        {
        if(Pizzaboy[playerid] == 1)
        {
        new rand = random(sizeof(PizzaCP));
        SetPlayerCheckpoint(playerid, PizzaCP[rand][0], PizzaCP[rand][1], PizzaCP[rand][2], 5);
        GivePlayerMoney(playerid, PayRandom[rand][0]);// here it try to pay the player a float amount     GameTextForPlayer(playerid, "~y~Go deliver them pizzas", 1000, 5);
        }
Try this

pawn Код:
if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 448)//Pizza
        {
        if(Pizzaboy[playerid] == 1)
        {
        new rand = random(sizeof(PizzaCP));
        new prand = random(sizeof(RandomPay));// Change RandomPay to ehat you have named your random pay.
        SetPlayerCheckpoint(playerid, PizzaCP[rand][0], PizzaCP[rand][1], PizzaCP[rand][2], 5);
        GivePlayerMoney(playerid, PayRandom[prand][0]);
        GameTextForPlayer(playerid, "~y~Go deliver them pizzas", 1000, 5);
        }
Reply
#7

Ok, thanks for replying Jakwob I'll test it soon
Reply
#8

It clearly shows that its a array of size 7, look for array of size 7 it has the error..
Reply
#9

Did you fix this?
Reply
#10

Yeah, thank you Jakwob, Sorry didn't get back, I have been feeling ill.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)