qual error que aparece no seu distro ?
info
Grupo: Campones
Registrado: 05/01/13
Posts: 6
Reputação: 0
Char no Tibia: Slashin Ataiti

Eu tive que adaptar as funções do vodkart, pois iria dar um errozinho ao usar elas seguidas, já que as duas funções pegam informações do player e depois removem ele, assim que a primeira terminasse, a segunda não ia conseguir pegar informações do player (pois ele estaria off) e iria tentar remover ele novamente, sendo que ele já foi removido, então ia dar alguns erros no server, o fist iria aumentar e o magic level não iria diminuir...
o parâmetro newText é uma string cara, um texto, você não pode comparar ela diretamente com um número e muito menos fazer operações aritméticas com textos.
depois que você estava colocando a skill do fist diretamente igual ao texto entrado e o mesmo com magic, então depois de executar a script, um player com magic level 10 e club 10 que escrevesse 5 no texto, iria ficar com 5 de club e -5 de magic level (magic level negativo?)
use assim:
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
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)
if item.itemid ~= 1949 then return true end
local value = tonumber(newText)
if not value then
doPlayerSendCancel(cid, "Por favor, insira um número válido.")
return false
end
local guid = getPlayerGUID(cid)
local magic = getPlayerMagLevel(cid)
local fist = getPlayerSkillLevel(cid, 0)
if magic >= value then
doPlayerSetSkill(guid, 0, fist + value)
doPlayerSetMag(guid, magic - value)
end
return false
end
perceba que ainda há algumas falhas nesse script já que eu não sei o que você pretende fazer, por exemplo, se o player escrever um número negativo na caixa de texto, em vez de perder magic level e ganhar fist, ele estaria perdendo fist e ganhando magic level...
essa script não é lá muito inteligente, pois não há limitações... quero dizer que um cara pra upar o magic level do 0 para 1 leva muito pouco tempo, aí ele passa pra fist, depois upa mais 1 de magic level, e passa de novo... de 1 em 1 o cara consegue pegar 40k fist em 1 dia... mas vai ver o seu server é alternativo e nem usa as skills do tibia, por isso não coloquei nenhuma limitação, mas depois vê isso aí que tá fácil de abusar dessa script
info
Grupo: Visconde
Registrado: 21/09/10
Posts: 319
Reputação: +27
Char no Tibia: lest sarif

Bom , ele simplismente tipo , tera 5 skills .
ai o "MAGIC LEVEL" ,sao os POINTS.
ai voce remove os points , e adiciona
e tipo , o max level de cada SKILL é 100.
Editado Janeiro 6 por tonynamoral
info
Grupo: Marquês
Registrado: 02/08/12
Posts: 1k
Reputação: +234
Char no Tibia: Maurolkit

local limite = 100
function onTextEdit(cid, item, newText)
if item.itemid == 1949 then
if tonumber(newText) then
if newText < limite then
if getPlayerMagicLevel(cid) >= newText then
doPlayerSetMagic(cid, math.abs(getPlayerMagicLevel(cid) - newText))
doPlayerSetSkill(cid, 0, newText)
doPlayerSendTextMessage(cid, 27, "Compra de fist fighting efetivada com sucesso.")
else
doPlayerSendCancel(cid, "Sorry, you don't have magic level for this.")
end
else
doPlayerSendCancel(cid, "You can't buy this number of magic level")
end
else
doPlayerSendCancel(cid, "Only number's alowed.")
end
end
return true
end
Editado Janeiro 6 por Skymagnum
info
Grupo: Visconde
Registrado: 21/09/10
Posts: 319
Reputação: +27
Char no Tibia: lest sarif

E tipo , como será + de 1 skills , como eu adiciono mais items e talz?
Skymagnum, newText nunca vai ser um número, na verificação isNumber já ia dar false e ia sempre falar que só números são permitidos... você tem que passar ele pra número usando tonumber ou envolvendo em parênteses, mas é melhor usar tonumber, pois se não for possível transformar em número, retorna nil. também cometeu o mesmo erro que o tony, está mudando diretamente a skill de fist para o valor inserido na caixa, em vez de aumentar a skill.
Tá aqui tony, veja se esse jeito te agrada:
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
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,
[1949] = SKILL_FIST,
}
local maxSkills = 100
local skillId = skillTable[item.itemid]
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
end
local guid = getPlayerGUID(cid)
local points = getPlayerMagLevel(cid)
local skill = getPlayerSkillLevel(cid, skillId)
if points < value then
doPlayerSendCancel(cid, "Você não tem points suficientes.")
return false
end
if skill >= maxSkills then
doPlayerSendCancel(cid, "Sua skill já está no máximo.")
return false
end
local newValue = math.min(skill + value, maxSkills)
doPlayerSetSkill(guid, skillId, newValue)
doPlayerSetMag(guid, points - newValue + skill)
return false
end
info
Grupo: Marquês
Registrado: 02/08/12
Posts: 1k
Reputação: +234
Char no Tibia: Maurolkit

Hum, valeu brunm123 não sabia dessa ;d.
info
Grupo: Visconde
Registrado: 21/09/10
Posts: 319
Reputação: +27
Char no Tibia: lest sarif

Brun . PERFEITO *-----------------------------------------------*





info
Grupo: Visconde
Registrado: 21/09/10
Posts: 319
Reputação: +27
Char no Tibia: lest sarif
Galera , criei esse script porém ele nao está funcionando '-'
Como deveria funcionar : OBS¹ : eu adicionei 2 funçoes do VODKART se eu nao me engano
vou postalar aki
Funçoes : doPlayerSetSkill / doPlayerSetMag
function doPlayerSetSkill(cid, skill, amount) local pid = getPlayerGUID(cid) doRemoveCreature(cid,true) db.executeQuery("UPDATE `player_skills` SET `value` = ".. amount .." WHERE `player_id` = ".. pid .. " and `skillid` = ".. skill ..";") return TRUE end function doPlayerSetMagic(cid, amount) local pid = getPlayerGUID(cid) doRemoveCreature(cid,true) db.executeQuery("UPDATE `players` SET `maglevel` = " .. amount .. " WHERE `id` = "..pid) return TRUE endComo deveria funcionar : o cara abre o item , digita quantas skills ele ker no e aperta OK lá d boa. ai adiciona o numero que ele digito em FIST FIGHT.
e removeria o MAGIC LEVEL.
entao galera , é isso ai