new rand = random(MAX_HOUSES - 1);
while(!(HouseInfo[rand][hExteriorZ] <= 100 && HouseInfo[rand][hExteriorX] > -2802.389648 && HouseInfo[rand][hExteriorX] < -1523.710327 && HouseInfo[rand][hExteriorY] < 1334.343750 && HouseInfo[rand][hExteriorY] > -216.298019))
{
rand++;
if(rand == 1400)
{
rand = 1;
}
}
SetPVarInt(playerid, "tpPizzaTimer", floatround((GetPizzaDistance(rand) / 80), floatround_round));
SetPVarInt(playerid, "pizzaTotal", floatround((GetPizzaDistance(rand) / 10), floatround_round));
SetPVarInt(playerid, "pizzaTimer", GetPVarInt(playerid, "pizzaTotal"));
SetTimerEx("OtherTimerEx", 1000, false, "ii", playerid, TYPE_TPPIZZARUNTIMER);
SetTimerEx("OtherTimerEx", 1000, false, "ii", playerid, TYPE_PIZZATIMER);
format(szMessage, sizeof(szMessage), "You have picked up a pizza for %s. You have %d seconds to deliver it!", HouseInfo[rand][hOwner], GetPVarInt(playerid, "pizzaTotal"));
SendClientMessageEx(playerid, COLOR_WHITE, szMessage);
SetPVarInt(playerid, "Pizza", rand);
PizzaBar[playerid] = CreateProgressBar(258.00, 137.00, 131.50, 3.19, COLOR_GREEN, 100.0);
SetProgressBarValue(PizzaBar[playerid], 100.0);
ShowProgressBarForPlayer(playerid, PizzaBar[playerid]);
SetPlayerCheckpoint(playerid, HouseInfo[rand][hExteriorX], HouseInfo[rand][hExteriorY], HouseInfo[rand][hExteriorZ], 5);
return 1;
Firstly: You have a possible infinate loop in that code when all the houses are invalid.
Secondly: Download the crash detect plugin. Issues such as yours are often caused by an OOB stopping code execution, which that plugin will tell you about. |
[debug] Run time error 4: "Array index out of bounds"
[debug] Accessing element at index 1000 past array upper bound 999
[debug] AMX backtrace:
[debug] #0 0036ee1c in public cmd_getpizza (0x00000000, 0x02338910) from EXRPR46.amx
[debug] #1 native CallLocalFunction () [00472ad0] from samp-server.exe
[debug] #2 0000b550 in public OnPlayerCommandText (0x00000000, 0x023388e8) from EXRPR46.amx
You have declared an array as "[1000]", then are trying to access slot "[1000]", which does't exist. Check pawn-lang.pdf for ore information on array indexes, and compile with -d3 for more specific debug information.
|