• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Lua Cannot use this item, but still runs code?

noshirtstan

New Member
Joined
Aug 2, 2020
Messages
68
Reaction score
2
Hey folks,

I'm having a slight issue with my coding.

I go to use the item in question, and the script runs no problem, but for some reason the cancel message "You cannot use this item" appears on the screen as I click the item to use.

Any thoughts?
 
Solution
So i adjusted all that but I'm still getting the you cannot use this, with the exception of the elseif on ln 125
Lua:
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
            return player:sendCancelMessage("You must learn "..craftingGatheringJobConfig[item.actionid].skillName.." before using this.")
        end
       
        if player:isGatheringJob(item.actionid) then
       
            if...

Xikini

I whore myself out for likes
Support Team
Joined
Nov 17, 2010
Messages
5,682
Solutions
406
Reaction score
3,792
Hey folks,

I'm having a slight issue with my coding.

I go to use the item in question, and the script runs no problem, but for some reason the cancel message "You cannot use this item" appears on the screen as I click the item to use.

Any thoughts?
Would need to see the script.
 
OP
OP
N

noshirtstan

New Member
Joined
Aug 2, 2020
Messages
68
Reaction score
2
Lua:
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
            return player:sendCancelMessage("You are already gathering!")
        end
       
        if not player:isGatheringJob(item.actionid) then
            return player:sendCancelMessage("You must learn "..craftingGatheringJobConfig[item.actionid].skillName.." before using this.")
        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 >= 75 then
                player:addItem(26410, math.floor(math.random() * 3) + 1)
            elseif mathCheck <= 74 then
                player:addItem(26409, math.floor(math.random() * 3) + 1)
            end
            else
                return player:sendCancelMessage("You need a pick to use this!")
                end
            end
            player:setStorageValue(205000, os.time() + 1)
           
    elseif item.itemid == 26406 and isInArray({50601, 50602, 50603, 50604}, item.actionid) then
        if player:getCondition(player, CONDITION_COOLDOWN, 160) then
            return player:sendCancelMessage("You are already gathering!")
        end
       
        if not player:isGatheringJob(item.actionid) then
            return player:sendCancelMessage("You must learn "..craftingGatheringJobConfig[item.actionid].skillName.." before using this.")
        end
       
    elseif item.itemid == 26407 and isInArray({50601, 50602, 50603, 50604}, item.actionid) then
        if player:getCondition(player, CONDITION_COOLDOWN, 160) then
            return player:sendCancelMessage("You are already gathering!")
        end
       
        if not player:isGatheringJob(item.actionid) then
            return player:sendCancelMessage("You must learn "..craftingGatheringJobConfig[item.actionid].skillName.." before using this.")
        end
   
    elseif item.itemid == 26408 and isInArray({50601, 50602, 50603, 50604}, item.actionid) then
        if player:getCondition(player, CONDITION_COOLDOWN, 160) then
            return player:sendCancelMessage("You are already gathering!")
        end
       
        if not player:isGatheringJob(item.actionid) then
            return player:sendCancelMessage("You must learn "..craftingGatheringJobConfig[item.actionid].skillName.." before using this.")
        end
       
    elseif item.itemid == 26404 and isInArray({    50601, 50602, 50603, 50604}, item.actionid) then
        return player:sendCancelMessage("This vein is exhausted!")
   
    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..".")
        end
    end
end

There are 2 empty lines up top so line 1 is actually line 3
 

Xikini

I whore myself out for likes
Support Team
Joined
Nov 17, 2010
Messages
5,682
Solutions
406
Reaction score
3,792
Lua:
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
            return player:sendCancelMessage("You are already gathering!")
        end
    
        if not player:isGatheringJob(item.actionid) then
            return player:sendCancelMessage("You must learn "..craftingGatheringJobConfig[item.actionid].skillName.." before using this.")
        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 >= 75 then
                player:addItem(26410, math.floor(math.random() * 3) + 1)
            elseif mathCheck <= 74 then
                player:addItem(26409, math.floor(math.random() * 3) + 1)
            end
            else
                return player:sendCancelMessage("You need a pick to use this!")
                end
            end
            player:setStorageValue(205000, os.time() + 1)
        
    elseif item.itemid == 26406 and isInArray({50601, 50602, 50603, 50604}, item.actionid) then
        if player:getCondition(player, CONDITION_COOLDOWN, 160) then
            return player:sendCancelMessage("You are already gathering!")
        end
    
        if not player:isGatheringJob(item.actionid) then
            return player:sendCancelMessage("You must learn "..craftingGatheringJobConfig[item.actionid].skillName.." before using this.")
        end
    
    elseif item.itemid == 26407 and isInArray({50601, 50602, 50603, 50604}, item.actionid) then
        if player:getCondition(player, CONDITION_COOLDOWN, 160) then
            return player:sendCancelMessage("You are already gathering!")
        end
    
        if not player:isGatheringJob(item.actionid) then
            return player:sendCancelMessage("You must learn "..craftingGatheringJobConfig[item.actionid].skillName.." before using this.")
        end

    elseif item.itemid == 26408 and isInArray({50601, 50602, 50603, 50604}, item.actionid) then
        if player:getCondition(player, CONDITION_COOLDOWN, 160) then
            return player:sendCancelMessage("You are already gathering!")
        end
    
        if not player:isGatheringJob(item.actionid) then
            return player:sendCancelMessage("You must learn "..craftingGatheringJobConfig[item.actionid].skillName.." before using this.")
        end
    
    elseif item.itemid == 26404 and isInArray({    50601, 50602, 50603, 50604}, item.actionid) then
        return player:sendCancelMessage("This vein is exhausted!")

    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..".")
        end
    end
end

There are 2 empty lines up top so line 1 is actually line 3
In order to trackdown the problem, I guess you'd need to start adding print() into your code, to find out where it is failing.

before / after every if statement is usually best, if you have no clue where it is erroring.
print(1)
print(2)
print(3)
 
Last edited:
OP
OP
N

noshirtstan

New Member
Joined
Aug 2, 2020
Messages
68
Reaction score
2
The thing is, it's not erroring out. Everything works great, except that it tells me i can;t use it even though im using it lol.
Post automatically merged:

It's doing the same thing with the books that teach the skills.
 

Xikini

I whore myself out for likes
Support Team
Joined
Nov 17, 2010
Messages
5,682
Solutions
406
Reaction score
3,792
The thing is, it's not erroring out. Everything works great, except that it tells me i can;t use it even though im using it lol.
Post automatically merged:

It's doing the same thing with the books that teach the skills.
Alright, so my new theory then is that the script assumes you are returning false, which would give you that 'error'.

Anywhere you have
return player:sendCancelMessage

change to
player:sendCancelMessage return true
 
OP
OP
N

noshirtstan

New Member
Joined
Aug 2, 2020
Messages
68
Reaction score
2
So i adjusted all that but I'm still getting the you cannot use this, with the exception of the elseif on ln 125
Code:
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
Post automatically merged:

I added return true to the end of code... Lol now i see what you meant. Works amazing now! Thank you all so much!
Code:
        else
            player:sendCancelMessage("You already know "..craftingGatheringJobConfig[item.actionid].skillName..".")
            return true
        end
        return true-- added
    end
    return true -- added
end
 

Xikini

I whore myself out for likes
Support Team
Joined
Nov 17, 2010
Messages
5,682
Solutions
406
Reaction score
3,792
So i adjusted all that but I'm still getting the you cannot use this, with the exception of the elseif on ln 125
Lua:
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
            return player:sendCancelMessage("You must learn "..craftingGatheringJobConfig[item.actionid].skillName.." before using this.")
        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
            return player:sendCancelMessage("You must learn "..craftingGatheringJobConfig[item.actionid].skillName.." before using this.")
        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
Lua:
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
    return true
end
 
Solution

Xikini

I whore myself out for likes
Support Team
Joined
Nov 17, 2010
Messages
5,682
Solutions
406
Reaction score
3,792
Just so I can learn, whats the difference in running return player:~~~ as apposed to running return true after the argument?
I'm shit at explaining stuff. LOL

But basically return true means that the script executed correctly and as expected.

return anything else means that the outcome is not something desirable.

then again you could also do

return player:~~ and true

But I feel it's less readable, so always put them apart.
 
Top