given that everything is right in the script , and your error is only on delitem3 , use
delequip .@equip_loc;
instead of delitem3
you still need the information to create a new item , but this insure that even if you missed some information about the item (like identify and attribute) the item will get deleted safely and the player can't abuse the system
also you don't need those
setarray .@OptID[0],0;
setarray .@OptID[1],0;
setarray .@OptID[2],0;
setarray .@OptID[3],0;
setarray .@OptID[4],0;
setarray .@OptVal[0],0;
setarray .@OptVal[1],0;
setarray .@OptVal[2],0;
setarray .@OptVal[3],0;
setarray .@OptVal[4],0;
setarray .@OptParam[0],0;
setarray .@OptParam[1],0;
setarray .@OptParam[2],0;
setarray .@OptParam[3],0;
setarray .@OptParam[4],0;
and your forloop for getting the random options
from
for (.@j = 0; .@j < 5; .@j++) {
setarray .@OptID[.@j],getequiprandomoption(.@eq_loc,.@j,ROA_ID);
setarray .@OptVal[.@j],getequiprandomoption(.@eq_loc,.@j,ROA_VALUE);
setarray .@OptParam[.@j],getequiprandomoption(.@eq_loc,.@j,ROA_PARAM);
}
to
for (.@j = 0; .@j < 5; .@j++) {
.@OptID[.@j] = getequiprandomoption(.@eq_loc,.@j,ROA_ID);
.@OptVal[.@j] = getequiprandomoption(.@eq_loc,.@j,ROA_VALUE);
.@OptParam[.@j] = getequiprandomoption(.@eq_loc,.@j,ROA_PARAM);
}