• 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.2 getCondint a nil value on talkaction

Lopaskurwa

Active Member
Joined
Oct 6, 2017
Messages
876
Solutions
2
Reaction score
49
Trying to create !showpztime talkaction but stuck with getCondition a nil value error, checked my previous codes that uses getCondition pretty much all of them created exactly the same, but it doesnt want to work this time
Lua:
function onSay(cid, words, param, channel)
    if getCondition(CONDITION_INFIGHT, CONDITIONID_DEFAULT) then
    return doPlayerSendCancel(cid, "You Don't Have Pz") and doSendMagicEffect(getThingPos(cid), 2)
    end
    doPlayerSendTextMessage(cid,27, "You Have To Wait "..getInFightTicks(cid).." Second For Pz.")
    return true
end
 
Normally you want to target the creature you are checking for the condition.

so instead of
getCondition(CONDITION_INFIGHT, CONDITIONID_DEFAULT)
it would be
cid:getCondition(CONDITION_INFIGHT, CONDITIONID_DEFAULT)
 
Normally you want to target the creature you are checking for the condition.

so instead of
getCondition(CONDITION_INFIGHT, CONDITIONID_DEFAULT)
it would be
cid:getCondition(CONDITION_INFIGHT, CONDITIONID_DEFAULT)
something isnt right with the code tho, for some reason it ignores the first line
 
The user @abdala ragab reached out to me asking to adapt it for TFS 1.x, so I took it and made the necessary adjustments. After testing, it's working fine. Here's the script for anyone who wants to use it :)

Here is RevScript, in the directory data/script.

Lua:
local talkaction = TalkAction("!showpztime")

function talkaction.onSay(player, words, param)
    local pzCondition = player:getCondition(CONDITION_INFIGHT, CONDITIONID_DEFAULT)
    if not pzCondition then
        player:sendCancelMessage("You don't have PvP protection.")
        player:getPosition():sendMagicEffect(2)
        return false
    end

    local remainingSeconds = math.floor(pzCondition:getTicks() / 1000)
    player:sendTextMessage(MESSAGE_STATUS_WARNING, "You have to wait " .. remainingSeconds .. " seconds for PvP protection.")
    return false
end

talkaction:register()

Here is another one, not RevScript... it's in the normal talkaction folder, specifically in data/talkactions/scripts...
Lua:
function onSay(player, words, param)
    local pzCondition = player:getCondition(CONDITION_INFIGHT, CONDITIONID_DEFAULT)
    if not pzCondition then
        player:sendCancelMessage("You don't have PvP protection.")
        player:getPosition():sendMagicEffect(2)
        return false
    end

    local remainingSeconds = math.floor(pzCondition:getTicks() / 1000)
    player:sendTextMessage(MESSAGE_STATUS_WARNING, "You have to wait " .. remainingSeconds .. " seconds for PvP protection.")
    return false
end
 
Last edited:
The user @abdala ragab reached out to me asking to adapt it for TFS 1.x, so I took it and made the necessary adjustments. After testing, it's working fine. Here's the script for anyone who wants to use it :)

Here is RevScript, in the directory data/script.

Lua:
local talkaction = TalkAction("!showpztime")

function talkaction.onSay(player, words, param)
    if not player:hasCondition(CONDITION_INFIGHT) then
        player:sendTextMessage(MESSAGE_STATUS_WARNING, "You are not in combat.")
        return false
    end

    local pzCondition = player:getCondition(CONDITION_INFIGHT, CONDITIONID_DEFAULT)
    local remainingSeconds = pzCondition and math.floor(pzCondition:getTicks() / 1000) or 0

    player:sendTextMessage(MESSAGE_STATUS_WARNING, "You have to wait " .. remainingSeconds .. " seconds for PvP protection.")
    return false
end

talkaction:register()

Here is another one, not RevScript... it's in the normal talkaction folder, specifically in data/talkactions/scripts...
Thank you, brother, I wish you success
 
The user @abdala ragab reached out to me asking to adapt it for TFS 1.x, so I took it and made the necessary adjustments. After testing, it's working fine. Here's the script for anyone who wants to use it :)

Here is RevScript, in the directory data/script.

Lua:
local talkaction = TalkAction("!showpztime")

function talkaction.onSay(player, words, param)
    if not player:hasCondition(CONDITION_INFIGHT) then
        player:sendTextMessage(MESSAGE_STATUS_WARNING, "You are not in combat.")
        return false
    end

    local pzCondition = player:getCondition(CONDITION_INFIGHT, CONDITIONID_DEFAULT)
    local remainingSeconds = pzCondition and math.floor(pzCondition:getTicks() / 1000) or 0

    player:sendTextMessage(MESSAGE_STATUS_WARNING, "You have to wait " .. remainingSeconds .. " seconds for PvP protection.")
    return false
end

talkaction:register()

Here is another one, not RevScript... it's in the normal talkaction folder, specifically in data/talkactions/scripts...
attempt to call method 'hasCondition' (a nil value)
 
attempt to call method 'hasCondition' (a nil value)
I removed the 'hasCondition' as I believe it's unnecessary. The rest is functioning normally, all good. I removed it, tested it, and it's working fine.


better!
Lua:
function onSay(player, words, param)
    local pzCondition = player:getCondition(CONDITION_INFIGHT, CONDITIONID_DEFAULT)
    if not pzCondition then
        player:sendCancelMessage("You don't have PvP protection.")
        player:getPosition():sendMagicEffect(2)
        return false
    end

    local remainingSeconds = math.floor(pzCondition:getTicks() / 1000)
    player:sendTextMessage(MESSAGE_STATUS_WARNING, "You have to wait " .. remainingSeconds .. " seconds for PvP protection.")
    return false
end
 
Last edited:
I removed the 'hasCondition' as I believe it's unnecessary. The rest is functioning normally, all good. I removed it, tested it, and it's working fine.


better!
Lua:
function onSay(player, words, param)
    local pzCondition = player:getCondition(CONDITION_INFIGHT, CONDITIONID_DEFAULT)
    if not pzCondition then
        player:sendCancelMessage("You don't have PvP protection.")
        player:getPosition():sendMagicEffect(2)
        return false
    end

    local remainingSeconds = math.floor(pzCondition:getTicks() / 1000)
    player:sendTextMessage(MESSAGE_STATUS_WARNING, "You have to wait " .. remainingSeconds .. " seconds for PvP protection.")
    return false
end
Hmm i think it shows and infight condition its best if it counted how many seconds of skull left he has because now i dont have any skull and it says you have to wait 400seconds :D
 
Back
Top