Olá XTibianos, vim trazer um novo sistema que criei nomeado por min como: Sistema de Durabilidade!
Qual a funcionalidade desse sistema:
Esse sistema tem a função de atribuir pontos de durabilidade em diversos tipos de itens, trazendo assim um pouco mais de realidade ao mundo do tibia, simulando batalhas onde os seus itens vão se desgastando até virarem inuteis.
Quais tipos de itens que podem ser adicionados esses pontos:
-
Weapons
-
Shields
-
Armors
-
Legs
-
Helmet
-
Boots
Como esses pontos diminuem:
Conforme o player vai batalhando, os pontos de durabilidade de todos os itens que estão sendo usados vão diminuindo até chegar a 0.
Oque acontese se os pontos chegarem a 0:
Se os pontos da sua weapon chegarem a 0, você não consiguira mais atacar o monstro.
Ja se o pontos do seu shield chegarem a 0, a defesa dele é setada para def=0.
E os outros itens do seu set que tiverem os pontos de durabilidades zerados, receberam arm=0.
E com isso você tem necessidade de reparar esses itens para voltar ao normal.
Como reparar esses itens:
Eu irei postar duas formas de reparação de itens, um npc e uma talkaction. Vocês devem usar a que acharem de melhor adaptação em seu otserv.
O itens podem ser reparados mesmo sem estar com os pontos iguais a 0, sera cobrado uma taxa por cada ponto de durabilidade reparado dos itens, esse preço é configuravel no scripts.
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Vamos aos primeiros scripts do sistema:
Primeiramente vai na pasta data/creaturescripts/scripts, duplica um arquivo e nomeia para "durWeapons" sem as apas e nele cole:
function onStatsChange(cid, attacker, type, combat, value) chance = 970 if type == STATSCHANGE_HEALTHLOSS then if isPlayer(attacker) then local slotWeapon = nil if weapons[getPlayerSlotItem(attacker, CONST_SLOT_RIGHT).itemid] then slotWeapon = CONST_SLOT_RIGHT elseif weapons[getPlayerSlotItem(attacker, CONST_SLOT_LEFT).itemid] then slotWeapon = CONST_SLOT_LEFT end if slotWeapon == nil then return true end if (getItemAttribute(getPlayerSlotItem(attacker, slotWeapon).uid, "Charges") == "Broken") then doPlayerSendTextMessage(attacker, 22, "Sua weapon esta quebrada.") return false elseif (math.random(1,1000) > chance) then setDurabilidade(attacker, slotWeapon, weapons) end end elseif type == STATSCHANGE_HEALTHGAIN then return false end return true end function onCombat(cid, target) registerCreatureEvent(target, "DurGain") return true end
Agora duplique outro arquivo nessa mesma pasta e nomeie para "durItens" sem as aspas e nele cole:
local slotShield = nil local slotArmor = nil local slotLegs = nil local slotHelmet = nil local slotBoots = nil local slots = { [1] = {slot=slotHelmet, lib=helmets}, [4] = {slot=slotArmor, lib=armors}, [5] = {slot=slotShield, lib=shields}, [6] = {slot=slotShield, lib=shields}, [7] = {slot=slotLegs, lib=legs}, [8] = {slot=slotBoots, lib=boots} } function onThink(cid, interval) if (isPlayer(cid)) then for i=1, 8 do if slots[i] ~= nil then if slots[i].lib[getPlayerSlotItem(cid, i).itemid] then slots[i].slot = i if setDurMaxHit(cid, slots[i].slot, slots[i].lib) then return true end end end end local slotWeapon = nil if weapons[getPlayerSlotItem(cid, CONST_SLOT_RIGHT).itemid] then slotWeapon = CONST_SLOT_RIGHT elseif weapons[getPlayerSlotItem(cid, CONST_SLOT_LEFT).itemid] then slotWeapon = CONST_SLOT_LEFT end if slotWeapon ~= nil then if setDurMaxHit(cid, slotWeapon, weapons) then return true end end if getPlayerStorageValue(cid, 456431) < 0 then chance = math.random(15,30) setPlayerStorageValue(cid, 456432, chance) end chance = getPlayerStorageValue(cid, 456432) if(getCreatureCondition(cid, CONDITION_INFIGHT)) and getPlayerStorageValue(cid, 456431) < chance then local health = getCreatureHealth(cid) setPlayerStorageValue(cid, 456431, getPlayerStorageValue(cid, 456431)+1) if getPlayerStorageValue(cid, 456431) == chance-1 then addEvent(verificaLife, 1000, health, cid) setPlayerStorageValue(cid, 456431, -1) end end end end function verificaLife(health, cid) if (isPlayer(cid)) then if getCreatureHealth(cid) < health then for i=1, 8 do if slots[i] ~= nil then if slots[i].lib[getPlayerSlotItem(cid, i).itemid] then slots[i].slot = i addEvent(setDurabilidade, math.random(10000,60000), cid, slots[i].slot, slots[i].lib) end end end end end end
Depois disso, abra o arquivo creaturescripts.xml que fica na pasta data/creaturescripts e nele cole essas três tags:
<event type="think" name="DurabTime" event="script" value="durItens.lua"/> <event type="statschange" name="DurGain" event="script" value="durWeapons.lua"/> <event type="combat" name="Durab" event="script" value="durWeapons.lua"/>
E para terminar a parte de creaturescripts, vai na pasta data/creaturescripts/scripts, abre a arquivo login.lua e antes do último return true cole:
registerCreatureEvent(cid, "Durab") registerCreatureEvent(cid, "DurabTime")
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Agora vamos pra parte de configuração do script, nesse script você deve configurar os itens que terão pontos de durabilidade, quantos pontos eles terão, se for shield você deve por qual sua "def" normal e se for outros itens do set deve por a sua "arm" normal.
Vai na pasta data/lib, duplica um arquivo, nomeie para "039-durabilidade" sem as aspas e nele cole:
weapons = { [2421] = {charge=100}, [2415] = {charge=50}, [2404] = {charge=50} } shields = { [2516] = {charge=50, def=31}, -- dragon shield [2520] = {charge=50, def=35} -- demon shield } armors = { [2486] = {charge=50, arm=15} } legs = { [7894] = {charge=50, arm=8} } helmets = { [2501] = {charge=50, arm=7} } boots = { [11113] = {charge=50, arm=3} } -- Não configurar daqui para baixo -- function isWeapon(uid) -- Function by Mock the bear. uid = uid or 0 local f = getItemWeaponType(uid) if f == 1 or f == 2 or f == 3 then return TRUE end return FALSE end function isShield(uid) -- Function by Mock the bear. uid = uid or 0 if getItemWeaponType(uid) == 4 then return TRUE end return FALSE end function setItemName(uid,name) -- Function by Mock the bear. return doItemSetAttribute(uid,'name',name) end function setItemDefense(uid,name) -- Function by Mock the bear. return doItemSetAttribute(uid,'defense',name) end function setItemArmor(uid,name) -- Function by Mock the bear. return doItemSetAttribute(uid,'armor',name) end function setDurabilidade(cid, slot, lib) if (isPlayer(cid)) then if getPlayerSlotItem(cid, slot).uid > 0 then if (getItemAttribute(getPlayerSlotItem(cid, slot).uid, "Charges")) ~= "Broken" then doItemSetAttribute(getPlayerSlotItem(cid, slot).uid, "Charges", (getItemAttribute(getPlayerSlotItem(cid, slot).uid, "Charges")) - 1) setItemName(getPlayerSlotItem(cid, slot).uid, getItemNameById(getPlayerSlotItem(cid, slot).itemid)..' [Dur: '.. (getItemAttribute(getPlayerSlotItem(cid, slot).uid, "Charges")) ..'/'.. lib[getPlayerSlotItem(cid, slot).itemid].charge ..']') if getItemAttribute(getPlayerSlotItem(cid, slot).uid, "Charges") <= 0 then doPlayerSendTextMessage(cid, 22, "Your item has broken.") if (isShield(getPlayerSlotItem(cid, slot).uid)) then setItemDefense(getPlayerSlotItem(cid, slot).uid, 0) end if (not isShield(getPlayerSlotItem(cid, slot).uid) and not isWeapon(getPlayerSlotItem(cid, slot).uid)) then setItemArmor(getPlayerSlotItem(cid, slot).uid, 0) end doSendMagicEffect(getPlayerPosition(cid), 2) doItemSetAttribute(getPlayerSlotItem(cid, slot).uid, "Charges", "Broken") return true end else doSendMagicEffect(getPlayerPosition(cid), 2) return false end end end end function setDurMaxHit(cid, slot, lib) if (getItemAttribute(getPlayerSlotItem(cid, slot).uid, "Charges")) ~= "Broken" then if (getItemAttribute(getPlayerSlotItem(cid, slot).uid, "Charges") == nil or getItemAttribute(getPlayerSlotItem(cid, slot).uid, "Charges") == 0 and slot ~= nil) then doItemSetAttribute(getPlayerSlotItem(cid, slot).uid, "Charges", lib[getPlayerSlotItem(cid, slot).itemid].charge) setItemName(getPlayerSlotItem(cid, slot).uid, getItemNameById(getPlayerSlotItem(cid, slot).itemid)..' [Dur: '.. (getItemAttribute(getPlayerSlotItem(cid, slot).uid, "Charges")) ..'/'.. lib[getPlayerSlotItem(cid, slot).itemid].charge ..']') return true end end return false end
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Por fim, vamos criar a talkaction e o npc reparadores.
TalkAction:
Essa talkaction vai funcionar da seguinte maneira, se você falar "!reparar" irá reparar todos os seus itens. Caso você fale !reparar weapon, !reparar shield, !reparar helmet, !reparar armor, !reparar legs ou !reparar boots, então reparara um item especifico. E será gasto gps por essa reparação, a quantidade de gps por pontos reparados esta configuravel na segunda linha do script.
Primeiro vai em data/talkactions/scripts, duplica um arquivo e nomeia para "reparar" sem as aspas e nele cole:
function onSay(cid, words, param) local charge_price = 25 -- preço por carga em gps. local slotShield = nil local slotArmor = nil local slotLegs = nil local slotHelmet = nil local slotBoots = nil local slotWeapon = nil local slots = { [1] = {slot=slotHelmet, lib=helmets}, [4] = {slot=slotArmor, lib=armors}, [5] = {slot=slotShield, lib=shields}, [6] = {slot=slotShield, lib=shields}, [7] = {slot=slotLegs, lib=legs}, [8] = {slot=slotBoots, lib=boots} } if weapons[getPlayerSlotItem(cid, CONST_SLOT_RIGHT).itemid] then slotWeapon = CONST_SLOT_RIGHT elseif weapons[getPlayerSlotItem(cid, CONST_SLOT_LEFT).itemid] then slotWeapon = CONST_SLOT_LEFT end if shields[getPlayerSlotItem(cid, CONST_SLOT_RIGHT).itemid] then slotShield = CONST_SLOT_RIGHT elseif shields[getPlayerSlotItem(cid, CONST_SLOT_LEFT).itemid] then slotShield = CONST_SLOT_LEFT end local price = 0 if param == "weapon" then if slotWeapon ~= nil then if (getItemAttribute(getPlayerSlotItem(cid, slotWeapon).uid, "Charges") == "Broken") then price = (weapons[getPlayerSlotItem(cid, slotWeapon).itemid].charge) else price = ((weapons[getPlayerSlotItem(cid, slotWeapon).itemid].charge) - (getItemAttribute(getPlayerSlotItem(cid, slotWeapon).uid, "Charges"))) end if doPlayerRemoveMoney(cid, price*charge_price) then doItemSetAttribute(getPlayerSlotItem(cid, slotWeapon).uid, "Charges", weapons[getPlayerSlotItem(cid, slotWeapon).itemid].charge) setItemName(getPlayerSlotItem(cid, slotWeapon).uid, getItemNameById(getPlayerSlotItem(cid, slotWeapon).itemid)..' [Dur: '.. (getItemAttribute(getPlayerSlotItem(cid, slotWeapon).uid, "Charges")) ..'/'.. weapons[getPlayerSlotItem(cid, slotWeapon).itemid].charge ..']') doPlayerSendTextMessage(cid, 22, "Sua weapon foi reparada.") doSendMagicEffect(getPlayerPosition(cid), 29) else doPlayerSendTextMessage(cid, 23, "Você não possui gps's suficiente para reparar sua weapon, é necessario "..(price*charge_price).." gps.") return true end else doPlayerSendTextMessage(cid, 23, "Seu slot de weapon esta vazio.") end return true end if param == "shield" then if slotShield ~= nil then if (getItemAttribute(getPlayerSlotItem(cid, slotShield).uid, "Charges") == "Broken") then price = (shields[getPlayerSlotItem(cid, slotShield).itemid].charge) else price = ((shields[getPlayerSlotItem(cid, slotShield).itemid].charge) - (getItemAttribute(getPlayerSlotItem(cid, slotShield).uid, "Charges"))) end if doPlayerRemoveMoney(cid, price*charge_price) then doItemSetAttribute(getPlayerSlotItem(cid, slotShield).uid, "Charges", shields[getPlayerSlotItem(cid, slotShield).itemid].charge) setItemName(getPlayerSlotItem(cid, slotShield).uid, getItemNameById(getPlayerSlotItem(cid, slotShield).itemid)..' [Dur: '.. (getItemAttribute(getPlayerSlotItem(cid, slotShield).uid, "Charges")) ..'/'.. shields[getPlayerSlotItem(cid, slotShield).itemid].charge ..']') setItemDefense(getPlayerSlotItem(cid, slotShield).uid, shields[getPlayerSlotItem(cid, slotShield).itemid].def) doPlayerSendTextMessage(cid, 22, "Seu shield foi reparado.") doSendMagicEffect(getPlayerPosition(cid), 29) else doPlayerSendTextMessage(cid, 23, "Você não possui gps's suficiente para reparar seu shield, é necessario "..(price*charge_price).." gps.") return true end else doPlayerSendTextMessage(cid, 23, "Seu slot de shield esta vazio.") end return true end if param == "armor" then i = 4 if slots[i].lib[getPlayerSlotItem(cid, i).itemid] then slots[i].slot = i if (getItemAttribute(getPlayerSlotItem(cid, i).uid, "Charges") == "Broken") then price = (slots[i].lib[getPlayerSlotItem(cid, i).itemid].charge) else price = ((slots[i].lib[getPlayerSlotItem(cid, i).itemid].charge) - (getItemAttribute(getPlayerSlotItem(cid, i).uid, "Charges"))) end if doPlayerRemoveMoney(cid, price*charge_price) then doItemSetAttribute(getPlayerSlotItem(cid, i).uid, "Charges", slots[i].lib[getPlayerSlotItem(cid, i).itemid].charge) setItemName(getPlayerSlotItem(cid, i).uid, getItemNameById(getPlayerSlotItem(cid, i).itemid)..' [Dur: '.. (getItemAttribute(getPlayerSlotItem(cid, i).uid, "Charges")) ..'/'.. slots[i].lib[getPlayerSlotItem(cid, i).itemid].charge ..']') setItemArmor(getPlayerSlotItem(cid, i).uid, slots[i].lib[getPlayerSlotItem(cid, i).itemid].arm) doPlayerSendTextMessage(cid, 22, "Seu armor foi reparado.") doSendMagicEffect(getPlayerPosition(cid), 29) else doPlayerSendTextMessage(cid, 23, "Você não possui gps's suficiente para reparar sua armor, é necessario "..(price*charge_price).." gps.") return true end else doPlayerSendTextMessage(cid, 23, "Seu slot de armor esta vazio.") end return true end if param == "legs" then i = 7 if slots[i].lib[getPlayerSlotItem(cid, i).itemid] then slots[i].slot = i if (getItemAttribute(getPlayerSlotItem(cid, i).uid, "Charges") == "Broken") then price = (slots[i].lib[getPlayerSlotItem(cid, i).itemid].charge) else price = ((slots[i].lib[getPlayerSlotItem(cid, i).itemid].charge) - (getItemAttribute(getPlayerSlotItem(cid, i).uid, "Charges"))) end if doPlayerRemoveMoney(cid, price*charge_price) then doItemSetAttribute(getPlayerSlotItem(cid, i).uid, "Charges", slots[i].lib[getPlayerSlotItem(cid, i).itemid].charge) setItemName(getPlayerSlotItem(cid, i).uid, getItemNameById(getPlayerSlotItem(cid, i).itemid)..' [Dur: '.. (getItemAttribute(getPlayerSlotItem(cid, i).uid, "Charges")) ..'/'.. slots[i].lib[getPlayerSlotItem(cid, i).itemid].charge ..']') setItemArmor(getPlayerSlotItem(cid, i).uid, slots[i].lib[getPlayerSlotItem(cid, i).itemid].arm) doPlayerSendTextMessage(cid, 22, "Sua legs foi reparada.") doSendMagicEffect(getPlayerPosition(cid), 29) else doPlayerSendTextMessage(cid, 23, "Você não possui gps's suficiente para reparar sua legs, é necessario "..(price*charge_price).." gps.") return true end else doPlayerSendTextMessage(cid, 23, "Seu slot de legs esta vazio.") end return true end if param == "boots" then i = 8 if slots[i].lib[getPlayerSlotItem(cid, i).itemid] then slots[i].slot = i if (getItemAttribute(getPlayerSlotItem(cid, i).uid, "Charges") == "Broken") then price = (slots[i].lib[getPlayerSlotItem(cid, i).itemid].charge) else price = ((slots[i].lib[getPlayerSlotItem(cid, i).itemid].charge) - (getItemAttribute(getPlayerSlotItem(cid, i).uid, "Charges"))) end if doPlayerRemoveMoney(cid, price*charge_price) then doItemSetAttribute(getPlayerSlotItem(cid, i).uid, "Charges", slots[i].lib[getPlayerSlotItem(cid, i).itemid].charge) setItemName(getPlayerSlotItem(cid, i).uid, getItemNameById(getPlayerSlotItem(cid, i).itemid)..' [Dur: '.. (getItemAttribute(getPlayerSlotItem(cid, i).uid, "Charges")) ..'/'.. slots[i].lib[getPlayerSlotItem(cid, i).itemid].charge ..']') setItemArmor(getPlayerSlotItem(cid, i).uid, slots[i].lib[getPlayerSlotItem(cid, i).itemid].arm) doPlayerSendTextMessage(cid, 22, "Sua boots foi reparada.") doSendMagicEffect(getPlayerPosition(cid), 29) else doPlayerSendTextMessage(cid, 23, "Você não possui gps's suficiente para reparar sua armor, é necessario "..(price*charge_price).." gps.") return true end else doPlayerSendTextMessage(cid, 23, "Seu slot de boots esta vazio.") end return true end if param == "helmet" then i = 1 if slots[i].lib[getPlayerSlotItem(cid, i).itemid] then slots[i].slot = i if (getItemAttribute(getPlayerSlotItem(cid, i).uid, "Charges") == "Broken") then price = (slots[i].lib[getPlayerSlotItem(cid, i).itemid].charge) else price = ((slots[i].lib[getPlayerSlotItem(cid, i).itemid].charge) - (getItemAttribute(getPlayerSlotItem(cid, i).uid, "Charges"))) end if doPlayerRemoveMoney(cid, price*charge_price) then doItemSetAttribute(getPlayerSlotItem(cid, i).uid, "Charges", slots[i].lib[getPlayerSlotItem(cid, i).itemid].charge) setItemName(getPlayerSlotItem(cid, i).uid, getItemNameById(getPlayerSlotItem(cid, i).itemid)..' [Dur: '.. (getItemAttribute(getPlayerSlotItem(cid, i).uid, "Charges")) ..'/'.. slots[i].lib[getPlayerSlotItem(cid, i).itemid].charge ..']') setItemArmor(getPlayerSlotItem(cid, i).uid, slots[i].lib[getPlayerSlotItem(cid, i).itemid].arm) doPlayerSendTextMessage(cid, 22, "Seu helmet foi reparado.") doSendMagicEffect(getPlayerPosition(cid), 29) else doPlayerSendTextMessage(cid, 23, "Você não possui gps's suficiente para reparar seu helmet, é necessario "..(price*charge_price).." gps.") return true end else doPlayerSendTextMessage(cid, 23, "Seu slot de helmet esta vazio.") end return true end local pricetotal = 0 for i=1, 8 do if slots[i] ~= nil then if slots[i].lib[getPlayerSlotItem(cid, i).itemid] then slots[i].slot = i if (getItemAttribute(getPlayerSlotItem(cid, i).uid, "Charges") == "Broken") then pricetotal = ((slots[i].lib[getPlayerSlotItem(cid, i).itemid].charge) + pricetotal) else pricetotal = (((slots[i].lib[getPlayerSlotItem(cid, i).itemid].charge) - (getItemAttribute(getPlayerSlotItem(cid, i).uid, "Charges"))) + pricetotal) end end end end if slotWeapon ~= nil then if (getItemAttribute(getPlayerSlotItem(cid, slotWeapon).uid, "Charges") == "Broken") then pricetotal = ((weapons[getPlayerSlotItem(cid, slotWeapon).itemid].charge) + pricetotal) else pricetotal = (((weapons[getPlayerSlotItem(cid, slotWeapon).itemid].charge) - (getItemAttribute(getPlayerSlotItem(cid, slotWeapon).uid, "Charges"))) + pricetotal) end end if doPlayerRemoveMoney(cid, pricetotal*charge_price) then for i=1, 8 do if slots[i] ~= nil then if slots[i].lib[getPlayerSlotItem(cid, i).itemid] then slots[i].slot = i if isShield(getPlayerSlotItem(cid, i).uid) then setItemDefense(getPlayerSlotItem(cid, i).uid, slots[i].lib[getPlayerSlotItem(cid, i).itemid].def) elseif not isWeapon(getPlayerSlotItem(cid, i).uid) then setItemArmor(getPlayerSlotItem(cid, i).uid, slots[i].lib[getPlayerSlotItem(cid, i).itemid].arm) end doItemSetAttribute(getPlayerSlotItem(cid, i).uid, "Charges", slots[i].lib[getPlayerSlotItem(cid, i).itemid].charge) setItemName(getPlayerSlotItem(cid, i).uid, getItemNameById(getPlayerSlotItem(cid, i).itemid)..' [Dur: '.. (getItemAttribute(getPlayerSlotItem(cid, i).uid, "Charges")) ..'/'.. slots[i].lib[getPlayerSlotItem(cid, i).itemid].charge ..']') end end end if slotWeapon ~= nil then doItemSetAttribute(getPlayerSlotItem(cid, slotWeapon).uid, "Charges", weapons[getPlayerSlotItem(cid, slotWeapon).itemid].charge) setItemName(getPlayerSlotItem(cid, slotWeapon).uid, getItemNameById(getPlayerSlotItem(cid, slotWeapon).itemid)..' [Dur: '.. (getItemAttribute(getPlayerSlotItem(cid, slotWeapon).uid, "Charges")) ..'/'.. weapons[getPlayerSlotItem(cid, slotWeapon).itemid].charge ..']') end doPlayerSendTextMessage(cid, 22, "Seus itens foram reparados.") doSendMagicEffect(getPlayerPosition(cid), 30) else doPlayerSendTextMessage(cid, 23, "Você não possui gps's suficiente para reparar todos os itens, é necessario "..(pricetotal*charge_price).." gps.") return true end return TRUE end
Depois vai em data/talkactions/talkactions.xml e cole a tag:
<talkaction words="!reparar" event="script" value="reparar.lua"/>
NPC:
O npc vai funcionar praticamente igual ao talkaction só que é necessario falar os comando ao npc. O preço por pontos é configurado na quinta linha.
Primeiro vai em data/npc, duplica um arquivo e nomeia para "Reparador" sem as aspas e nele cole:
<?xml version="1.0" encoding="UTF-8"?> <npc name="Reparador" script="reparador.lua" walkinterval="2000" floorchange="0"> <health now="150" max="150"/> <look type="139" corpse="2212"/> <parameters> <parameter key="message_greet" value="Ola |PLAYERNAME|. Voce deseja {reparar todos} seus itens?"/> </parameters> </npc>
Depois vai em data/npc/scripts, duplica um arquivo e nomeia para "reparador", sem as aspas e nele cole:
local keywordHandler = KeywordHandler:new() local npcHandler = NpcHandler:new(keywordHandler) NpcSystem.parseParameters(npcHandler) local talkState = {} local charge_price = 25 -- preço por carga em gps. function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end function onThink() npcHandler:onThink() end function creatureSayCallback(cid, type, msg) if(not npcHandler:isFocused(cid)) then return false end local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid local slotShield = nil local slotArmor = nil local slotLegs = nil local slotHelmet = nil local slotBoots = nil local slotWeapon = nil local slots = { [1] = {slot=slotHelmet, lib=helmets}, [4] = {slot=slotArmor, lib=armors}, [5] = {slot=slotShield, lib=shields}, [6] = {slot=slotShield, lib=shields}, [7] = {slot=slotLegs, lib=legs}, [8] = {slot=slotBoots, lib=boots} } if weapons[getPlayerSlotItem(cid, CONST_SLOT_RIGHT).itemid] then slotWeapon = CONST_SLOT_RIGHT elseif weapons[getPlayerSlotItem(cid, CONST_SLOT_LEFT).itemid] then slotWeapon = CONST_SLOT_LEFT end if shields[getPlayerSlotItem(cid, CONST_SLOT_RIGHT).itemid] then slotShield = CONST_SLOT_RIGHT elseif shields[getPlayerSlotItem(cid, CONST_SLOT_LEFT).itemid] then slotShield = CONST_SLOT_LEFT end if msgcontains(msg, 'reparar todos') then local pricetotal = 0 for i=1, 8 do if slots[i] ~= nil then if slots[i].lib[getPlayerSlotItem(cid, i).itemid] then slots[i].slot = i if (getItemAttribute(getPlayerSlotItem(cid, i).uid, "Charges") == "Broken") then pricetotal = ((slots[i].lib[getPlayerSlotItem(cid, i).itemid].charge) + pricetotal) else pricetotal = (((slots[i].lib[getPlayerSlotItem(cid, i).itemid].charge) - (getItemAttribute(getPlayerSlotItem(cid, i).uid, "Charges"))) + pricetotal) end end end end if slotWeapon ~= nil then if (getItemAttribute(getPlayerSlotItem(cid, slotWeapon).uid, "Charges") == "Broken") then pricetotal = ((weapons[getPlayerSlotItem(cid, slotWeapon).itemid].charge) + pricetotal) else pricetotal = (((weapons[getPlayerSlotItem(cid, slotWeapon).itemid].charge) - (getItemAttribute(getPlayerSlotItem(cid, slotWeapon).uid, "Charges"))) + pricetotal) end end if doPlayerRemoveMoney(cid, pricetotal*charge_price) then for i=1, 8 do if slots[i] ~= nil then if slots[i].lib[getPlayerSlotItem(cid, i).itemid] then slots[i].slot = i if isShield(getPlayerSlotItem(cid, i).uid) then setItemDefense(getPlayerSlotItem(cid, i).uid, slots[i].lib[getPlayerSlotItem(cid, i).itemid].def) elseif not isWeapon(getPlayerSlotItem(cid, i).uid) then setItemArmor(getPlayerSlotItem(cid, i).uid, slots[i].lib[getPlayerSlotItem(cid, i).itemid].arm) end doItemSetAttribute(getPlayerSlotItem(cid, i).uid, "Charges", slots[i].lib[getPlayerSlotItem(cid, i).itemid].charge) setItemName(getPlayerSlotItem(cid, i).uid, getItemNameById(getPlayerSlotItem(cid, i).itemid)..' [Dur: '.. (getItemAttribute(getPlayerSlotItem(cid, i).uid, "Charges")) ..'/'.. slots[i].lib[getPlayerSlotItem(cid, i).itemid].charge ..']') end end end if slotWeapon ~= nil then doItemSetAttribute(getPlayerSlotItem(cid, slotWeapon).uid, "Charges", weapons[getPlayerSlotItem(cid, slotWeapon).itemid].charge) setItemName(getPlayerSlotItem(cid, slotWeapon).uid, getItemNameById(getPlayerSlotItem(cid, slotWeapon).itemid)..' [Dur: '.. (getItemAttribute(getPlayerSlotItem(cid, slotWeapon).uid, "Charges")) ..'/'.. weapons[getPlayerSlotItem(cid, slotWeapon).itemid].charge ..']') end selfSay("Seus itens foram reparados.", cid) doSendMagicEffect(getPlayerPosition(cid), 30) else selfSay("Você não possui gps's suficiente para reparar todos os itens, é necessario "..(pricetotal*charge_price).." gps.", cid) selfSay("Você pode reparar um item especifico? {reparar weapon}, {reparar armor}...", cid) return true end elseif msgcontains(msg, 'reparar weapon') then local price = 0 if slotWeapon ~= nil then if (getItemAttribute(getPlayerSlotItem(cid, slotWeapon).uid, "Charges") == "Broken") then price = (weapons[getPlayerSlotItem(cid, slotWeapon).itemid].charge) else price = ((weapons[getPlayerSlotItem(cid, slotWeapon).itemid].charge) - (getItemAttribute(getPlayerSlotItem(cid, slotWeapon).uid, "Charges"))) end if doPlayerRemoveMoney(cid, price*charge_price) then doItemSetAttribute(getPlayerSlotItem(cid, slotWeapon).uid, "Charges", weapons[getPlayerSlotItem(cid, slotWeapon).itemid].charge) setItemName(getPlayerSlotItem(cid, slotWeapon).uid, getItemNameById(getPlayerSlotItem(cid, slotWeapon).itemid)..' [Dur: '.. (getItemAttribute(getPlayerSlotItem(cid, slotWeapon).uid, "Charges")) ..'/'.. weapons[getPlayerSlotItem(cid, slotWeapon).itemid].charge ..']') selfSay("Sua weapon foi reparada.", cid) doSendMagicEffect(getPlayerPosition(cid), 29) return true else selfSay("Você não possui gps's suficiente para reparar sua weapon, é necessario "..(price*charge_price).." gps.", cid) return true end else selfSay("Seu slot de weapon esta vazio.", cid) end elseif msgcontains(msg, 'reparar shield') then local price = 0 if slotShield ~= nil then if (getItemAttribute(getPlayerSlotItem(cid, slotShield).uid, "Charges") == "Broken") then price = (shields[getPlayerSlotItem(cid, slotShield).itemid].charge) else price = ((shields[getPlayerSlotItem(cid, slotShield).itemid].charge) - (getItemAttribute(getPlayerSlotItem(cid, slotShield).uid, "Charges"))) end if doPlayerRemoveMoney(cid, price*charge_price) then doItemSetAttribute(getPlayerSlotItem(cid, slotShield).uid, "Charges", shields[getPlayerSlotItem(cid, slotShield).itemid].charge) setItemName(getPlayerSlotItem(cid, slotShield).uid, getItemNameById(getPlayerSlotItem(cid, slotShield).itemid)..' [Dur: '.. (getItemAttribute(getPlayerSlotItem(cid, slotShield).uid, "Charges")) ..'/'.. shields[getPlayerSlotItem(cid, slotShield).itemid].charge ..']') setItemDefense(getPlayerSlotItem(cid, slotShield).uid, shields[getPlayerSlotItem(cid, slotShield).itemid].def) selfSay("Seu shield foi reparado.", cid) doSendMagicEffect(getPlayerPosition(cid), 29) return true else selfSay("Você não possui gps's suficiente para reparar seu shield, é necessario "..(price*charge_price).." gps.", cid) return true end else selfSay("Seu slot de shield esta vazio.", cid) end elseif msgcontains(msg, 'reparar armor') then i = 4 if slots[i].lib[getPlayerSlotItem(cid, i).itemid] then slots[i].slot = i if (getItemAttribute(getPlayerSlotItem(cid, i).uid, "Charges") == "Broken") then price = (slots[i].lib[getPlayerSlotItem(cid, i).itemid].charge) else price = ((slots[i].lib[getPlayerSlotItem(cid, i).itemid].charge) - (getItemAttribute(getPlayerSlotItem(cid, i).uid, "Charges"))) end if doPlayerRemoveMoney(cid, price*charge_price) then doItemSetAttribute(getPlayerSlotItem(cid, i).uid, "Charges", slots[i].lib[getPlayerSlotItem(cid, i).itemid].charge) setItemName(getPlayerSlotItem(cid, i).uid, getItemNameById(getPlayerSlotItem(cid, i).itemid)..' [Dur: '.. (getItemAttribute(getPlayerSlotItem(cid, i).uid, "Charges")) ..'/'.. slots[i].lib[getPlayerSlotItem(cid, i).itemid].charge ..']') setItemArmor(getPlayerSlotItem(cid, i).uid, slots[i].lib[getPlayerSlotItem(cid, i).itemid].arm) selfSay("Seu armor foi reparado.", cid) doSendMagicEffect(getPlayerPosition(cid), 29) return true else selfSay("Você não possui gps's suficiente para reparar sua armor, é necessario "..(price*charge_price).." gps.", cid) return true end else selfSay("Seu slot de armor esta vazio.", cid) end elseif msgcontains(msg, 'reparar legs') then i = 7 if slots[i].lib[getPlayerSlotItem(cid, i).itemid] then slots[i].slot = i if (getItemAttribute(getPlayerSlotItem(cid, i).uid, "Charges") == "Broken") then price = (slots[i].lib[getPlayerSlotItem(cid, i).itemid].charge) else price = ((slots[i].lib[getPlayerSlotItem(cid, i).itemid].charge) - (getItemAttribute(getPlayerSlotItem(cid, i).uid, "Charges"))) end if doPlayerRemoveMoney(cid, price*charge_price) then doItemSetAttribute(getPlayerSlotItem(cid, i).uid, "Charges", slots[i].lib[getPlayerSlotItem(cid, i).itemid].charge) setItemName(getPlayerSlotItem(cid, i).uid, getItemNameById(getPlayerSlotItem(cid, i).itemid)..' [Dur: '.. (getItemAttribute(getPlayerSlotItem(cid, i).uid, "Charges")) ..'/'.. slots[i].lib[getPlayerSlotItem(cid, i).itemid].charge ..']') setItemArmor(getPlayerSlotItem(cid, i).uid, slots[i].lib[getPlayerSlotItem(cid, i).itemid].arm) selfSay("Sua legs foi reparada.", cid) doSendMagicEffect(getPlayerPosition(cid), 29) return true else selfSay("Você não possui gps's suficiente para reparar sua legs, é necessario "..(price*charge_price).." gps.", cid) return true end else selfSay("Seu slot de legs esta vazio.", cid) end elseif msgcontains(msg, 'reparar boots') then i = 8 if slots[i].lib[getPlayerSlotItem(cid, i).itemid] then slots[i].slot = i if (getItemAttribute(getPlayerSlotItem(cid, i).uid, "Charges") == "Broken") then price = (slots[i].lib[getPlayerSlotItem(cid, i).itemid].charge) else price = ((slots[i].lib[getPlayerSlotItem(cid, i).itemid].charge) - (getItemAttribute(getPlayerSlotItem(cid, i).uid, "Charges"))) end if doPlayerRemoveMoney(cid, price*charge_price) then doItemSetAttribute(getPlayerSlotItem(cid, i).uid, "Charges", slots[i].lib[getPlayerSlotItem(cid, i).itemid].charge) setItemName(getPlayerSlotItem(cid, i).uid, getItemNameById(getPlayerSlotItem(cid, i).itemid)..' [Dur: '.. (getItemAttribute(getPlayerSlotItem(cid, i).uid, "Charges")) ..'/'.. slots[i].lib[getPlayerSlotItem(cid, i).itemid].charge ..']') setItemArmor(getPlayerSlotItem(cid, i).uid, slots[i].lib[getPlayerSlotItem(cid, i).itemid].arm) selfSay("Sua boots foi reparada.", cid) doSendMagicEffect(getPlayerPosition(cid), 29) return true else selfSay("Você não possui gps's suficiente para reparar sua boots, é necessario "..(price*charge_price).." gps.", cid) return true end else selfSay("Seu slot de boots esta vazio.", cid) end elseif msgcontains(msg, 'reparar helmet') then i = 1 if slots[i].lib[getPlayerSlotItem(cid, i).itemid] then slots[i].slot = i if (getItemAttribute(getPlayerSlotItem(cid, i).uid, "Charges") == "Broken") then price = (slots[i].lib[getPlayerSlotItem(cid, i).itemid].charge) else price = ((slots[i].lib[getPlayerSlotItem(cid, i).itemid].charge) - (getItemAttribute(getPlayerSlotItem(cid, i).uid, "Charges"))) end if doPlayerRemoveMoney(cid, price*charge_price) then doItemSetAttribute(getPlayerSlotItem(cid, i).uid, "Charges", slots[i].lib[getPlayerSlotItem(cid, i).itemid].charge) setItemName(getPlayerSlotItem(cid, i).uid, getItemNameById(getPlayerSlotItem(cid, i).itemid)..' [Dur: '.. (getItemAttribute(getPlayerSlotItem(cid, i).uid, "Charges")) ..'/'.. slots[i].lib[getPlayerSlotItem(cid, i).itemid].charge ..']') setItemArmor(getPlayerSlotItem(cid, i).uid, slots[i].lib[getPlayerSlotItem(cid, i).itemid].arm) selfSay("Seu helmet foi reparado.", cid) doSendMagicEffect(getPlayerPosition(cid), 29) return true else selfSay("Você não possui gps's suficiente para reparar sua helmet, é necessario "..(price*charge_price).." gps.", cid) return true end else selfSay("Seu slot de helmet esta vazio.", cid) end end end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new())
Pronto o sisteminha, agora é só usar e apreciar!
Imagens do Sistema: