• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Lua Help with syntax

Icaraii

Well-Known Member
Joined
Jan 5, 2020
Messages
469
Solutions
1
Reaction score
58
Hi, I made a multiple hit spell with a single effect that check if player is using x item in right hand and y item in left hand, it works fine, however I'm getting a error on TFS.
TFS 1.3
Lua Script Error: [Spell Interface]
data/spells/scripts/dps/multipledamage.lua:eek:nCastSpell
data/spells/scripts/dps/multipledamage.lua:102: attempt to index local 'creature' (a nil value)
stack traceback:
[C]: in function '__index'
data/spells/scripts/dps/multipledamage.lua:102: in function <data/spells/scripts/dps/multipledamage.lua:91>

spell:
Lua:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, 202)
combat:setParameter(COMBAT_PARAM_BLOCKARMOR, true)
combat:setParameter(COMBAT_PARAM_BLOCKSHIELD, true)

local combat2 = Combat()
combat2:setParameter(COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
combat2:setParameter(COMBAT_PARAM_BLOCKARMOR, true)
combat2:setParameter(COMBAT_PARAM_BLOCKSHIELD, true)

local combat3 = Combat()
combat3:setParameter(COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
combat3:setParameter(COMBAT_PARAM_BLOCKARMOR, true)
combat3:setParameter(COMBAT_PARAM_BLOCKSHIELD, true)

local combat4 = Combat()
combat4:setParameter(COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
combat4:setParameter(COMBAT_PARAM_BLOCKARMOR, true)
combat4:setParameter(COMBAT_PARAM_BLOCKSHIELD, true)

function onGetFormulaValues(player, skill, attack, shield, factor)
    local maxHealth = player:getMaxHealth()
    local maxMana = player:getMaxMana()
    local playlvl = player:getLevel()
    local shield = player:getSkillLevel(SKILL_SHIELD)
   
    local min = ((playlvl < 300 and playlvl or 300) + ((maxHealth + maxMana) / 16) + (attack * 4) + (skill * 2)) * 0,75
    local max = ((playlvl < 300 and playlvl or 300) + ((maxHealth + maxMana) / 16) + (attack * 4) + (skill * 2)) * 1,5
   
    return -min, -max  
end
combat:setCallback(CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues")

function onGetFormulaValues2(player, skill, attack, shield, factor)
    local maxHealth = player:getMaxHealth()
    local maxMana = player:getMaxMana()
    local playlvl = player:getLevel()
    local shield = player:getSkillLevel(SKILL_SHIELD)
   
    local min = ((playlvl < 300 and playlvl or 300) + ((maxHealth + maxMana) / 16) + (attack * 4) + (skill * 2)) * 0,75
    local max = ((playlvl < 300 and playlvl or 300) + ((maxHealth + maxMana) / 16) + (attack * 4) + (skill * 2)) * 1,5
   
    return -min, -max  
end
combat2:setCallback(CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues2")

function onGetFormulaValues3(player, skill, attack, shield, factor)
    local maxHealth = player:getMaxHealth()
    local maxMana = player:getMaxMana()
    local playlvl = player:getLevel()
    local shield = player:getSkillLevel(SKILL_SHIELD)
   
    local min = ((playlvl < 300 and playlvl or 300) + ((maxHealth + maxMana) / 16) + (attack * 4) + (skill * 2)) * 0,75
    local max = ((playlvl < 300 and playlvl or 300) + ((maxHealth + maxMana) / 16) + (attack * 4) + (skill * 2)) * 1,5
   
    return -min, -max  
end
combat3:setCallback(CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues3")

function onGetFormulaValues4(player, skill, attack, shield, factor)
    local maxHealth = player:getMaxHealth()
    local maxMana = player:getMaxMana()
    local playlvl = player:getLevel()
    local shield = player:getSkillLevel(SKILL_SHIELD)
   
    local min = ((playlvl < 300 and playlvl or 300) + ((maxHealth + maxMana) / 16) + (attack * 4) + (skill * 2)) * 0,75
    local max = ((playlvl < 300 and playlvl or 300) + ((maxHealth + maxMana) / 16) + (attack * 4) + (skill * 2)) * 1,5
   
    return -min, -max  
end
combat4:setCallback(CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues4")

local weapons = {26676, 26763, 26765, 26766, 26767, 26728, 26764, 26729, 26772, 26768, 26770, 26771, 26730, 26699, 26769, 26731, 26686, 26753, 26755, 26756, 26757, 26724, 26687, 26754, 26725, 26684, 26658, 26668, 26662, 26696, 26761, 26758, 26759, 26762, 26726, 26692, 26760, 26727, 26743, 26683, 26746, 26745, 26685, 26744, 26720, 26672, 26747, 26678, 26721, 26677, 26693, 26673, 26705, 26688, 26674, 26682, 26670, 26708, 26694, 26671, 26679, 26667, 26707, 26675, 26751, 26750, 26749, 26752, 26722, 26689, 26748, 26723, 26710, 26734, 26737, 26733, 26736, 26717, 26700, 26735, 26718, 26681, 26669, 26701, 26690, 26698, 26663, 26712, 26680, 26709, 26691, 26695, 26665, 26780, 26779, 26778, 26664, 26713, 26714, 26715, 26666, 26716, 26655, 26659, 26656, 26660, 26657, 26661} -- dagger
   
local shields = {27510, 27452, 27406, 27453, 27511, 27507, 27508, 27509, 27601, 27309, 27487, 27600, 27597, 27599, 27598, 27576, 27477, 27359, 27478, 27572, 27575, 27573, 27574, 27580, 27480, 27386, 27349, 27479, 27577, 27581, 27579, 27578, 27586, 27481, 27392, 27482, 27584, 27583, 27585, 27582, 27402, 27350, 27357, 27551, 27284, 27467, 27428, 27405, 27390, 27378, 27468, 27547, 27548, 27549, 27550, 27384, 27593, 27486, 27285, 27441, 27403, 27337, 27485, 27594, 27595, 27592, 27596, 27499, 27442, 27447, 27366, 27448, 27449, 27501, 27498, 27500, 27541, 27446, 27425, 27409, 27399, 27375, 27368, 27328, 27336, 27308, 27295, 27464, 27538, 27539, 27537, 27540, 27571, 27475, 27476, 27567, 27570, 27569, 27568, 27565, 27473, 27344, 27312, 27306, 27474, 27413, 27566, 27564, 27563, 27562, 27606, 27489, 27420, 27426, 27345, 27331, 27488, 27382, 27605, 27391, 27604, 27602, 27603, 27544, 27342, 27332, 27326, 27294, 27465, 27466, 27546, 27542, 27545, 27543, 27520, 27434, 27456, 27415, 27400, 27412, 27355, 27457, 27387, 27305, 27521, 27519, 27394, 27518, 27517, 27589, 27483, 27418, 27374, 27484, 27322, 27590, 27587, 27588, 27591, 27525, 27506, 27458, 27421, 27450, 27302, 27451, 27459, 27333, 27334, 27443, 27503, 27526, 27523, 27502, 27524, 27505, 27522, 27504, 27561, 27283, 27471, 27325, 27472, 27492, 27414, 27398, 27559, 27358, 27558, 27444, 27557, 27560, 27552, 27469, 27424, 27470, 27321, 27327, 27556, 27553, 27287, 27555, 27554, 27531, 27433, 27460, 27410, 27407, 27411, 27461, 27432, 27329, 27300, 27530, 27352, 27529, 27339, 27528, 27527, 27422, 27423, 27381, 27290, 27319, 27535, 27462, 27376, 27385, 27463, 27301, 27532, 27296, 27533, 27373, 27445, 27536, 27534, 27320, 27516, 27317, 27354, 27454, 27364, 27346, 27455, 27513, 27514, 27515, 27512, 27286, 27292, 27610, 27343, 27341, 27303, 27356, 27370, 27408, 27371, 27299, 27293, 27311, 27291, 27347, 27607, 27608, 27497, 27348, 27323, 27338, 27490, 27416, 27493, 27379, 27494, 27298, 27313, 27496, 27288, 27330, 27297, 27609, 27340, 27361, 27491, 27318, 27289, 27495, 27436, 27440, 27438, 27304, 27437, 27435, 27439, -- sword
26676, 26763, 26765, 26766, 26767, 26728, 26764, 26729, 26772, 26768, 26770, 26771, 26730, 26699, 26769, 26731, 26686, 26753, 26755, 26756, 26757, 26724, 26687, 26754, 26725, 26684, 26658, 26668, 26662, 26696, 26761, 26758, 26759, 26762, 26726, 26692, 26760, 26727, 26743, 26683, 26746, 26745, 26685, 26744, 26720, 26672, 26747, 26678, 26721, 26677, 26693, 26673, 26705, 26688, 26674, 26682, 26670, 26708, 26694, 26671, 26679, 26667, 26707, 26675, 26751, 26750, 26749, 26752, 26722, 26689, 26748, 26723, 26710, 26734, 26737, 26733, 26736, 26717, 26700, 26735, 26718, 26681, 26669, 26701, 26690, 26698, 26663, 26712, 26680, 26709, 26691, 26695, 26665, 26780, 26779, 26778, 26664, 26713, 26714, 26715, 26666, 26716, 26655, 26659, 26656, 26660, 26657, 26661, -- dagger
26522, 26537, 26525, 26530, 26536, 26532, 26531, 26534, 26535, 26542, 26538, 26539, 26521, 26541, 26543, 26533, 26529, 26527, 26528, 26524, 26526, 26523, 26540, -- claw
26590, 26612, 26611, 26610, 26580, 26613, 26589, 26593, 26616, 26615, 26614, 26582, 26591, 26570, 26617, 26592, 26605, 26632, 26631, 26630, 26603, 26571, 26633, 26604, 26548, 26574, 26602, 26628, 26627, 26626, 26544, 26600, 26573, 26629, 26601, 26599, 26624, 26623, 26622, 26581, 26597, 26565, 26558, 26625, 26598, 26553, 26596, 26620, 26619, 26618, 26594, 26621, 26595, 26567, 26549, 26572, 26576, 26559, 26568, 26562, 26569, 26556, 26566, 26579, 26550, 26554, 26577, 26606, 26560, 26609, 26563, 26552, 26555, 26607, 26578, 26608, 26575, 26547, 26561, 26551, 26557, 26546, 27950, 26564, 26583, 26587, 26584, 26588, 26585, 26586, -- club
26238, 26240, 26328, 26330, 26329, 26239, 26331, 26158, 26159, 26136, 26145, 26218, 26302, 26303, 26300, 26301, 26219, 26162, 26217, 26163,    26215, 26298, 26299, 26296, 26297, 26216, 26214, 26227, 26314, 26315, 26312, 26313, 26228, 26226, 26221, 26306, 26307, 26304, 26305, 26222, 26220, 26224, 26310, 26311, 26308, 26309, 26225, 26128, 26223, 26230, 26318, 26319, 26316, 26317, 26231, 26166, 26229, 26194, 26268, 26269, 26266, 26267, 26195, 26126, 26193, 26254, 26350, 26351, 26105, 26348, 26349, 26255, 26134, 26160, 26253, 26236, 26326, 26165, 26327, 26324, 26325, 26237, 26127, 26235, 26245, 26338, 26339, 26336, 26337, 26246, 26149, 26244, 26251, 26346, 26347, 26344, 26345, 26252, 26150, 26250, 26191, 26108, 26151, 26131, 26133, 26103, 26146, 26156, 26212, 26294, 26295, 26292, 26293, 26213, 26179, 26107, 26211, 26233, 26322, 26323, 26320, 26321, 26234, 26232, 26242, 26334, 26157, 26335, 26332, 26333, 26243, 26115, 26241, 26260, 26358, 26359, 26356, 26357, 26261, 26142, 26259, 26263, 26362, 26363, 26360, 26361, 26264, 26155, 26262, 26197, 26274, 26275, 26272, 26273, 26198, 26175, 26196, 26201, 26278, 26279, 26276, 26277, 26199, 26177, 26135, 26176, 26200, 26154, 26119, 26172, 26138, 26148, 26161, 26169, 26257, 26354, 26355, 26352, 26353, 26258, 26256, 26203, 26282, 26283, 26280, 26281, 26204, 26102, 26202, 26180, 26124, 26116, 26141, 26152, 26144, 26167, 26209, 26290, 26291, 26288, 26289, 26210, 26208, 26147, 26248, 26342, 26343, 26340, 26341, 26249, 26247, 26114, 26189, 26171, 26132, 26178, 26164, 26174, 26153, 26117, 26270, 26265, 26139, 26123, 26104, 26192, 26206, 26286, 26287, 26284, 26285, 26207, 26205, 26182, 26111, 26190, 26143, 26140, 26113, 26122, 26118, 26181, 26129, 26173, 26271, 26137, 26121, 26168, 26106, 26110, 26112, 26109, 26120, 26130, 26170, 26186, 26183, 26185, 26184, 26187, 26125, 26188, -- axe
27213, 27204, 27211, 27208, 27187, 27219, 27252, 27218, 27225, 27254, 27230, 27232, 27198, 27197, 27245, 27174, 27256, 27239, 27222, 27206, 27246, 27205, 27176, 27240, 27192, 27250, 27175, 27257, 27221, 27190, 27260, 27251, 27223, 27200, 27195, 27199, 27231, 27266, 27193, 27264, 27185, 27268, 27210, 27181, 27173, 27220, 27234, 27184, 27258, 27249, 27201, 27233, 27217, 27235, 27265, 27186, 27237, 27248, 27196, 27267, 27189, 27209, 27270, 27259, 27238, 27183, 27271, 27263, 27236, 27191, 27215, 27224, 27228, 27243, 27269, 27226, 27202, 27188, 27194, 27182, 27261, 27253, 27247, 27262, 27229, 27177, -- shields
27272, 27277, 27278, 27279, 27280, 27281, 27282, 28097, 28094, 28100, 28092, 28096, 27274, 27275, 27276, 27273, 28101, 28095, 28098, 28093, 28099, 28067, 28069, 28091, 28089, 28085, 28086, 28087, 28088, 28090 -- spellbooks
} -- todas armas possíveis melee de dual wielding (sword, axe, club, dagger, claw) + shield + spellbook

local function RunPart(c,cid,var,dirList,dirEmitPos,startDir) -- Part
    if (isCreature(cid)) then
        doCombat(cid, c, var)
    end
end

function onCastSpell(cid, var, creature)

    local startDir = Creature(cid):getDirection()
    RunPart(combat,cid.uid,var)
    addEvent(RunPart,250,combat2,cid.uid,var)
    addEvent(RunPart,500,combat3,cid.uid,var)
    addEvent(RunPart,750,combat4,cid.uid,var)

    local slotWeapon = CONST_SLOT_LEFT
    local slotShield = CONST_SLOT_RIGHT
       
    local playerWeapon = creature:getSlotItem(slotWeapon)
    local playerShield = creature:getSlotItem(slotShield)  
   
    if not playerWeapon or not table.contains(weapons, playerWeapon:getId()) then
        creature:sendTextMessage(MESSAGE_STATUS_SMALL, "You need a dagger in the main hand to cast this spell.")
        return false
    end
   
    if not playerShield or not table.contains(shields, playerShield:getId()) then
        creature:sendTextMessage(MESSAGE_STATUS_SMALL, "You need a sword, axe, club, claw, dagger, shield or spellbook in the second hand to cast this spell.")
        return false
    end


    return true
end
 
Back
Top