Dá uma olhada no que eu fiz:
local maxSkills = 100
local skillTable = { --[id do item] = id da skill,
[2400] = {id = 0, count = 1, add = "none"}, -- Strenght
[2404] = {id = 1, count = 3, add = "speed"}, -- Agility
[2403] = {id = 2, count = 20, add = "health"}, -- Vitality
[2402] = {id = 3, count = 15, add = "mana"}, -- Energy
[2401] = {id = 4, count = 1, add = "none"}, -- Range
[2405] = {id = 5, count = 1, add = "none"}, -- Defense
}
local function doPlayerSetSkill(pid, skill, amount)
local player = getPlayerByGUID(pid)
if isCreature(player) then
doRemoveCreature(player, true)
end
db.executeQuery("UPDATE `player_skills` SET `value` = ".. amount .." WHERE `player_id` = ".. pid .. " and `skillid` = ".. skill ..";")
return true
end
local function doPlayerSetMagic(pid, amount)
local player = getPlayerByGUID(pid)
if isCreature(player) then
doRemoveCreature(player, true)
end
db.executeQuery("UPDATE `players` SET `maglevel` = " .. amount .. " WHERE `id` = "..pid)
return true
end
function onTextEdit(cid, item, newText)
local skillId = skillTable[item.itemid]
if not skillId then
return true
end
local guid = getPlayerGUID(cid)
local points = getPlayerMagLevel(cid)
local skill = getPlayerSkillLevel(cid, skillId.id)
local value = tonumber(newText)
if not value or value < 0 then
doPlayerSendCancel(cid, "Por favor, insira um número válido.")
return false
elseif getPlayerPz(cid) then
doPlayerSendCancel(cid, "Você não pode estar em PZ.")
return false
elseif points < value then
doPlayerSendCancel(cid, "Você não tem points suficientes.")
return false
elseif skill >= maxSkills then
doPlayerSendCancel(cid, "Sua skill já está no máximo.")
return false
end
local newValue = math.min(skill + value, maxSkills)
if skillId.add == "none" then
return false
elseif skillId.add == "speed" then
doChangeSpeed(cid, getCreatureSpeed(cid)+(value*skillId.count))
elseif skillId.add == "health" then
setCreatureMaxHealth(cid, getCreatureMaxHealth(cid)+(value*skillId.count))
elseif skillId.add == "mana" then
setCreatureMaxMana(cid, getCreatureMaxMana(cid)+(value*skillId.count))
end
doPlayerSetSkill(guid, skillId.id, newValue)
doPlayerSetMagic(guid, points - newValue + skill)
return false
end
Sugiro que você leia esse Tópico:





info
Grupo: Visconde
Registrado: 21/09/10
Posts: 319
Reputação: +27
Char no Tibia: lest sarif
fala ai galera , eu tenho 1 script aqui , que está entrando em conflito com o outro.
Error :
Primeiro SCRIPT : Skillsids.lua
local function doPlayerSetSkill(pid, skill, amount)
local player = getPlayerByGUID(pid)
if isCreature(player) then doRemoveCreature(player, true) end
db.executeQuery("UPDATE `player_skills` SET `value` = ".. amount .." WHERE `player_id` = ".. pid .. " and `skillid` = ".. skill ..";")
return true
end
local function doPlayerSetMagic(pid, amount)
local player = getPlayerByGUID(pid)
if isCreature(player) then doRemoveCreature(player, true) end
db.executeQuery("UPDATE `players` SET `maglevel` = " .. amount .. " WHERE `id` = "..pid)
return true
end
function onTextEdit(cid, item, newText)
local skillTable = { --[id do item] = id da skill,
[2400] = {id = 0, count = 1, add = "none"}, -- Strenght
[2404] = {id = 1, count = 3, add = "speed"}, -- Agility
[2403] = {id = 2, count = 20, add = "health"}, -- Vitality
[2402] = {id = 3, count = 15, add = "mana"}, -- Energy
[2401] = {id = 4, count = 1, add = "none"}, -- Range
[2405] = {id = 5, count = 1, add = "none"}, -- Defense
}
local maxSkills = 100
local skillId = skillTable[item.itemid]
local guid = getPlayerGUID(cid)
local points = getPlayerMagLevel(cid)
local skill = getPlayerSkillLevel(cid, skillId.id)
if not skillId then return true end
local value = tonumber(newText)
if not value or value < 0 then
doPlayerSendCancel(cid, "Por favor, insira um número válido.") return false
elseif getPlayerPz(cid) then
doPlayerSendCancel(cid, "Você não pode estar em PZ.") return false
elseif points < value then
doPlayerSendCancel(cid, "Você não tem points suficientes.") return false
elseif skill >= maxSkills then
doPlayerSendCancel(cid, "Sua skill já está no máximo.") return false
end
local newValue = math.min(skill + value, maxSkills)
if skillId.add == "none" then
elseif skillId.add == "speed" then
doChangeSpeed(cid, getCreatureSpeed(cid)+(value*skillId.count))
elseif skillId.add == "health" then
setCreatureMaxHealth(cid, getCreatureMaxHealth(cid)+(value*skillId.count))
elseif skillId.add == "mana" then
setCreatureMaxMana(cid, getCreatureMaxMana(cid)+(value*skillId.count))
end
doPlayerSetSkill(guid, skillId.id, newValue)
doPlayerSetMagic(guid, points - newValue + skill)
return false
end
Eu gostaria que voces podessem me falar qual é o error e solucionar pra eu *--*
Editado Janeiro 6 por tonynamoral