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

Solved If npc is near then give storage onUse

Status
Not open for further replies.

lucastiond

New Member
Joined
Jul 14, 2013
Messages
35
Reaction score
0
My tfs version is 1.2

I am trying to give a storageValue when I use one item, but only if the npc is near. And if the npc is away then it sends a message.

Someone knows how to do it?
 
Solution
Code:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local npc = Npc(id or name or userdata)
    if player:getPosition():getDistance(npc:getPosition()) > 5 then
        player:setStorageValue(11111, 1)
    else
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "text message")
    end
    return true
end
Code:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local npc = Npc(id or name or userdata)
    if player:getPosition():getDistance(npc:getPosition()) > 5 then
        player:setStorageValue(11111, 1)
    else
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "text message")
    end
    return true
end
 
Solution
Status
Not open for further replies.
Back
Top