30.12.2017, 12:04
Basically, my server crashes each time inventory function is called through OnDialogResponse, here is what crashdetect.dll says;
What I am guessing is that I've used too much arrays and it caused the script to have a massive difference between stack/heap size and estimated max usage. Any tips? Here is the code;
Код:
[debug] Stack pointer (STK) is 0x19F974, heap pointer (HEA) is 0x1A0000 [debug] AMX backtrace: [debug] #0 0001f7c8 in public OnDialogResponse (0, 45, 1, -1, 1703928) from survival_mysql.amx
pawn Код:
ShowTargetInventory(playerid)
{
new buffer[2028], test[MAX_PLAYERS], count[MAX_PLAYERS];
for(new j = 0; j < inInfo[tradingPartner[playerid]][aSlots]; j++)
{
/*if(tradingItem1[playerid] == inInfo[tradingPartner[playerid]][iSlots][j] || tradingItem2[playerid] == inInfo[tradingPartner[playerid]][iSlots][j] || tradingItem3[playerid] == inInfo[tradingPartner[playerid]][iSlots][j])
{
test[playerid] = inInfo[tradingPartner[playerid]][iSlots][j];
format(buffer, sizeof(buffer), "%s{FF0000}%d %s (%d)(YOU ALREADY SELECTED THIS ITEM)\n", buffer, j + 1, ItemNames[test[playerid]], inInfo[tradingPartner[playerid]][iAmount][j]);
inInfo[tradingPartner[playerid]][dSlots][count[playerid]] = test[playerid];
count[playerid]++;
}*/
//else
//{
test[playerid] = inInfo[tradingPartner[playerid]][iSlots][j];
format(buffer, sizeof(buffer), "%s{0099cc}%d {FFFFFF}%s (%d)\n", buffer, j + 1, ItemNames[test[playerid]], inInfo[tradingPartner[playerid]][iAmount][j]);
inInfo[tradingPartner[playerid]][dSlots][count[playerid]] = test[playerid];
count[playerid]++;
//}
}
new string[90];
countsinventory[playerid]++;
if(tradingcCount[playerid] != countsinventory[playerid])
format(string, sizeof(string),"{0174DF}[R-SURVIVAL]: {FFFFFF}Trading System [ {FF0000}%d {FFFFFF}/ {00FF00}%d {FFFFFF}]", countsinventory[playerid], tradingcCount[playerid]);
else
format(string, sizeof(string),"{0174DF}[R-SURVIVAL]: {FFFFFF}Trading System [ {00FF00}%d {FFFFFF}/ {00FF00}%d {FFFFFF}]", countsinventory[playerid], tradingcCount[playerid]);
ShowPlayerDialog(playerid, DIALOG_TRADINGREQITEMS, DIALOG_STYLE_LIST, string, buffer, "Select","Cancel");
}