SA-MP Forums Archive
Run time error: Invalid Memory Access - 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: Run time error: Invalid Memory Access (/showthread.php?tid=569917)



Run time error: Invalid Memory Access - dusk - 03.04.2015

The code:
pawn Код:
stock GetBusinessFurnitureCount(bizindex)
{
    new count = 0;
    for(new i = 0; i < MAX_BUSINESS_FURNITURE; i++)
    {
        if(i < 0 || i >= MAX_BUSINESS_FURNITURE || bizindex < 0 || bizindex >= MAX_BIZNES)
            printf("GetBusinessFurnitureCount(%d) is invalid index. i:%d", bizindex, i);
        if(BusinessFurniture[ bizindex ][ i ][ SqlId ])
            count++;
    }
    return count;
}
The backtrace.
pawn Код:
[19:25:40] [debug] Run time error 5: "Invalid memory access"
[19:25:40] [debug] AMX backtrace:
[19:25:40] [debug] #0 00064e64 in GetBusinessFurnitureCount (bizindex=29) at Property\Businesses.p:1306
The problematic line:
pawn Код:
if(BusinessFurniture[ bizindex ][ i ][ SqlId ])
Declaration of array and its enum:
pawn Код:
enum E_BUSINESS_FURNITURE_DATA {
    SqlId,
    FurnitureId,
    ObjectId,
    Name[ MAX_FURNITURE_NAME]
};
new BusinessFurniture[ MAX_BIZNES ][ MAX_BUSINESS_FURNITURE ][ E_BUSINESS_FURNITURE_DATA ];
Also I was unable to get the same result on my local server. For some reasons it only appears in my VPS. I think it might be due to the number of players although I dont yet see how can that be the case.

By googling I already added checks for invalid indexes, they do not appear. What else could cause this? I'm quite desperete, so ANY ideas at all will be appreciated.


Re: Run time error: Invalid Memory Access - dusk - 04.04.2015

bump


Re: Run time error: Invalid Memory Access - ikey07 - 04.04.2015

Any chance you use GetPVarString() any near that?


Re: Run time error: Invalid Memory Access - dusk - 04.04.2015

Sadly no.

I use it like so:
pawn Код:
else if(IsPlayerInAnyBusiness(playerid))
    {
        index = GetPlayerBusinessIndex(playerid);
        furnitureCount = GetBusinessFurnitureCount(index);



Re: Run time error: Invalid Memory Access - dusk - 05.04.2015

mighty bump.


Re: Run time error: Invalid Memory Access - dusk - 09.04.2015

It's still an issue