Opa galera,
To montando um servidor, to com dois scripts aqui e preciso de ajuda..
1 - To usando um sistema de SHOP ingame, queria que na talk !infoshop aparecesse os creditos ( Voce Possui ..X.. Créditos ):
Sistema de créditos que uso é:
function onSay(cid, words, param)
local t = {
["blessed shield"] = {item ={2523,1},creditos = 8000},
["medal of honour"] = {item ={5785,1},creditos = 5000},
["golden bow"] = {item ={7438,1},creditos = 28000},
["lunar staff"] = {item ={7424,1},creditos = 28000},
["soft boots"] = {item ={2640,1},creditos = 10000}
}
local param,str = string.lower(param),""
if param == "" then
doPlayerSendTextMessage(cid, 27, "Voce possui "..getCreditos(cid).." creditos.") return true
elseif param == 'lista' then
for name, x in pairs(t) do
str = str.."\nItem: "..name.." -> Preço: [" ..x.creditos.."] Creditos"
end
doPlayerPopupFYI(cid, str) return true
end
local buy = t[param]
if not(buy) then
doPlayerSendTextMessage(cid, 22, "desculpe, mas este comando não existe, digite !shop lista") return true
elseif getCreditos(cid) < buy.creditos then
doPlayerSendTextMessage(cid, 22, "desculpe, mas você precisa de "..buy.creditos.." creditos para comprar o "..param) return true
end
local desc = doPlayerAddItem(cid, buy.item[1],buy.item[2])
doItemSetAttribute(desc,"description","Este Item foi comprado por "..getPlayerName(cid)..".")
removeCreditos(cid,buy.creditos)
doPlayerSendTextMessage(cid, 27, "Parabéns! você comprou "..buy.item[2].." ".. getItemNameById(buy.item[1]) ..".")
return true
end
Talk:
local config = {rateExp = getConfigInfo('rateExp'),
rateSkill = getConfigInfo('rateSkill'),
rateLoot = getConfigInfo('rateLoot'),
rateMagic = getConfigInfo('rateMagic'),
rateSpawn = getConfigInfo('rateSpawn'),
protectionLevel = getConfigInfo('protectionLevel')
}
function onSay(cid, words, param)
local str = "#O AbsolutOT é o unico servidor de tibia que tem como doaçoes vip utilizando creditos.#\n\n[Preços]\n[R$5,00] = 1000 de creditos\n[R$10,00] = 2100 de creditos\n[R$15,00] = 3300 de creditos\n[R$20,00] = 5000 de creditos\n[R$30,00] = 8000 de creditos\n[R$40,00] = 12000 de creditos\n[R$70,00] = 20000 de creditos\n[R$100,00] = 28000 de creditos\n\n\n --------------------------------------------------------------------\n-Protection level: " .. config.protectionLevel
doPlayerPopupFYI(cid, str)
return FALSE
end
2 - To usando um sistema de refinamento igual de MU Online, uma gema refina o item até +6 outro até +10, ai tem um bug, quando refina shield aumenta atk, segue script:
Lib:
-- Perfect Refine System
Refine = {
--[[
Base de todo o sistema de refino
]]--
config = {
max = 10, -- Nível máximo de refino padrão
message = { -- Mensagens enviadas pelo sistema
type = MESSAGE_EVENT_DEFAULT,
onSuccess = "Your %s has upgraded to level +%s",
onFail = "Your %s has downgraded to level +%s",
onBreak = "Your %s has broken",
invalidGem = "This is not a valid refine gem",
gemLevel = "This gem can refine only to level +%s",
maxLevel = "Your %s is already in max level"
},
--[[
O seguinte array controla os diferentes atributos que podem
melhorados no refino.
attributes = {{"attack", false}, {"defense", false}, {"armor", false}}
A configuração dele é realmente simples, os valores booleanos dizem respeito
ao ganho de pontos no referido atributo. Se 'true' o ganho é igual ao nível do item,
se 'false' o ganho é 1.
Note que eu configurei para 'attack', 'defense' como 'true' e 'armor' e 'hitchance' como 'false'.
]]--
attributes = {{"attack", false}, {"defense", false}, {"armor", false}},
--[[
´ Este array configura o sistema de quebra de equipamento, deixando o sistema muito mais real.
Configurei para que a quebra só fosse possível depois do +7 com uma chance de 20%.
Ou seja se o jogador falhar no refino de um equipamento +7 ou superior, tem 20% de chance de quebrar
e perder este equipamento.
]]--
breakConfig = {level = 7, chance = 20},
--[[
Essa opção ativa o broadcast para quando o jogador refinar um equipamento para +7 ou mais.
]]--
doBroadcast = true,
--[[
Essa função calcula a chance de sucesso do refino, veja a chance de alguns.
+1 = 100%
+2 = 91%
+3 = 81%
...
+10 = 10%
]]--
chance = function(level)
return math.floor(100 - (((level * 2 * 3) - (level + 1)) * 2.04))
end
},
gems = {
--[[
Configure aqui as "pedras" que refinam itens.
Você pode configurar quantas pedras quiser e limitar o nível que essa pedra pode fortalecer.
Configurei duas, uma pode fortalecer até +6 e a outra até +10.
Você pode criar também pedras que dão bônus na chance total de refino
]]--
[2158] = {max = 6, bonus = 0},
[2153] = {max = 10, bonus = 0}
},
isEquipment = function(self)
local weapontype = self:getItemWeaponType()
if (weapontype > 0 and weapontype < 7) or self.item.info.armor ~= 0 then
return true
end
return false
end,
setItemName = function(self, name)
return doItemSetAttribute(self.item.uid, "name", name)
end,
getItemKeyValue = function(self, key)
return getItemAttribute(self.item.uid, key)
end,
setItemKeyValue = function(self, key, value)
return doItemSetAttribute(self.item.uid, key, value)
end,
removeItem = function(self, count)
return doRemoveItem(self.item.uid, count)
end
}
function Refine:load(item)
--[[
Função que carrega o item a ser refinado na forma de um objeto.
E você pode usar qualquer função Lua/Open Tibia que se utilize do uid do item como
um método da classe Refine
Ou seja, é totalmente possível fazer isso em uma Action, por exemplo:
local obj = Refine:load(itemEx)
obj:doRemoveItem(1)
Ao invés de
doRemoveItem(item.uid, 1)
end
]]--
local obj = setmetatable({item = {uid = item.uid, info = getItemInfo(item.itemid)}}, {__index = function(self, index)
if _G[index] then
return setmetatable({callback = _G[index]}, {__call = function(self, ...)
return self.callback(item.uid, ...)
end})
else
return Refine[index]
end
end})
if not obj:isEquipment() then
return false
end
obj:getLevel()
return obj
end
function Refine:getLevel()
local info = self:getItemName():match("%+(%d+)")
self.item.level = (tonumber(info) or 0)
return true
end
function Refine:upgrade(cid, gem)
--[[
Função principal do sistema
]]--
local refineItem = self.gems[gem.itemid]
if not refineItem then
doPlayerSendTextMessage(cid, self.config.message.type, self.config.message.invalidGem)
return false
end
if self.item.level == self.config.maxLevel then
doPlayerSendTextMessage(cid, self.config.message.type, self.config.message.maxLevel)
return false
else
if self.item.level >= refineItem.max then
doPlayerSendTextMessage(cid, self.config.message.type, self.config.message.gemLevel:format(refineItem.max))
return false
end
end
doRemoveItem(gem.uid, 1)
if math.random(1, 100) <= self.config.chance(self.item.level) + refineItem.bonus then
doPlayerSendTextMessage(cid, self.config.message.type, self.config.message.onSuccess:format(self:getItemName(), (self.item.level + 1)))
if self.config.doBroadcast == true and (self.item.level + 1) >= 7 then
doBroadcastMessage("The ".. self:getItemName() .." of ".. getCreatureName(cid) .." is now in level +".. self.item.level + 1 ..".")
end
if self.item.level > 0 then
self:setItemName(self:getItemName():gsub("%+(%d+)", "+".. (self.item.level + 1)))
local p = self.config.attributes
for i = 1, #p do
if self:getItemKeyValue(p[1]) ~= nil then
self:setItemKeyValue(p[1], (self:getItemKeyValue(p[1]) + (p[2] == true and (self.item.level + 1) or 1)))
end
end
else
self:setItemName(self:getItemName() .." +1")
local p = self.config.attributes
for i = 1, #p do
if self.item.info[p[1]] ~= 0 or self:getItemWeaponType() ~= 5 then
self:setItemKeyValue(p[1], self.item.info[p[1]] + 1)
end
end
end
return true
else
doPlayerSendTextMessage(cid, self.config.message.type, self.config.message.onFail:format(self:getItemName(), (self.item.level - 1)))
if self.config.breakConfig.chance > 0 and math.random(1, 100) <= self.config.breakConfig.chance and self.item.level >= self.config.breakConfig.level then
doPlayerSendTextMessage(cid, self.config.message.type, self.config.message.onBreak:format(self:getItemName()))
self:removeItem(1)
else
if self.item.level > 1 then
self:setItemName(self:getItemName():gsub("%+(%d+)", "+".. (self.item.level - 1)))
local p = self.config.attributes
for i = 1, #p do
if self:getItemKeyValue(p[1]) ~= nil then
self:setItemKeyValue(p[1], (self:getItemKeyValue(p[1]) - (p[2] == true and self.item.level or 1)))
end
end
else
self:setItemName(self.item.info.name)
local p = self.config.attributes
for i = 1, #p do
if self.item.info[p[1]] ~= 0 or self:getItemWeaponType() ~= 5 then
self:setItemKeyValue(p[1], self.item.info[p[1]])
end
end
end
end
return false
end
end
Action:
function onUse(cid, item, fromPosition, itemEx, toPosition)
local obj = Refine:load(itemEx)
if obj and obj:upgrade(cid, item) then
doSendMagicEffect(toPosition, CONST_ME_MAGIC_GREEN)
else
doSendMagicEffect(toPosition, CONST_ME_POFF)
return false
end
return true
end
alguem pode me ajudar?
alguém ai me ajuda ?