@Altairjr veja se funciona ai bro (não testei). Qualquer erro me manda aqui :d
local combat_values = {
["none"] = -1,
["ice"] = 1,
["fire"] = 2,
["earth"] = 3,
["energy"] = 4,
["holy"] = 5,
["death"] = 6,
}
local config = {
storage = 101010,
time_storage = 101011,
price = 1000000,
delay = 0,
msg = {
help = "Use o comando exemplo: !wand holy Efeitos disponíveis: ice, fire, earth, energy, holy, death, e none para desabilitar. A troca para outro elemento custa 1kk.",
invalid = "Por favor, digite um tipo valido.",
changed = "O elemento da wand foi trocado para %s.",
nomoney = "Você não possui dinheiro.",
delayed = "Você precisa esperar para trocar o efeito.",
}
}
-- /////////////////////Requerimentos///////////////////--
local req_text = "You cannot use this command." -- Mensagem caso nao possua o item
--/////////////////////////////////////////////////////--
function onSay(cid, words, param)
local param = param:lower()
local value = combat_values[param]
local wand_left = getPlayerSlotItem(cid, CONST_SLOT_LEFT)
local wand_right = getPlayerSlotItem(cid, CONST_SLOT_RIGHT)
if wand_left.uid > 0 or wand_right.uid > 0 then
if wand_left.uid > 0 and (param == "help" or param == "") then
doShowTextDialog(cid, wand_left.itemid, string.format(config.msg.help, config.price))
return true
elseif wand_right.uid > 0 and (param == "help" or param == "") then
doShowTextDialog(cid, wand_right.itemid, string.format(config.msg.help, config.price))
return true
end
if not value then
doPlayerSendCancel(cid, config.msg.invalid)
return true
end
if getPlayerMoney(cid) < config.price then
doPlayerSendCancel(cid, config.msg.nomoney)
return true
end
if getPlayerMoney(cid) < config.price then
doPlayerSendCancel(cid, config.msg.nomoney)
return true
end
if getCreatureStorage(cid, config.time_storage) + config.delay > os.time() then
doPlayerSendCancel(cid, config.msg.delayed)
return true
end
doCreatureSetStorage(cid, config.storage, value)
doCreatureSetStorage(cid, config.time_storage, os.time())
doPlayerRemoveMoney(cid, config.price)
doPlayerSendCancel(cid, string.format(config.msg.changed, param))
else
doPlayerSendCancel(cid, req_text)
end
return true
end