crashdetect detected something over Gagi's House System - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: crashdetect detected something over Gagi's House System (
/showthread.php?tid=419981)
crashdetect detected something over Gagi's House System -
JaKe Elite - 03.03.2013
After i convert all parts of Gagi's House System to my gamemode i compile it no errors.
When i start the gamemode.
The crashdetector starts detecting something
And it seems like ti's coming from public GlobalTimer.
Код:
[00:09:22] [debug] Run time error 4: "Array index out of bounds"
[00:09:22] [debug] Accessing element at index 500 past array upper bound 499
[00:09:22] [debug] AMX backtrace:
[00:09:22] [debug] #0 000be4a4 in public GlobalTimer () from fgame.amx
The code of GlobalTimer
pawn Код:
forward GlobalTimer();
public GlobalTimer()
{
new Year, Month, Day,string[64];
getdate(Year, Month, Day);
for(new id = 0; id <= MAX_HOUSE;id++)
{
format(string,64,House_File,id);
if(House[id][DayEnter]+MAX_DAYS <= Day && House[id][On_Sell] == 0)
{
if(fexist(string))
{
//If month have 31 days
if(House[id][MonthEnter] == 1 || House[id][MonthEnter] == 3 || House[id][MonthEnter] == 5 || House[id][MonthEnter] == 7 || House[id][MonthEnter] == 8 || House[id][MonthEnter] == 10 || House[id][MonthEnter] == 12)
{
if(House[id][DayEnter]+MAX_DAYS > 31)
{
new newday = (31-House[id][DayEnter]);
new newday1 = MAX_DAYS-newday;
if(newday1 != Day) return 1;
}
}
//If month have 30 days
if(House[id][MonthEnter] == 4 || House[id][MonthEnter] == 6 || House[id][MonthEnter] == 9 || House[id][MonthEnter] == 11)
{
if(House[id][DayEnter]+MAX_DAYS > 30)
{
new newday = (30-House[id][DayEnter]);
new newday1 = MAX_DAYS-newday;
if(newday1 != Day) return 1;
}
}
//If month have 29 days
if(House[id][MonthEnter] == 2)
{
if(House[id][DayEnter]+MAX_DAYS > 29)
{
new newday = (29-House[id][DayEnter]);
new newday1 = MAX_DAYS-newday;
if(newday1 != Day) return 1;
}
}
ResetPlayerHouseID(House[id][Owner]);
House[id][On_Sell] = 1;
format(House[id][Owner],48,"Apartment");
CheckHouse(id);
DestroyDynamicPickup(House[id][PickupU]);
House[id][PickupU] = CreateDynamicPickup(1273, 23, House[id][EnterX],House[id][EnterY],House[id][EnterZ],-1,-1,-1,100.0);
DestroyDynamicMapIcon(House[id][Icon]);
House[id][Icon] = CreateDynamicMapIcon(House[id][EnterX],House[id][EnterY],House[id][EnterZ], 31, 0, -1, -1, -1, 100.0);
format(string,sizeof(string),"{29CC3F}Owner: "COL_WHITE"Apartment\n{29CC3F}House Name: "COL_WHITE"%s\n{29CC3F}Price: "COL_WHITE"%d\n{29CC3F}Level: "COL_WHITE"%d\n{29CC3F}Address: "COL_WHITE"%s\n (/buyhouse)",House[id][HouseName],House[id][Price],House[id][Level],House[id][Address]);
UpdateDynamic3DTextLabelText(House[id][DLabel],-1,string);
printf("House ID %d has been unowned",id);
}
}
}
foreach(Player, i)
{
//===Bills===
if(Player[i][Houseid] != 999)
{
Player[i][Sec]++;
if(Player[i][Sec] >= 60) {Player[i][Sec] = 0; Player[i][Min]++;}
if(Player[i][Min] == 60)
{
Player[i][Min] = 0;
new money = randomEx(50,150);
SendFormatMSG(i,-1,"You pay for house bills {13AD32}$%d",money);
GivePlayerMoney(i,-money);
}
}
//Phone
if(Calling[i] > 0)
{
Calling[i]--;
if(Calling[i] == 0) {SCM(i,-1,"There is no answer.");}
}
if(Player[i][RobHouse] > 0) Player[i][RobHouse]--;
}
return 1;
}
Re: crashdetect detected something over Gagi's House System -
AndreT - 03.03.2013
Lets say the definition of MAX_HOUSE is 500.
What your loop will do is iterate from 0 to 500. Or in other words, from 0 to MAX_HOUSE, whereas the valid indexes to access this array at are 0 to MAX_HOUSE-1 (in your case, 0 to 499).
pawn Код:
for(new id = 0; id <= MAX_HOUSE;id++)
should become
pawn Код:
for(new id = 0; id != MAX_HOUSE; id++)
... if I'm not mistaken.
Re: crashdetect detected something over Gagi's House System -
JaKe Elite - 03.03.2013
Thanks fixed now
Rep++