function onStatsChange(cid, attacker, type, combat, value)
local config = {
item_id = 2222, -- right or left hand
more_dmg = 20, -- percent
more_dmg_spell = 20 -- percent
}
if isPlayer(cid) then
if((type == STATSCHANGE_HEALTHLOSS or STATSCHANGE_MANALOSS) and (getPlayerSlotItem(cid, CONST_SLOT_LEFT).itemid == config.item_id or getPlayerSlotItem(cid, CONST_SLOT_RIGHT).itemid == config.item_id)) then
if(combat == COMBAT_PHYSICALDAMAGE) then
local correct = value + (value * config.more_dmg)
doTargetCombatHealth(attacker, cid, combat, correct, correct, 255)
else
local correct = value + (value * config.more_dmg_spell)
doTargetCombatHealth(attacker, cid, combat, correct, correct, 255)
end
return false
end
end
end
have fun with stack overflowLUA:function onStatsChange(cid, attacker, type, combat, value) local config = { item_id = 2222, -- right or left hand more_dmg = 20, -- percent more_dmg_spell = 20 -- percent } if isPlayer(cid) then if((type == STATSCHANGE_HEALTHLOSS or STATSCHANGE_MANALOSS) and (getPlayerSlotItem(cid, CONST_SLOT_LEFT).itemid == config.item_id or getPlayerSlotItem(cid, CONST_SLOT_RIGHT).itemid == config.item_id)) then if(combat == COMBAT_PHYSICALDAMAGE) then local correct = value + (value * config.more_dmg) doTargetCombatHealth(attacker, cid, combat, correct, correct, 255) else local correct = value + (value * config.more_dmg_spell) doTargetCombatHealth(attacker, cid, combat, correct, correct, 255) end return false end end end
onEquip / onDeEquip in movments handles equipment (the slots you equip things to even arrow slot) you can set the storage value there.I am very intrested in the script too.
I used a storage value and the stack overflow is gone.
function onStatsChange(cid, attacker, type, combat, value)
local config = {
item_id = 2400, -- right or left hand
more_dmg = 75, -- percent
more_dmg_spell = 75 -- percent
local storage = 815869 --the storage value used
}
if isPlayer(cid) then
if((type == STATSCHANGE_HEALTHLOSS or STATSCHANGE_MANALOSS) and (getPlayerSlotItem(cid, CONST_SLOT_LEFT).itemid == config.item_id or getPlayerSlotItem(cid, CONST_SLOT_RIGHT).itemid == config.item_id)) then
if(combat == COMBAT_PHYSICALDAMAGE) then
if getPlayerStorageValue(target,storage) ~= 1 then
return true,
setPlayerStorageValue(target,storage,1),
local correct = value + (value * config.more_dmg)
doTargetCombatHealth(attacker, cid, combat, correct, correct, 255)
else
local correct = value + (value * config.more_dmg_spell)
doTargetCombatHealth(attacker, cid, combat, correct, correct, 255)
end
return false
end
end
end
end
<event type="statschange" name="MoreDMG" event="script" value="MoreDMG.lua"/>registerCreatureEvent(cid, "MoreDMG")
I know that i should place a line " setPlayerStorageValue(target,storage,0)" when an item is unequiped but I don't know how to put it in into the script.
Unfortunately the script itself isn't working for me. I don't get any errors.
I am using theforgottenserver tfs 0.4 client 8.6.
If anyone could take a look at it that would be great![]()
function onEquip(cid, item, slot)
local slots = getPlayerSlotItem(cid, slot)
if slots then
if slots.itemid ~= item.itemid then
return true
end
if getPlayerStorageValue(cid, 815869) < 1 then
setPlayerStorageValue(cid, 815869, 1)
end
end
return true
end
function onDeEquip(cid, item, slot)
if getPlayerStorageValue(cid, 815869) > 0 then
setPlayerStorageValue(cid, 815869, 0)
end
return true
end
<movevent event="Equip" itemid="itemid of item" slot=" slot name of item" script="path to script" />
<movevent event="DeEquip" itemid="itemid of item" slot=" slot name of item" script="path to script" />