Entao Max, eu andei um tempo dando uma estudada, mas como já falei, sou iniciante pura!
Acontece que no script a descrição do item já vai estar pré-selecionada.
Você chegou a testar isso?
function onStepIn(cid, item, position, fromPosition) local item = getPlayerItemById(cid, true, 2379) local desc = getItemAttribute(item.uid, "description") local predefinido = 'Bought by Teste [iD:2379].' if item.itemid >= 1 and string.find(desc, predefinido) then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Deu certo!") end return true end
Certamente não vai aparecer a mensagem "Deu certo!". Mesmo vc tendo o itemid 2379 e com a descrição 'Bought by Teste [iD:2379].'
Eu fiz muitos e muitos testes, quando o Brun123 mencionou o uso da % na frente do [ ] então ai sim funcionou.
Ficou assim:
function onStepIn(cid, item, position, fromPosition) local item = getPlayerItemById(cid, true, 2379) local desc = getItemAttribute(item.uid, "description") local predefinido = 'Bought by Teste %[iD:2379].' if item.itemid >= 1 and string.find(desc, predefinido) then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Deu certo!") end return true end






info
Grupo: Barão
Registrado: 18/10/10
Posts: 246
Reputação: +89
Char no Tibia: Elite Pamcadaum
Sim, mas na string que deve ser buscada não há nenhum pattern '-'.
@Tópico
Olha, aparentemente não tem nada de errado com o código, Teríamos que ver a descrição do item pra ver como tá ficando, eu testei assim:
local item = getPlayerItemById(cid, true, 2379) local desc = getItemAttribute(item.uid, "description") if item.uid > 100 and desc:find(" ".. getCreatureName(cid) .." ") then print("All right") ende deu certo.
Descrição do meu item:
Faz esse teste:
local desc = getItemAttribute(getPlayerItemById(cid, true, 2379).uid, "description") print("\"".. desc .. "\"")