• Congratulations to the OTLand January Mapping Competition Winner! The grand prize of Otland Premium goes to Andréew.
  • Sign up for February Mapping Competition! The prize includes Otland Premium time.
  • 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
Best answers
0
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
 

M0ustafa

Î Àm ŁĕğẹňĎ
Premium User
Support Team
Joined
Mar 4, 2017
Messages
1,301
Best answers
153
Reaction score
477
Location
Egypt
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
 
OP
G

Guiizuka97

New Member
Joined
Sep 9, 2019
Messages
11
Best answers
0
Reaction score
0
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 :(
 

M0ustafa

Î Àm ŁĕğẹňĎ
Premium User
Support Team
Joined
Mar 4, 2017
Messages
1,301
Best answers
153
Reaction score
477
Location
Egypt
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.
 
OP
G

Guiizuka97

New Member
Joined
Sep 9, 2019
Messages
11
Best answers
0
Reaction score
0
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.
yes im. is a woodcutting skill edited on sources
 

M0ustafa

Î Àm ŁĕğẹňĎ
Premium User
Support Team
Joined
Mar 4, 2017
Messages
1,301
Best answers
153
Reaction score
477
Location
Egypt
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
 
OP
G

Guiizuka97

New Member
Joined
Sep 9, 2019
Messages
11
Best answers
0
Reaction score
0
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
 

M0ustafa

Î Àm ŁĕğẹňĎ
Premium User
Support Team
Joined
Mar 4, 2017
Messages
1,301
Best answers
153
Reaction score
477
Location
Egypt
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.
 
OP
G

Guiizuka97

New Member
Joined
Sep 9, 2019
Messages
11
Best answers
0
Reaction score
0
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
 

M0ustafa

Î Àm ŁĕğẹňĎ
Premium User
Support Team
Joined
Mar 4, 2017
Messages
1,301
Best answers
153
Reaction score
477
Location
Egypt
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:
OP
G

Guiizuka97

New Member
Joined
Sep 9, 2019
Messages
11
Best answers
0
Reaction score
0
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
 

M0ustafa

Î Àm ŁĕğẹňĎ
Premium User
Support Team
Joined
Mar 4, 2017
Messages
1,301
Best answers
153
Reaction score
477
Location
Egypt
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
 

Itutorial

Veteran OT User
Joined
Dec 23, 2014
Messages
1,542
Best answers
35
Reaction score
381
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
 
OP
G

Guiizuka97

New Member
Joined
Sep 9, 2019
Messages
11
Best answers
0
Reaction score
0
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.
 
OP
G

Guiizuka97

New Member
Joined
Sep 9, 2019
Messages
11
Best answers
0
Reaction score
0
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!
 
Top