Item Check And Destroy
if isplayer(ch) then
if taskopen(ch,shaegoal,shaetasknumber) then
if carries(ch,"shae-1") and carries(ch,"shae-2") and carries(ch,"shae-3") and carries(ch,"shae-4") then
local count1 = countitems(ch,"shae-1")
local count2 = countitems(ch,"shae-2")
local count3 = countitems(ch,"shae-2")
local count4 = countitems(ch,"shae-2")
if count1 >= 2 and count2 >= 2 and count3 >= 2 and count4 >= 2 then
sayto(ch,"Nice job, I'll take those items.")
destroy(ch,"shae-1",LP_ONEONLY)
destroy(ch,"shae-1",LP_ONEONLY)
destroy(ch,"shae-2",LP_ONEONLY)
destroy(ch,"shae-2",LP_ONEONLY)
destroy(ch,"shae-3",LP_ONEONLY)
destroy(ch,"shae-3",LP_ONEONLY)
destroy(ch,"shae-4",LP_ONEONLY)
destroy(ch,"shae-4",LP_ONEONLY)
completetask(ch,shaegoal,shaetasknumber)
addtask(ch,shaegoal,shaenexttask)
sayto(ch,"Now, on to your next task!")
else
sayto(ch,"You have all four items, but I need two of each, which you don't have.")
return
end
else
sayto(ch,"You do not have all four of the items i need")
return
end
else
sayto(ch,"I'm not interested in that at the moment.")
end
end
If you have multiple items with consecutive keys, you can use a for loop to reduce typing:
-- Delete objects petstore-3, -4, .. -9 local i = 0 for i=3,9 do destroy(ch,"petstore-"..i,LP_CARRIEDONLY) end