Hm...Why not just use getgmlvl? instead of using query?
if(getgmlvl == 1){
set .qty,2;}
else {
set .qty,0;}
getitem getarg(2), getarg(3)+.qty, getd(getarg(0) + "[" + .@i + "]");
As for why the item cant be given is because in this script you've pasted; the Item ID is no where to be found so "getarg(2)" becomes 0. In terms; You must define the itemID and the quantity inorder for the "getitem" to beable to fully work