TFS 0.X Detect on play fanfare if player is x,y,z position

newby

Banned User
Joined
Jun 11, 2016
Messages
164
Best answers
0
Reaction score
38
How to detect when player plays fanfire, if he is in position x=100, y=120, z=7
Send player a msg?
 

Leesne

Member
Joined
Dec 4, 2017
Messages
95
Best answers
13
Reaction score
40
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.
 

Perun

nems.online
Premium User
Joined
May 1, 2009
Messages
294
Best answers
5
Reaction score
116
How to detect when player plays fanfire, if he is in position x=100, y=120, z=7
Send player a msg?
if(getCreaturePos(cid) == {x=1234,y=1234,z=7}) then
 

Evil Hero

Legacy Member
TFS Developer
Joined
Dec 12, 2007
Messages
1,177
Best answers
14
Reaction score
552
Location
Germany
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.
 

Perun

nems.online
Premium User
Joined
May 1, 2009
Messages
294
Best answers
5
Reaction score
116
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
 
OP
newby

newby

Banned User
Joined
Jun 11, 2016
Messages
164
Best answers
0
Reaction score
38
Thank you guys!
 
Top