• 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!

TFS 1.X+ tfs 1.3 player:getCondition(CONDITION_PARALYZE)

roriscrave

Advanced OT User
Joined
Dec 7, 2011
Messages
1,188
Solutions
34
Reaction score
200
Hi, i`m using tfs 1.3 downgraded by nekiro, i paralyzed a player and used this code:
but it print (nil).

why?
Lua:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    print(player:getCondition(CONDITION_PARALYZE))
    return true
end
 
Solution
Seems to be a problem with using -1, for infinite time.


Here's the fix. ^

--

You can test without infinite -1, and get expected results though.

Lua:
local conditionLyze = Condition(CONDITION_PARALYZE)
conditionLyze:setParameter(CONDITION_PARAM_TICKS, 60)
conditionLyze:setFormula(-1, 80, -1, 80)

function onUse(player, item, fromPosition, target, toPosition, isHotkey)

    player:addCondition(conditionLyze)
    
    if player:hasCondition(CONDITION_PARALYZE) then
        player:removeCondition(CONDITION_PARALYZE)
        print('have')
    else
        print('not have')
    end
    return true
end
Not sure why it's printing nil for you..

But I've only seen it used like this..
and it should print correct for you.

Lua:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if player:getCondition(CONDITION_PARALYZE) then
        print("player is paralyzed.")
    else
        print("player is not paralyzed.")
    end
    return true
end
 
Not sure why it's printing nil for you..

But I've only seen it used like this..
and it should print correct for you.

Lua:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if player:getCondition(CONDITION_PARALYZE) then
        print("player is paralyzed.")
    else
        print("player is not paralyzed.")
    end
    return true
end
printed:
1609734654347.png
but, player are paralyzed:
1609734677816.png
 
ah I see.

change
Lua:
if player:getCondition(CONDITION_PARALYZE) then
to
Lua:
if player:hasCondition(CONDITION_PARALYZE) then

I thought I had solved it, but always print 'not have'
but the player is paralyzed

1609736027711.png
Lua:
local conditionLyze = Condition(CONDITION_PARALYZE)
conditionLyze:setParameter(CONDITION_PARAM_TICKS, -1)
conditionLyze:setFormula(-1, 80, -1, 80)

function onUse(player, item, fromPosition, target, toPosition, isHotkey)

    player:addCondition(conditionLyze)
    
    if player:hasCondition(CONDITION_PARALYZE) then
        player:removeCondition(CONDITION_PARALYZE)
        print('have')
    else
        print('not have')
    end
    return true
end
 
Seems to be a problem with using -1, for infinite time.


Here's the fix. ^

--

You can test without infinite -1, and get expected results though.

Lua:
local conditionLyze = Condition(CONDITION_PARALYZE)
conditionLyze:setParameter(CONDITION_PARAM_TICKS, 60)
conditionLyze:setFormula(-1, 80, -1, 80)

function onUse(player, item, fromPosition, target, toPosition, isHotkey)

    player:addCondition(conditionLyze)
    
    if player:hasCondition(CONDITION_PARALYZE) then
        player:removeCondition(CONDITION_PARALYZE)
        print('have')
    else
        print('not have')
    end
    return true
end
 
Solution
Back
Top