• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Solved 'hasCondition' TFS 1.0 problem.

dominique120

Science & Reason
Senator
Premium User
Joined
Jun 16, 2013
Messages
3,881
Solutions
3
Reaction score
1,046
Location
Númenor
I get this error with this script:
Code:
Lua Script Error: [Action Interface]
data/actions/scripts/mana_runes/mana rune.lua:onUse
data/actions/scripts/mana_runes/mana rune.lua:6: attempt to call global 'hasCond
ition' (a nil value)
stack traceback:
        [C]: in function 'hasCondition'
        data/actions/scripts/mana_runes/mana rune.lua:6: in function <data/actio
ns/scripts/mana_runes/mana rune.lua:4>

Code:
local exhaust = createConditionObject(CONDITION_EXHAUST)
setConditionParam(exhaust, CONDITION_PARAM_TICKS, 700) -- time in seconds x1000

function onUse(cid, item, fromPosition, itemEx, toPosition)

  if(hasCondition(cid, CONDITION_EXHAUST)) then
    doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
    doPlayerSendCancel(cid, "You are exhausted")
    return true
  end
  doPlayerAddMana(cid, math.random(55, 300))  --parameter for total mana healed
  doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_BLUE)
  doAddCondition(cid, exhaust)
  doRemoveItem(item.uid, 1)
  return true
end
 
Just change hasCondition to getCreatureCondition if you have the same error.
The script already works, it's just that a function with the name hasCondition doesn't exist (and isn't set to an existing function in a lib file) in his server.
 
Just change hasCondition to getCreatureCondition if you have the same error.
The script already works, it's just that a function with the name hasCondition doesn't exist (and isn't set to an existing function in a lib file) in his server.


local exhaust = createConditionObject(CONDITION_EXHAUST)
setConditionParam(exhaust, CONDITION_PARAM_TICKS, 700) -- time in seconds x1000

function onUse(cid, item, fromPosition, itemEx, toPosition)

if(getCreatureCondition(cid, CONDITION_EXHAUST)) then
doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
doPlayerSendCancel(cid, "You are exhausted")
return true
end
doPlayerAddMana(cid, math.random(55, 300)) --parameter for total mana healed
doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_BLUE)
doAddCondition(cid, exhaust)
doRemoveItem(item.uid, 1)
return true
end


like that?
 
You can use any itemid that is not used yet by an other script.
ohh so much thx im really noob ty man <3



- - - Updated - - -

how to put this? >_> last help pls
doCreatureSay(cid, "Aaaah...", TALKTYPE_ORANGE_1)



- - - Updated - - -

nvm fixed thx im leaving right now so much thx <3
 
Last edited by a moderator:
Back
Top