• 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 0.X Detect on play fanfare if player is x,y,z position

newby

Active Member
Joined
Jun 11, 2016
Messages
183
Reaction score
43
How to detect when player plays fanfire, if he is in position x=100, y=120, z=7
Send player a msg?
 
Solution
if(getCreaturePos(cid) == {x=1234,y=1234,z=7}) then
You cannot compare position tables, you have to invoke a function like:
Lua:
function comparePosition(p1, p2)
    return pos1.x == pos2.x and pos1.y == pos2.y and pos1.z == pos2.z and true or false
end
depending on tfs version it might have comparePosition(p1, p2) already.
Lua:
local MusicEffect = {
    [2076] = CONST_ME_SOUND_GREEN,     --Fanfare
}

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if item.itemid == 2076 then
-- area
        if isInRange(player:getPosition(), Position(32330, 32214, 7), Position(32332, 32216, 7)) then
            player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Wow that is a terrible song.")
        end
-- exact location
        if player:getPosition() == Position(32330, 32214, 7) then
            player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Wow that is a beautiful song.")
        end
    end

    item:getPosition():sendMagicEffect(MusicEffect[item.itemid])
    return true
end
modified from music.lua

oh sorry i didn't see 0.x.
I don't have sources for 0.x, checkout the music.lua if it has one.
 
if(getCreaturePos(cid) == {x=1234,y=1234,z=7}) then
You cannot compare position tables, you have to invoke a function like:
Lua:
function comparePosition(p1, p2)
    return pos1.x == pos2.x and pos1.y == pos2.y and pos1.z == pos2.z and true or false
end
depending on tfs version it might have comparePosition(p1, p2) already.
 
Solution
You cannot compare position tables, you have to invoke a function like:
Lua:
function comparePosition(p1, p2)
    return pos1.x == pos2.x and pos1.y == pos2.y and pos1.z == pos2.z and true or false
end
depending on tfs version it might have comparePosition(p1, p2) already.
Yea sorry, i forgot that i've edited this in my srv so i can compare table.
__eq
 
Back
Top