• 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 Error Woodcutting script.

Guiizuka97

New Member
Joined
Sep 9, 2019
Messages
11
Reaction score
0
dosn't show any error on log. and dont happens nothing when i use the axe on the tree or the floor.


local trees = {

[2704] = {itemid = 2704, level = 5, loot = 5901, xp = 1},
[2705] = {itemid = 2705, level = 15, loot = 5901, xp = 3}

}

function onUse(cid, item, fromPosition, target, toPosition, isHotkey)
local logs = 5901

if trees[target.itemid] then

local skill = getPlayerSkillLevel(cid, 7)

if skill < trees[target.itemid].level then
doPlayerAddSkillTry(cid, 7, trees[target.itemid].xp)
doSendMagicEffect(target, 30)
doPlayerAddItem(cid, trees[target.itemid].loot)

doSendTextMessage(cid, 22, "You couldn't mine anything.")
doSendMagicEffect(CONST_ME_HITAREA)

end
end
end









--function onUse(cid, item, fromPosition, itemEx, toPosition)

--
--if getPlayerSkillLevel(cid, 7) < 10 then
--doPlayerSendTextMessage(cid, 22, "Precisa de Level 10 em Woodcutting.") else

--doPlayerAddItem(cid, logs ,1)
--doPlayerSendTextMessage(cid, 22, "You cut a tree.")
--doPlayerAddSkillTry(cid, 7, 1)
--return true
--
-- end

-- end
 
Solution
Code:
local trees = {
    [2704] = {itemid = 2704, level = 5, loot = 5901, xp = 1},
    [2705] = {itemid = 2705, level = 15, loot = 5901, xp = 3}
}

function onUse(cid, item, fromPosition, target, toPosition, isHotkey)
    local TREE = trees[target.itemid]

    if not TREE then
        doPlayerSendCancelMessage(cid, "You cannot chop this.")
    return false
    end

    if getPlayerSkillLevel(cid, 7) < TREE.level then
        doPlayerSendCancelMessage(cid, "You are not high enough level to cut this tree.")
    return false
    end
   
    doPlayerAddSkillTry(cid, 7, TREE.xp)
    doSendMagicEffect(toPosition, CONST_ME_HITAREA)
    doPlayerAddItem(cid, TREE.loot, 1)
    doSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_GREEN, "You have successfully...
Because you have those -- before the functions? or you pasted them by mistake on your code? I am not sure.
Just try this one
Lua:
local trees = {
[2704] = {itemid = 2704, level = 5, loot = 5901, xp = 1},
[2705] = {itemid = 2705, level = 15, loot = 5901, xp = 3}

}
function onUse(cid, item, fromPosition, target, toPosition, isHotkey)
local logs = 5901
if trees[target.itemid] then
local skill = getPlayerSkillLevel(cid, 7)
if skill < trees[target.itemid].level then
doPlayerAddSkillTry(cid, 7, trees[target.itemid].xp)
doSendMagicEffect(target, 30)
doPlayerAddItem(cid, trees[target.itemid].loot)
doSendTextMessage(cid, 22, "You couldn't mine anything.")
doSendMagicEffect(CONST_ME_HITAREA)
end
end
end
function onUse(cid, item, fromPosition, itemEx, toPosition)
if getPlayerSkillLevel(cid, 7) < 10 then
doPlayerSendTextMessage(cid, 22, "Precisa de Level 10 em Woodcutting.") else
doPlayerAddItem(cid, logs ,1)
doPlayerSendTextMessage(cid, 22, "You cut a tree.")
doPlayerAddSkillTry(cid, 7, 1)
return true
end
end
 
Because you have those -- before the functions? or you pasted them by mistake on your code? I am not sure.
Just try this one
Lua:
local trees = {
[2704] = {itemid = 2704, level = 5, loot = 5901, xp = 1},
[2705] = {itemid = 2705, level = 15, loot = 5901, xp = 3}

}
function onUse(cid, item, fromPosition, target, toPosition, isHotkey)
local logs = 5901
if trees[target.itemid] then
local skill = getPlayerSkillLevel(cid, 7)
if skill < trees[target.itemid].level then
doPlayerAddSkillTry(cid, 7, trees[target.itemid].xp)
doSendMagicEffect(target, 30)
doPlayerAddItem(cid, trees[target.itemid].loot)
doSendTextMessage(cid, 22, "You couldn't mine anything.")
doSendMagicEffect(CONST_ME_HITAREA)
end
end
end
function onUse(cid, item, fromPosition, itemEx, toPosition)
if getPlayerSkillLevel(cid, 7) < 10 then
doPlayerSendTextMessage(cid, 22, "Precisa de Level 10 em Woodcutting.") else
doPlayerAddItem(cid, logs ,1)
doPlayerSendTextMessage(cid, 22, "You cut a tree.")
doPlayerAddSkillTry(cid, 7, 1)
return true
end
end
Nothing Happens :(
 
What is this? getPlayerSkillLevel(cid, 7) Are you using custom server? Because Cipsoft's Tibia/Classic servers has only skills from 0 to 6, so 7 doesn't mean anything.
 
Try this one
Lua:
local trees = {
[2704] = {itemid = 2704, level = 5, loot = 5901, xp = 1},
[2705] = {itemid = 2705, level = 15, loot = 5901, xp = 3}

}
function onUse(cid, item, fromPosition, target, toPosition, isHotkey)
local logs = 5901
if trees[target.itemid] then
local skill = getPlayerSkillLevel(cid, 7)
if skill < trees[target.itemid].level then
doPlayerAddSkillTry(cid, 7, trees[target.itemid].xp)
doSendMagicEffect(target, 30)
doPlayerAddItem(cid, trees[target.itemid].loot)
doSendTextMessage(cid, 22, "You couldn't mine anything.")
doSendMagicEffect(CONST_ME_HITAREA)
end
end
end
function onUse(cid, item, fromPosition, itemEx, toPosition)
local skill = getPlayerSkillLevel(cid, 7)
if getPlayerSkillLevel(cid, 7) and skill < 10 then
doPlayerSendTextMessage(cid, 22, "Precisa de Level 10 em Woodcutting.") else
doPlayerAddItem(cid, logs ,1)
doPlayerSendTextMessage(cid, 22, "You cut a tree.")
doPlayerAddSkillTry(cid, 7, 1)
return true
end
end
 
Try this one
Lua:
local trees = {
[2704] = {itemid = 2704, level = 5, loot = 5901, xp = 1},
[2705] = {itemid = 2705, level = 15, loot = 5901, xp = 3}

}
function onUse(cid, item, fromPosition, target, toPosition, isHotkey)
local logs = 5901
if trees[target.itemid] then
local skill = getPlayerSkillLevel(cid, 7)
if skill < trees[target.itemid].level then
doPlayerAddSkillTry(cid, 7, trees[target.itemid].xp)
doSendMagicEffect(target, 30)
doPlayerAddItem(cid, trees[target.itemid].loot)
doSendTextMessage(cid, 22, "You couldn't mine anything.")
doSendMagicEffect(CONST_ME_HITAREA)
end
end
end
function onUse(cid, item, fromPosition, itemEx, toPosition)
local skill = getPlayerSkillLevel(cid, 7)
if getPlayerSkillLevel(cid, 7) and skill < 10 then
doPlayerSendTextMessage(cid, 22, "Precisa de Level 10 em Woodcutting.") else
doPlayerAddItem(cid, logs ,1)
doPlayerSendTextMessage(cid, 22, "You cut a tree.")
doPlayerAddSkillTry(cid, 7, 1)
return true
end
end
what was on comments "--" was old script
 
You tried the one I just posted? You had one issue with your script and I think it should have been giving you this error attempt to compare boolean with number
Try the one I posted should work.
 
You tried the one I just posted? You had one issue with your script and I think it should have been giving you this error attempt to compare boolean with number
Try the one I posted should work.
now you cut the tree appers and also adds a try. but didnt give item
also what was on comments isnt the script
 
So where is the script? Post your script full so I can help you?
Anyways I edited the script above now it should be giving the item "Wood"
Lua:
local trees = {
[2704] = {itemid = 2704, level = 5, loot = 5901, xp = 1},
[2705] = {itemid = 2705, level = 15, loot = 5901, xp = 3}

}
function onUse(cid, item, fromPosition, target, toPosition, isHotkey)
local logs = 5901
if trees[target.itemid] then
local skill = getPlayerSkillLevel(cid, 7)
if skill < trees[target.itemid].level then
doPlayerAddSkillTry(cid, 7, trees[target.itemid].xp)
doSendMagicEffect(target, 30)
doPlayerAddItem(cid, trees[target.itemid].loot)
doSendTextMessage(cid, 22, "You couldn't mine anything.")
doSendMagicEffect(CONST_ME_HITAREA)
end
end
end
function onUse(cid, item, fromPosition, itemEx, toPosition)
local logs = 5901
local skill = getPlayerSkillLevel(cid, 7)
if getPlayerSkillLevel(cid, 7) and skill < 10 then
doPlayerSendTextMessage(cid, 22, "Precisa de Level 10 em Woodcutting.") else
doPlayerAddItem(cid, logs ,1)
doPlayerAddSkillTry(cid, 7, 1)
doPlayerSendTextMessage(cid, 22, "You cut a tree.")
return true
end
end
 
Last edited:
So where is the script? Post your script full so I can help you?
Anyways I edited the script above now it should be giving the item "Wood"
Lua:
local trees = {
[2704] = {itemid = 2704, level = 5, loot = 5901, xp = 1},
[2705] = {itemid = 2705, level = 15, loot = 5901, xp = 3}

}
function onUse(cid, item, fromPosition, target, toPosition, isHotkey)
local logs = 5901
if trees[target.itemid] then
local skill = getPlayerSkillLevel(cid, 7)
if skill < trees[target.itemid].level then
doPlayerAddSkillTry(cid, 7, trees[target.itemid].xp)
doSendMagicEffect(target, 30)
doPlayerAddItem(cid, trees[target.itemid].loot)
doSendTextMessage(cid, 22, "You couldn't mine anything.")
doSendMagicEffect(CONST_ME_HITAREA)
end
end
end
function onUse(cid, item, fromPosition, itemEx, toPosition)
local logs = 5901
local skill = getPlayerSkillLevel(cid, 7)
if getPlayerSkillLevel(cid, 7) and skill < 10 then
doPlayerSendTextMessage(cid, 22, "Precisa de Level 10 em Woodcutting.") else
doPlayerAddItem(cid, logs ,1)
doPlayerAddSkillTry(cid, 7, 1)
doPlayerSendTextMessage(cid, 22, "You cut a tree.")
return true
end
end
the code is the one without the comments
 
Try this one its the code without the comments.
Lua:
local trees = {
[2704] = {itemid = 2704, level = 5, loot = 5901, xp = 1},
[2705] = {itemid = 2705, level = 15, loot = 5901, xp = 3}
}

function onUse(cid, item, fromPosition, target, toPosition, isHotkey)
local logs = 5901
if trees[target.itemid] then
local skill = getPlayerSkillLevel(cid, 7)
if getPlayerSkillLevel(cid, 7) and skill < trees[target.itemid].level then
doPlayerAddSkillTry(cid, 7, trees[target.itemid].xp)
doSendMagicEffect(target, 30)
doPlayerAddItem(cid, trees[target.itemid].loot)
doSendTextMessage(cid, 22, "You couldn't mine anything.")
doSendMagicEffect(CONST_ME_HITAREA)
end
end
end
 
Code:
local trees = {
    [2704] = {itemid = 2704, level = 5, loot = 5901, xp = 1},
    [2705] = {itemid = 2705, level = 15, loot = 5901, xp = 3}
}

function onUse(cid, item, fromPosition, target, toPosition, isHotkey)
    local TREE = trees[target.itemid]

    if not TREE then
        doPlayerSendCancelMessage(cid, "You cannot chop this.")
    return false
    end

    if getPlayerSkillLevel(cid, 7) < TREE.level then
        doPlayerSendCancelMessage(cid, "You are not high enough level to cut this tree.")
    return false
    end
   
    doPlayerAddSkillTry(cid, 7, TREE.xp)
    doSendMagicEffect(toPosition, CONST_ME_HITAREA)
    doPlayerAddItem(cid, TREE.loot, 1)
    doSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_GREEN, "You have successfully cut the tree.")
    return true
end
 
Solution
Code:
local trees = {
    [2704] = {itemid = 2704, level = 5, loot = 5901, xp = 1},
    [2705] = {itemid = 2705, level = 15, loot = 5901, xp = 3}
}

function onUse(cid, item, fromPosition, target, toPosition, isHotkey)
    local TREE = trees[target.itemid]

    if not TREE then
        doPlayerSendCancelMessage(cid, "You cannot chop this.")
    return false
    end

    if getPlayerSkillLevel(cid, 7) < TREE.level then
        doPlayerSendCancelMessage(cid, "You are not high enough level to cut this tree.")
    return false
    end
  
    doPlayerAddSkillTry(cid, 7, TREE.xp)
    doSendMagicEffect(toPosition, CONST_ME_HITAREA)
    doPlayerAddItem(cid, TREE.loot, 1)
    doSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_GREEN, "You have successfully cut the tree.")
    return true
end
i will test. send feedback tomorrow.
 
Code:
local trees = {
    [2704] = {itemid = 2704, level = 5, loot = 5901, xp = 1},
    [2705] = {itemid = 2705, level = 15, loot = 5901, xp = 3}
}

function onUse(cid, item, fromPosition, target, toPosition, isHotkey)
    local TREE = trees[target.itemid]

    if not TREE then
        doPlayerSendCancelMessage(cid, "You cannot chop this.")
    return false
    end

    if getPlayerSkillLevel(cid, 7) < TREE.level then
        doPlayerSendCancelMessage(cid, "You are not high enough level to cut this tree.")
    return false
    end
  
    doPlayerAddSkillTry(cid, 7, TREE.xp)
    doSendMagicEffect(toPosition, CONST_ME_HITAREA)
    doPlayerAddItem(cid, TREE.loot, 1)
    doSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_GREEN, "You have successfully cut the tree.")
    return true
end

THX MAN you are amazing!
 
Back
Top