Spell com tabela

textoy
Por textoy
em Scripts

textoy

avatar
Campones
Campones

INFOS

Grupo: CamponesRegistrado: 06/06/13Posts: 19Char no Tibia: Mister M

Gurizada, to morrendo pra descobrir. O objetivo é uma magia que quando usada pega o target e compara com uma tabela, se o target for igual da tabela, ele adiciona uma storage baseada na própria tabela, se nao manda erro.

A tabela se comporta assim: {monstro, monstro, monstro, monstro}

que é lido pela storage como:{1, 2, 3, 4}

 

porém nao ta funcionando, alguém pode me ajudar ?

 

 

 

 

local pets = {"Wolf", "Bear", "Spider", "Scorpion"}
function onCastSpell(cid, var)
local target = getCreatureName(getCreatureTarget(cid))
for i = 1, #pets do
local pet = pets
if target ~= i then
doPlayerSendCancel(cid, "You cant tame this creature.")
elseif target == i then
setPlayerStorageValue(cid, 3010, pet)
end
end
end

 

 

zipter98

avatar
Herói
Herói

INFOS

Grupo: HeróiRegistrado: 20/09/12Posts: 2553Gênero: Masculino


local pets = {"Wolf", "Bear", "Spider", "Scorpion"}

 

function onCastSpell(cid, var)

local target_name = getCreatureName(variantToNumber(var))

 

if not isMonster(variantToNumber(var)) then

doPlayerSendCancel(cid, "You can't use this spell on players.")

return true

elseif not isInArray(pets, target_name) then

doPlayerSendCancel(cid, "You can't tame this creature.")

return true

end

 

doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You successfully tamed "..target_name..".")

setPlayerStorageValue(cid, 3010, table.find(pets, target_name))

return true

end

 

Não respondo PMs solicitando suporte. Já existem seções no fórum para isto.

Night Wolf

Coordenador de Desenvolvimento
avatar
Herói
Herói

INFOS

Grupo: HeróiRegistrado: 14/02/14Posts: 341Gênero: MasculinoChar no Tibia: Night Wolf

^só lembra de colocar no xml needtarget = "1"

I9AtE9T.png
/NW