- Joined
- Dec 26, 2013
- Messages
- 1,662
- Solutions
- 11
- Reaction score
- 919
Greetings Otland!
Here I come to you today in ask of help with the latest TFS 1.0 server. Seems everything was fine with my spells until I updated the source to include some of the latest commits. Anyways, never had this error in my screen before, now it's there, and also my script stopped working on one of my spells (only the condition part) and as far as the rest goes the spells are still completely functional.
ok spell that stopped working(only condition stopped) armorbreak.lua
Returns error in console
Like I said the spell still does everything except add the condition to the target, whereas before it worked perfectly fine.
Here I come to you today in ask of help with the latest TFS 1.0 server. Seems everything was fine with my spells until I updated the source to include some of the latest commits. Anyways, never had this error in my screen before, now it's there, and also my script stopped working on one of my spells (only the condition part) and as far as the rest goes the spells are still completely functional.
ok spell that stopped working(only condition stopped) armorbreak.lua
Code:
local areaCombat = Combat()
areaCombat:setParameter(COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
areaCombat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_BLOCKHIT)
local areaCombat2 = Combat()
areaCombat2:setParameter(COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
areaCombat2:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_BLOCKHIT)
local combat = Combat()
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_BLOCKHIT)
function onGetPlayerMinMaxValues(cid, attackSkill, attackValue, attackFactor)
local player = Player(cid)
local level = player:getLevel()
local skill = player:getSkillLevel(0)
local leftHand = pushThing(player:getSlotItem(CONST_SLOT_LEFT)).itemid
local rightHand = pushThing(player:getSlotItem(CONST_SLOT_RIGHT)).itemid
if(ItemType(leftHand):getWeaponType() == 1 or ItemType(rightHand):getWeaponType() == 1) then
skill = player:getSkillLevel(2)
end
if(ItemType(leftHand):getWeaponType() == 2 or ItemType(rightHand):getWeaponType() == 2) then
skill = player:getSkillLevel(1)
end
if(ItemType(leftHand):getWeaponType() == 3 or ItemType(rightHand):getWeaponType() == 3) then
skill = player:getSkillLevel(3)
end
if(ItemType(leftHand):getWeaponType() == 5 or ItemType(rightHand):getWeaponType() == 5) then
skill = player:getSkillLevel(4)
end
min = -((level/2) + skill + attackValue)
max = -((level + skill + attackValue)*1.6)
return min, max
end
areaCombat:setCallback(CALLBACK_PARAM_SKILLVALUE, "onGetPlayerMinMaxValues")
function onGetPlayerMinMaxValues2(cid, attackSkill, attackValue, attackFactor)
local player = Player(cid)
local level = player:getLevel()
local skill = player:getSkillLevel(0)
local leftHand = pushThing(player:getSlotItem(CONST_SLOT_LEFT)).itemid
local rightHand = pushThing(player:getSlotItem(CONST_SLOT_RIGHT)).itemid
if(ItemType(leftHand):getWeaponType() == 1 or ItemType(rightHand):getWeaponType() == 1) then
skill = player:getSkillLevel(2)
end
if(ItemType(leftHand):getWeaponType() == 2 or ItemType(rightHand):getWeaponType() == 2) then
skill = player:getSkillLevel(1)
end
if(ItemType(leftHand):getWeaponType() == 3 or ItemType(rightHand):getWeaponType() == 3) then
skill = player:getSkillLevel(3)
end
if(ItemType(leftHand):getWeaponType() == 5 or ItemType(rightHand):getWeaponType() == 5) then
skill = player:getSkillLevel(4)
end
min = -((level/2) + skill + attackValue)
max = -((level + skill + attackValue)*1.6)
return min, max
end
areaCombat2:setCallback(CALLBACK_PARAM_SKILLVALUE, "onGetPlayerMinMaxValues2")
local condition = Condition(CONDITION_BLEEDING)
condition:setTicks(9000)
condition:setParameter(CONDITION_PARAM_DELAYED, 1)
condition:setParameter(CONDITION_PARAM_TICKINTERVAL, 3000)
local area = createCombatArea({{0, 1, 0},
{1, 2, 1},
{0, 1, 0}})
areaCombat:setArea(area)
local area2 = createCombatArea({{0, 0, 1, 0, 0},
{0, 1, 0, 1, 0},
{1, 0, 2, 0, 1},
{0, 1, 0, 1, 0},
{0, 0, 1, 0, 0}})
areaCombat2:setArea(area2)
function onTargetCreature(cid, target)
local dmg = 0
local targetCreature = Creature(target)
if not targetCreature then
return true
end
if isPlayer(target) then
local pl = Player(target)
dmg = pl:getTotalArmor()
elseif isMonster(target) then
local monsterType = MonsterType(targetCreature:getName())
dmg = monsterType:getArmor()
end
condition:setParameter(CONDITION_PARAM_PERIODICDAMAGE, -(dmg*2))
combat:setCondition(condition)
combat:execute(cid, positionToVariant(target))
return true
end
areaCombat:setCallback(CALLBACK_PARAM_TARGETCREATURE, "onTargetCreature")
function onTargetCreature2(cid, target)
local dmg = 0
local targetCreature = Creature(target)
if not targetCreature then
return true
end
if isPlayer(target) then
local pl = Player(target)
dmg = pl:getTotalArmor()
elseif isMonster(target) then
local monsterType = MonsterType(targetCreature:getName())
dmg = monsterType:getArmor()
end
condition:setParameter(CONDITION_PARAM_PERIODICDAMAGE, -(dmg*2))
combat:setCondition(condition)
combat:execute(cid, positionToVariant(target))
return true
end
areaCombat2:setCallback(CALLBACK_PARAM_TARGETCREATURE, "onTargetCreature2")
local function RunPart(c,cid,var,dirList,dirEmitPos) -- Part
if (isCreature(cid)) then
c:execute(cid, var)
if (dirList ~= nil) then -- Emit distance effects
local i = 2;
while (i < #dirList) do
doSendDistanceShoot(dirEmitPos,{x=dirEmitPos.x-dirList[i],y=dirEmitPos.y-dirList[i+1],z=dirEmitPos.z},dirList[1])
i = i + 2
end
end
end
end
function onCastSpell(cid, var)
local startPos = getCreaturePosition(cid)
RunPart(areaCombat,cid,var)
addEvent(RunPart,200,areaCombat2,cid,var)
return true
end
Returns error in console
Code:
Lua Script Error: [Spell Interface]
data/spells/scripts/attack/armorbreak.lua:onCastSpell
LuaScriptInterface::luaAddEvent(). Argument #4 is unsafe
stack traceback:
[C]: in function 'addEvent'
data/spells/scripts/attack/armorbreak.lua:134: in function <data/spells/
scripts/attack/armorbreak.lua:131>
Like I said the spell still does everything except add the condition to the target, whereas before it worked perfectly fine.