• 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.3](CONDITION_INFIGHT) Doesn't work? or what?

Lay

TFS 1.2
Joined
Dec 7, 2012
Messages
67
Solutions
9
Reaction score
29
Hey,
I have problem with this:

Code:
function onSay(player, words, param)
        if not player:getCondition(CONDITION_INFIGHT) then
            player:teleportTo(player:getTown():getTemplePosition())
            return false
        else
            player:sendTextMessage(MESSAGE_STATUS_SMALL, "You can't teleport during battles.")
            return false
        end
    return true
end

If i think it well, TP does not work when player will be in battle with monsters (battle, swords icon), but this shit work =/
(CONDITION_POISON) and others works perfect only i have problem with this INFIGHT

Whan can be wrong? or what i did wrong?
 
Solution
Hey,
I have problem with this:

Code:
function onSay(player, words, param)
        if not player:getCondition(CONDITION_INFIGHT) then
            player:teleportTo(player:getTown():getTemplePosition())
            return false
        else
            player:sendTextMessage(MESSAGE_STATUS_SMALL, "You can't teleport during battles.")
            return false
        end
    return true
end

If i think it well, TP does not work when player will be in battle with monsters (battle, swords icon), but this shit work =/
(CONDITION_POISON) and others works perfect only i have problem with this INFIGHT

Whan can be wrong? or what i did wrong?
I think it uses subid CONDITIONID_DEFAULT for that and the default subid for getCondition...
Hey,
I have problem with this:

Code:
function onSay(player, words, param)
        if not player:getCondition(CONDITION_INFIGHT) then
            player:teleportTo(player:getTown():getTemplePosition())
            return false
        else
            player:sendTextMessage(MESSAGE_STATUS_SMALL, "You can't teleport during battles.")
            return false
        end
    return true
end

If i think it well, TP does not work when player will be in battle with monsters (battle, swords icon), but this shit work =/
(CONDITION_POISON) and others works perfect only i have problem with this INFIGHT

Whan can be wrong? or what i did wrong?
I think it uses subid CONDITIONID_DEFAULT for that and the default subid for getCondition is CONDITIONID_COMBAT

Try changing it to
Lua:
player:getCondition(CONDITION_INFIGHT, CONDITIONID_DEFAULT)
 
Solution
\o/
Thanks! Mkalo!
Maybe some1 know why: player:sendChannelMessage doesn't works correct, only player who used script sees message. ;o
 
\o/
Thanks! Mkalo!
Maybe some1 know why: player:sendChannelMessage doesn't works correct, only player who used script sees message. ;o
that's not sendchannelmessage its sendtextmessage
MESSAGE_STATUS_SMALL is used for the white text at thhe bottom of the screen
if you want it to show for everyone you can use player:say(text, MONSTER_TYPE_SAY)
 
I explained it wrong, just dont wont make new topic so asked here. I update TFS and now have problems with some functions like: player:sendChannelMessage in ur script Xeraphus nobody sees msg only player who used script/looted that item:
Code:
local rareItems = {2492, 2498}
          
local CHAT1 = 3 -- world ch
local CHAT2 = 4 -- loot ch

local function scanRareItems(cid, pos)
    local player = Player(cid)
    local name = player:getName()
    local corpse = Tile(pos):getTopDownItem()
    for i = corpse:getSize()-1, 0, -1 do
        local item = corpse:getItem(i)
        if isInArray(rareItems, item:getId()) then
            local count = item:getCount()
            local string = ("%s has looted %s %s!"):format(name, count > 1 and count or item:getArticle(), count > 1 and item:getPluralName() or item:getName())
            player:sendChannelMessage(nil, string, TALKTYPE_CHANNEL_R1, CHAT1)
            player:sendChannelMessage(nil, string, TALKTYPE_CHANNEL_R1, CHAT2)
        end
    end
end

function onKill(creature, target)
    if creature:isPlayer() and target:isMonster() then
        addEvent(scanRareItems, 0, creature:getId(), target:getPosition())
    end
    return true
end
2holen4.png


When some1 kill summon:
34eolrk.png

This is not big deal but makes madness in console.
 
Thanks Xeraphus works fine.
Code:
            sendChannelMessage(CHAT1, TALKTYPE_CHANNEL_R1, string)
            sendChannelMessage(CHAT2, TALKTYPE_CHANNEL_R1, string)
 
I think it uses subid CONDITIONID_DEFAULT for that and the default subid for getCondition is CONDITIONID_COMBAT

Try changing it to
Lua:
player:getCondition(CONDITION_INFIGHT, CONDITIONID_DEFAULT)

Now even on Protection Zone he denies me to teleport.
Weird.
'-'

Lua:
function onSay(player, words, param)   
    if player:getCondition(CONDITION_INFIGHT, CONDITIONID_DEFAULT) then
            player:sendTextMessage(MESSAGE_STATUS_WARNING, "You Can't Teleport Now!")
            player:sendCancelMessage('Still on Battle!')
            player:getPosition():sendMagicEffect(CONST_ME_POFF)
    return false
    end   
            player:teleportTo(player:getTown():getTemplePosition())
            player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)   
            player:sendTextMessage(MESSAGE_INFO_DESCR, "TELEPORTED!")
    return false
end
 
try this

Code:
function onSay(player, words, param)

local config = {
onlypremmy = "yes", -- Apenas players premium accounts "yes" or "no".
pzlock = "true",
battle = "true",
}

        if config.onlypremmy == "yes" and not isPremium(player) then
        doPlayerSendTextMessage(player, 22, "Você precisa ser premium para usar esse comando.")
        return TRUE
        elseif config.pzlock == "true" and isPlayerPzLocked(player) == true then
        doPlayerSendTextMessage(player, 22, "Você não pode se teleportar com PZ LOCKED.")
        return TRUE
    elseif config.battle == "true" and getCreatureCondition(player,CONDITION_INFIGHT) == true then
        doPlayerSendTextMessage(player, 22, "Você não pode se teleportar durante uma batalha com monstros.")
        return TRUE
end
    doPlayerSendTextMessage(player, 22, "Você foi teleportado para o templo!")
    doSendMagicEffect(getPlayerPosition(player),7)
    player:teleportTo(player:getTown():getTemplePosition())
    doSendMagicEffect(getPlayerPosition(player),67)
    return false
end
 
Back
Top