Ir para conteúdo

Conflito entre 2 scripts


surfnament

Posts Recomendados

Galera tem 2 scripts meu que estão em conflito:

O 'Addon Bonnus' e o 'Slot System'

 

No addon bonnus ao colocar o addon o player recebe mais mana/hp/skills
No slot system o player recebe mais mana/hp/skill só que isto fica no item...

Acredito que os 2 devam estar usando a mesma função e dai venha o conflito....

Quando o player esta usando os 2 sistemas fica acumulando mana e hp..


Alguem saberia arrumar? Colocar uma função que eles possam ser usados juntos? Preciso muito deles no meu servidor....

Agradeço a quem ajudar!

 

addonsbonnus.lua

 

 

local hunter = createConditionObject(CONDITION_ATTRIBUTES)
setConditionParam(hunter, CONDITION_PARAM_TICKS, -1)
setConditionParam(hunter, CONDITION_PARAM_STAT_MAXHEALTH, 300) --- hp
setConditionParam(hunter, CONDITION_PARAM_STAT_MAXMANA, 300) --- mana
local mage = createConditionObject(CONDITION_ATTRIBUTES)
setConditionParam(mage, CONDITION_PARAM_TICKS, -1)
setConditionParam(mage, CONDITION_PARAM_STAT_MAGICLEVEL, 3)
setConditionParam(mage, CONDITION_PARAM_STAT_MAXHEALTH, 500) --- hp
setConditionParam(mage, CONDITION_PARAM_STAT_MAXMANA, 3000) --- mana
local shaman = createConditionObject(CONDITION_ATTRIBUTES)
setConditionParam(shaman, CONDITION_PARAM_TICKS, -1)
setConditionParam(shaman, CONDITION_PARAM_STAT_MAGICLEVEL, 1)
setConditionParam(shaman, CONDITION_PARAM_STAT_MAXHEALTH, 200) --- hp
setConditionParam(shaman, CONDITION_PARAM_STAT_MAXMANA, 800) --- mana
local knight = createConditionObject(CONDITION_ATTRIBUTES)
setConditionParam(knight, CONDITION_PARAM_TICKS, -1)
setConditionParam(knight, CONDITION_PARAM_STAT_MAXHEALTH, 1000) --- hp
setConditionParam(knight, CONDITION_PARAM_STAT_MAXMANA, 100) --- mana
local nobleman = createConditionObject(CONDITION_ATTRIBUTES)
setConditionParam(nobleman, CONDITION_PARAM_TICKS, -1)
setConditionParam(nobleman, CONDITION_PARAM_STAT_MAXHEALTH, 300) --- hp
setConditionParam(nobleman, CONDITION_PARAM_STAT_MAXMANA, 300) --- mana
local warrior = createConditionObject(CONDITION_ATTRIBUTES)
setConditionParam(warrior, CONDITION_PARAM_TICKS, -1)
setConditionParam(warrior, CONDITION_PARAM_STAT_MAXHEALTH, 2000) --- hp
setConditionParam(warrior, CONDITION_PARAM_STAT_MAXMANA, 300) --- mana
local barbarian = createConditionObject(CONDITION_ATTRIBUTES)
setConditionParam(barbarian, CONDITION_PARAM_TICKS, -1)
setConditionParam(barbarian, CONDITION_PARAM_SKILL_AXE, 2)
setConditionParam(barbarian, CONDITION_PARAM_STAT_MAXHEALTH, 1000) --- hp
setConditionParam(barbarian, CONDITION_PARAM_STAT_MAXMANA, 200) --- mana
local druid = createConditionObject(CONDITION_ATTRIBUTES)
setConditionParam(druid, CONDITION_PARAM_TICKS, -1)
setConditionParam(druid, CONDITION_PARAM_STAT_MAGICLEVEL, 1)
setConditionParam(druid, CONDITION_PARAM_STAT_MAXHEALTH, 200) --- hp
setConditionParam(druid, CONDITION_PARAM_STAT_MAXMANA, 800) --- mana
local wizzard = createConditionObject(CONDITION_ATTRIBUTES)
setConditionParam(wizzard, CONDITION_PARAM_TICKS, -1)
setConditionParam(wizzard, CONDITION_PARAM_STAT_MAGICLEVEL, 3)
setConditionParam(wizzard, CONDITION_PARAM_STAT_MAXHEALTH,100) --- hp
setConditionParam(wizzard, CONDITION_PARAM_STAT_MAXMANA, 1000) --- mana
local pirate = createConditionObject(CONDITION_ATTRIBUTES)
setConditionParam(pirate, CONDITION_PARAM_STAT_MAXHEALTH, 500) --- hp
setConditionParam(pirate, CONDITION_PARAM_STAT_MAXMANA, 500) --- mana
setConditionParam(pirate, CONDITION_PARAM_TICKS, -1)
local assassin = createConditionObject(CONDITION_ATTRIBUTES)
setConditionParam(assassin, CONDITION_PARAM_TICKS, -1)
setConditionParam(assassin, CONDITION_PARAM_STAT_MAXHEALTH, 2000) --- hp
setConditionParam(assassin, CONDITION_PARAM_STAT_MAXMANA, 2000) --- mana
local norse = createConditionObject(CONDITION_ATTRIBUTES)
setConditionParam(norse, CONDITION_PARAM_TICKS, -1)
setConditionParam(norse, CONDITION_PARAM_STAT_MAXHEALTH, 300) --- hp
setConditionParam(norse, CONDITION_PARAM_STAT_MAXMANA, 300) --- mana
local nightmare = createConditionObject(CONDITION_ATTRIBUTES)
setConditionParam(nightmare, CONDITION_PARAM_TICKS, -1)
setConditionParam(nightmare, CONDITION_PARAM_STAT_MAXHEALTH, 2000) --- hp
setConditionParam(nightmare, CONDITION_PARAM_STAT_MAXMANA, 10) --- mana
local wayfarer = createConditionObject(CONDITION_ATTRIBUTES)
setConditionParam(wayfarer, CONDITION_PARAM_TICKS, -1)
setConditionParam(wayfarer, CONDITION_PARAM_SKILL_MAGIC, 3)
setConditionParam(wayfarer, CONDITION_PARAM_STAT_MAXHEALTH, 300) --- hp
setConditionParam(wayfarer, CONDITION_PARAM_STAT_MAXMANA, 300) --- mana
local baron = createConditionObject(CONDITION_ATTRIBUTES)
setConditionParam(baron, CONDITION_PARAM_TICKS, -1)
setConditionParam(baron, CONDITION_PARAM_STAT_MAGICLEVEL, 3)
local mldois = createConditionObject(CONDITION_ATTRIBUTES)
setConditionParam(mldois, CONDITION_PARAM_TICKS, -1)
setConditionParam(mldois, CONDITION_PARAM_STAT_MAGICLEVEL, 3)

outfitBonusTable = { --- [] = {condition = , maxHealth = , maxMana = }
[128] = {maxHealth = 300, condition = speed1, typ = CONDITION_HASTE}, [136] = {maxHealth = 300, condition = speed1, typ = CONDITION_HASTE}, --Citizen
[129] = {condition = hunter}, [137] = {condition = hunter}, --Hunter
[130] = {condition = mage}, [138] = {condition = mage}, --Mage
[153] = {maxHealth = 300, maxMana = 300}, [157] = {maxHealth = 300, maxMana = 300}, --Beggar
[367] = {condition = wayfarer}, {condition = speed1, typ = CONDITION_HASTE}, [366] = {condition = wayfarer}, {condition = speed1, typ = CONDITION_HASTE}, --Wayfarer
[132] = {condition = nobleman}, [140] = {condition = nobleman}, --Nobleman
[131] = {condition = knight}, [139] = {condition = knight}, --Knight
[133] = {condition = mldois, maxMana = 300}, [141] = {condition = mldois, maxMana = 300}, --Summoner
[151] = {condition = pirate}, [155] = {condition = pirate}, --Pirate
[134] = {condition = warrior}, [142] = {condition = warrior}, --Warrior
[143] = {condition = barbarian}, [147] = {condition = barbarian}, --Barbarian
[144] = {condition = druid}, [148] = {condition = druid}, --Druid
[145] = {condition = wizzard}, [149] = {condition = wizzard}, --Wizard
[146] = {maxHealth = 500, maxMana = 500, condition = speed1, typ = CONDITION_HASTE}, [150] = {maxHealth = 500, maxMana = 500, condition = speed1, typ = CONDITION_HASTE}, --Oriental
[152] = {condition = assassin}, {condition = speed2, typ = CONDITION_HASTE}, [156] = {condition = assassin}, {condition = speed2, typ = CONDITION_HASTE}, --Assassin
[154] = {condition = shaman}, [158] = {condition = shaman}, --Shaman
[251] = {condition = norse}, [252] = {condition = norse}, --Norse
[268] = {condition = nightmare}, [269] = {condition = nightmare}, --Nightmare
[270] = {maxMana = 400, condition = speed1, typ = CONDITION_HASTE}, [273] = {maxMana = 400, condition = speed1, typ = CONDITION_HASTE}, --Jester
[278] = {condition = mldois, maxHealth = 2500}, [279] = {condition = mldois, maxHealth = 2500}, --Brotherhood
[335] = {condition = mldois, maxHealth = 250}, {condition = speed1, typ = CONDITION_HASTE}, [336] = {condition = mldois, maxHealth = 250}, {condition = speed1, typ = CONDITION_HASTE}, --Warmaster
[288] = {maxHealth = 2500, condition = speed2, typ = CONDITION_HASTE}, [289] = {maxHealth = 2500, condition = speed2, typ = CONDITION_HASTE}, --Demonhunter
[324] = {condition = mldois}, {condition = speed1, typ = CONDITION_HASTE}, [325] = {condition = mldois}, {condition = speed1, typ = CONDITION_HASTE} --Yalaharian
}
function onLogin(cid)
registerCreatureEvent(cid, "Addons")
local oldOutfit = getCreatureOutfit(cid)
if (oldOutfit.lookAddons ~= 3) or (outfitBonusTable[oldOutfit.lookType] == nil) or ((outfitBonusTable[oldOutfit.lookType]).condition == nil) then
return true
end
doAddCondition(cid, (outfitBonusTable[oldOutfit.lookType]).condition)
return true
end
function onOutfit(cid, old, current)
if old.lookAddons == 3 and outfitBonusTable[old.lookType] then --Bonus off
if (outfitBonusTable[old.lookType]).maxHealth ~= nil then
setCreatureMaxHealth(cid, getCreatureMaxHealth(cid) -(outfitBonusTable[old.lookType]).maxHealth)
doCreatureAddHealth(cid, -(outfitBonusTable[old.lookType]).maxHealth)
end
if (outfitBonusTable[old.lookType]).maxMana ~= nil then
setCreatureMaxMana(cid, getCreatureMaxMana(cid) -(outfitBonusTable[old.lookType]).maxMana)
doCreatureAddMana(cid, -(outfitBonusTable[old.lookType]).maxMana)
end
if (outfitBonusTable[old.lookType]).condition ~= nil then
(outfitBonusTable[old.lookType]).typ = ( (outfitBonusTable[old.lookType]).typ == nil) and CONDITION_ATTRIBUTES or (outfitBonusTable[old.lookType]).typ
doRemoveCondition(cid, (outfitBonusTable[old.lookType]).typ)
end
end
if current.lookAddons == 3 and outfitBonusTable[current.lookType] then --Bonus on
if (outfitBonusTable[current.lookType]).maxHealth ~= nil then
setCreatureMaxHealth(cid, getCreatureMaxHealth(cid) +(outfitBonusTable[current.lookType]).maxHealth)
doCreatureAddHealth(cid, (outfitBonusTable[current.lookType]).maxHealth)
end
if (outfitBonusTable[current.lookType]).maxMana ~= nil then
setCreatureMaxMana(cid, getCreatureMaxMana(cid) +(outfitBonusTable[current.lookType]).maxMana)
doCreatureAddMana(cid, (outfitBonusTable[current.lookType]).maxMana)
end
if (outfitBonusTable[current.lookType]).condition ~= nil then
doAddCondition(cid, (outfitBonusTable[current.lookType]).condition)
end
end
return true
end

 

 

 

slotcrystal.lua

 

 

---Script by mock the bear!
local conditionMP,conditionHP,conditionML,conditionCLUB,conditionSHI,conditionDIST,conditionAMP = {},{},{},{},{},{},{}
for i=1,100 do ---Carrega as conditions
--- HP
conditionHP = createConditionObject(CONDITION_ATTRIBUTES)
setConditionParam(conditionHP, CONDITION_PARAM_TICKS, -1)
setConditionParam(conditionHP, CONDITION_PARAM_STAT_MAXHEALTHPERCENT, 100+i)
setConditionParam(conditionHP, CONDITION_PARAM_BUFF, true)
setConditionParam(conditionHP, CONDITION_PARAM_SUBID, 50)
--MANA
conditionMP = createConditionObject(CONDITION_ATTRIBUTES)
setConditionParam(conditionMP, CONDITION_PARAM_TICKS, -1)
setConditionParam(conditionMP, CONDITION_PARAM_STAT_MAXMANAPERCENT, 100+i)
setConditionParam(conditionMP, CONDITION_PARAM_BUFF, true)
setConditionParam(conditionMP, CONDITION_PARAM_SUBID, 51)
--Magic level
conditionML = createConditionObject(CONDITION_ATTRIBUTES)
setConditionParam(conditionML, CONDITION_PARAM_TICKS, -1)
setConditionParam(conditionML, CONDITION_PARAM_STAT_MAGICLEVELPERCENT, 100+i)
setConditionParam(conditionML, CONDITION_PARAM_BUFF, true)
setConditionParam(conditionML, CONDITION_PARAM_SUBID, 52)
--club axe sword
conditionCLUB = createConditionObject(CONDITION_ATTRIBUTES)
setConditionParam(conditionCLUB, CONDITION_PARAM_TICKS, -1)
setConditionParam(conditionCLUB, CONDITION_PARAM_SKILL_CLUBPERCENT, 100+i)
setConditionParam(conditionCLUB, CONDITION_PARAM_SKILL_SWORDPERCENT, 100+i)
setConditionParam(conditionCLUB, CONDITION_PARAM_SKILL_AXEPERCENT, 100+i)
setConditionParam(conditionCLUB, CONDITION_PARAM_BUFF, true)
setConditionParam(conditionCLUB, CONDITION_PARAM_SUBID, 53)
--- shield
conditionSHI = createConditionObject(CONDITION_ATTRIBUTES)
setConditionParam(conditionSHI, CONDITION_PARAM_TICKS, -1)
setConditionParam(conditionSHI, CONDITION_PARAM_SKILL_SHIELDPERCENT, 100+i)
setConditionParam(conditionSHI, CONDITION_PARAM_BUFF, true)
setConditionParam(conditionSHI, CONDITION_PARAM_SUBID, 54)
--- dist
conditionDIST = createConditionObject(CONDITION_ATTRIBUTES)
setConditionParam(conditionDIST, CONDITION_PARAM_TICKS, -1)
setConditionParam(conditionDIST, CONDITION_PARAM_SKILL_DISTANCEPERCENT, 100+i)
setConditionParam(conditionDIST, CONDITION_PARAM_BUFF, true)
setConditionParam(conditionDIST, CONDITION_PARAM_SUBID, 55)
end
function getSlotType(n) --By mock the bear
if not n then
return false
end
if n:match('%[(.+)%]') then
n = n:match('%[(.+)%]')
if n == '?' then
return 0,n
else
return n:match('(.-)%.([+-])(%d+)%%')
end
else
return false
end

end
local function loadSet(cid)
local t = {}
for slot=1,9 do
t[slot] = ''

local s = getPlayerSlotItem(cid,slot).uid
if s ~= 0 then
t[slot] = getItemName(s)
end
end
return t
end
function isInArray2(arr,var) -- Because in some servers it return 1 and 0 and others true and false
for i,b in pairs(arr) do
if var == b then
return true
end
end
return false
end
function check2(cid,i)
if i == 5 or i == 6 then
if isInArray({'head','necklace','backpack','body','legs','feet','ring'},getItemValue(getPlayerSlotItem(cid,i).itemid,'slotType') or '') then
return false
end
end
return true
end
function chk(cid,f)
if not isPlayer(cid) then return end
local t = loadSet(cid)
for i=1,#f do
if f ~= t then
equip(cid,nil,slot)
break
end
end
addEvent(chk,2000,cid,t)
end
items = { ---- Only to get attr: slotType because getItemName dont return it -.-'
_VERSION='1.0 By mock',
XML_DIR='data/items/items.xml',
}
do
local ia = os.clock()
io.write('Loading items')
local i = io.open(items.XML_DIR,'r')
local u = i:read(-1)
i:close()
local u = u:match('<items>(.+)</items>')
for mi,id,mid,name,data,me in u:gmatch('<(%a-)%s*id%s*=%s*"(%d+)"%s*(.-)%s*name%s*=%s*"(.-)"%s*>(.-)</(%a*)>') do
if mi == 'item' and me == 'item' then
local td = {name=name,id=id,type=1}
for key,value in data:gmatch('<attribute key="(.-)" value="(.-)"/>') do
td[key] = value
end
for key,value in mid:gmatch('(.-)="(.-)"') do
td[key] = value
end
items[tonumber(id)] = td

items[name] = td
end
end
for mi,id,mid,name,data in u:gmatch('<(%a-)%s*id%s*=%s*"(%d*)"%s*(.-)%s*name%s*=%s*"(%a+)"%s*/>') do
if mi == 'item' then
local td = {name=name,id=id,type=2}
for key,value in mid:gmatch('(.-)="(.-)"') do
td[key] = value
end
items[tonumber(id)] = td
items[name] = td
end
end
io.write('[done '..os.clock()-ia..']\n')
end
function getItemValue(item,value)
return items[item] and items[item][value]
end
function equip(cid,item,slot) --By mock the bear
local HP = getCreatureHealth(cid)
local MP = getCreatureMana(cid)
local t = {}
if item then
local mm,sinal,qto = getSlotType(getItemName(item.uid))
t[mm] = tonumber(qto)
end
for i=1,9 do -- Not on slot 10 > arrow
if i ~= slot then
if getPlayerSlotItem(cid,i).itemid ~= 0 then
local aab = getPlayerSlotItem(cid,i).uid
if aab and check2(cid,i) then
for _ in getItemName(aab):gmatch('(%[.-%])') do
local mm,sinal,qto2 = getSlotType(_)
if mm then
if not t[mm] then
t[mm] = 0
end
t[mm] = t[mm]+tonumber(qto2)

t[mm] = t[mm] > 100 and 100 or t[mm]
end
end
end
end
end
end
local fu = 0
local ca = {}
local s = ''
for sl,n in pairs(t) do
fu = fu+1
s = s..''..n..'% more of '..sl..'\n'
if sl == 'hp' then
doAddCondition(cid,conditionHP[tonumber(n)])
doCreatureAddHealth(cid,HP-getCreatureHealth(cid))
ca[50] = 1
doPlayerSendTutorial(cid,19)
elseif sl == 'mp' then
doAddCondition(cid,conditionMP[tonumber(n)])
doCreatureAddMana(cid,HP-getCreatureMana(cid))
ca[51] = 1
doPlayerSendTutorial(cid,19)
elseif sl == 'ml' then
doAddCondition(cid,conditionML[tonumber(n)])
ca[52] = 1
elseif sl == 'cas' then
doAddCondition(cid,conditionCLUB[tonumber(n)])
ca[53] = 1
elseif sl == 'shield' then
doAddCondition(cid,conditionSHI[tonumber(n)])
ca[54] = 1
elseif sl == 'dist' then
doAddCondition(cid,conditionDIST[tonumber(n)])
ca[55] = 1
end
end
if fu > 0 then
addEvent(doPlayerSendTextMessage,100,cid,24,'You have:\n'..s)
for i=50,55 do
if not ca then
doRemoveCondition(cid,CONDITION_ATTRIBUTES,i)
end
end
else
for i=50,55 do
doRemoveCondition(cid,CONDITION_ATTRIBUTES,i)
end
end
return true
end
function onLogin(cid) ---Script by mock the bear!
equip(cid,nil,slot)
addEvent(chk,2000,cid,loadSet(cid)) -- Here we check!
return TRUE
end

 

 

 

slotcrystal.lua (action)

 

 

--[[
Slot system 100% by mock \o
]]
---Config
local conf = {
maxSlotCount=1,
ignoredIds={}
}
--End
function choose(...) --- Function by mock.
local arg = {...}
return arg[math.random(1,#arg)]
end
if not getItemAttack then
function getItemAttack(uid)
return getItemAttribute(uid,'attack')
end
function getItemDefense(uid)
return getItemAttribute(uid,'defense')
end
end
local function isArmor(uid) -- Function by Mock the bear.
if (getItemInfo(uid.itemid).armor ~= 0) and (getItemWeaponType(uid.uid) == 0) then
return true
end
return false
end
local 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
local function isShield(uid) -- Function by Mock the bear.
uid = uid or 0
if getItemWeaponType(uid) == 4 then
return true
end
return false
end
local function isBow(uid) -- Function by Mock the bear.
uid = uid or 0
if getItemWeaponType(uid) == 5 and not isItemStackable(uid) then
return true
end
return false
end
function onUse(cid, item, fromPosition, itemEx, toPosition) -- Script by mock the bear (MTB)
if item.uid == 0 or item.itemid == 0 then return false end
toPosition.stackpos = 255
if item.uid == 0 or item.itemid == 0 then return false end
toPosition.stackpos = 255
if isInArray(conf.ignoredIds, itemEx.itemid)
or (not getItemWeaponType(itemEx.uid) or getItemWeaponType(itemEx.uid) > 5)
or (getItemWeaponType(itemEx.uid) == 0 and not isArmor(itemEx))
or itemEx.itemid == 0 or itemEx.type > 1 or isItemStackable(itemEx.uid) then
doPlayerSendTextMessage(cid, 24,"You cant open a slot on this item.")
return TRUE
end
if isCreature(itemEx.uid) then
return FALSE
end
local nam = getItemName(itemEx.uid)
function getper()
local n = 1
for i=1,10 do
n = n+math.random(0,10)
if n < 8*i then
break
end
end
return n
end
function getSlotCount(nam)
local c = 0
for _ in nam:gmatch('%[(.-)%]') do
c = c+1
end
return c
end
if getSlotCount(nam) < conf.maxSlotCount then
local l = choose('hp','mp','ml','cas','shield','dist')
local p = getper()

doSendMagicEffect(toPosition,30)
nam = nam..' ['..l..'.+'..p..'%]'
doSendAnimatedText(toPosition,l..' '..p..'%',120)
doItemSetAttribute(itemEx.uid,'name',nam)
doRemoveItem(item.uid,1)
else
doPlayerSendTextMessage(cid, 24,"You cant open a slot on this item.")
end
return true
end

 

 

Editado por Prototype
Link para o comentário
Compartilhar em outros sites

  • 5 weeks later...

O tópico foi fechado e movido para lixeira por estar inativo a mais de 10 dias. Caso seja preciso reabrir o mesmo, favor entrar em contato com a equipe.

Link para o comentário
Compartilhar em outros sites

Visitante
Este tópico está impedido de receber novos posts.
×
×
  • Criar Novo...