function onUse(player, item, fromPosition, itemEx, toPosition)
if item.itemid == 26405 and isInArray({50605, 50602, 50603, 50604}, item.actionid) then
if player:getCondition(player, CONDITION_COOLDOWN, 160) then
player:sendCancelMessage("You are already gathering!")
return true
end
if not player:isGatheringJob(item.actionid) then
player:sendCancelMessage("You must learn "..craftingGatheringJobConfig[item.actionid].skillName.." before using this.")
return true
end
if player:isGatheringJob(item.actionid) then
if player:getStorageValue(205000) > os.time() then
player:sendCancelMessage("You must wait before mining this again!")
return true
end
if player:getItemCount(2553) >= 1 then -- check for pick
mathCheck = math.floor(math.random() * 100) + 1
if mathCheck >= 50 then
player:addItem(26410, math.floor(math.random() * 3) + 1)
elseif mathCheck <= 49 then
player:addItem(26409, math.floor(math.random() * 3)+ 1)
end
else
player:sendCancelMessage("You need a pick to use this!")
return true
end
end
player:setStorageValue(205000, os.time() + 1)
elseif item.itemid == 26406 and isInArray({50605, 50602, 50603, 50604}, item.actionid) then
if player:getCondition(player, CONDITION_COOLDOWN, 160) then
player:sendCancelMessage("You are already gathering!")
return true
end
if not player:isGatheringJob(item.actionid) then
player:sendCancelMessage("You must learn "..craftingGatheringJobConfig[item.actionid].skillName.." before using this.")
return true
end
if player:isGatheringJob(item.actionid) then
if player:getStorageValue(205000) > os.time() then
player:sendCancelMessage("You must wait before mining this again!")
return true
end
if player:getItemCount(2553) >= 1 then -- check for pick
mathCheck = math.floor(math.random() * 100) + 1
if mathCheck >= 60 then
player:addItem(26411, math.floor(math.random() * 3) + 1)
elseif mathCheck <= 59 then
player:addItem(26409, math.floor(math.random() * 3) + 1)
end
else
player:sendCancelMessage("You need a pick to use this!")
return true
end
end
player:setStorageValue(205001, os.time() + 1)
elseif item.itemid == 26407 and isInArray({50605, 50602, 50603, 50604}, item.actionid) then
if player:getCondition(player, CONDITION_COOLDOWN, 160) then
player:sendCancelMessage("You are already gathering!")
return true
end
if not player:isGatheringJob(item.actionid) then
player:sendCancelMessage("You must learn "..craftingGatheringJobConfig[item.actionid].skillName.." before using this.")
return true
end
if player:isGatheringJob(item.actionid) then
if player:getStorageValue(205000) > os.time() then
player:sendCancelMessage("You must wait before mining this again!")
return true
end
if player:getItemCount(2553) >= 1 then -- check for pick
mathCheck = math.floor(math.random() * 100) + 1
if mathCheck >= 70 then
player:addItem(26412, math.floor(math.random() * 3) + 1)
elseif mathCheck <= 69 then
player:addItem(26409, math.floor(math.random() * 3) + 1)
end
else
player:sendCancelMessage("You need a pick to use this!")
return true
end
end
player:setStorageValue(205002, os.time() + 1)
elseif item.itemid == 26408 and isInArray({50605, 50602, 50603, 50604}, item.actionid) then
if player:getCondition(player, CONDITION_COOLDOWN, 160) then
player:sendCancelMessage("You are already gathering!")
return true
end
if not player:isGatheringJob(item.actionid) then
player:sendCancelMessage("You must learn "..craftingGatheringJobConfig[item.actionid].skillName.." before using this.")
return true
end
if player:isGatheringJob(item.actionid) then
if player:getStorageValue(205000) > os.time() then
player:sendCancelMessage("You must wait before mining this again!")
return true
end
if player:getItemCount(2553) >= 1 then -- check for pick
mathCheck = math.floor(math.random() * 100) + 1
if mathCheck >= 80 then
player:addItem(26413, math.floor(math.random() * 3) + 1)
elseif mathCheck <= 79 then
player:addItem(26409, math.floor(math.random() * 3) + 1)
end
else
player:sendCancelMessage("You need a pick to use this!")
return true
end
end
player:setStorageValue(205003, os.time() + 1)
elseif item.itemid == 26404 and isInArray({ 50605, 50602, 50603, 50604}, item.actionid) then
player:sendCancelMessage("This vein is exhausted!")
return true
elseif item.itemid == 2217 and item.actionid >= craftingGatheringJobConfig.baseRecipeStorage then
if player:getStorageValue(item.actionid) == -1 then
player:sendTextMessage(MESSAGE_EVENT_DEFAULT, "You have learned "..craftingGatheringJobConfig[item.actionid].skillName..", then the book burned to ashes after learning it's secrets.")
player:getPosition():sendMagicEffect(CONST_ME_EXPLOSIONHIT)
player:setStorageValue(item.actionid, 10)
Item(item.uid):remove(1)
else
player:sendCancelMessage("You already know "..craftingGatheringJobConfig[item.actionid].skillName..".")
return true
end
end
end