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

Lua onTradeRequest from pos to pos

alejandro762

Well-Known Member
Joined
Sep 6, 2021
Messages
225
Reaction score
63
Hello

I find one script here on forum, that give me some errors, that i dont know how to fix it.
Im looking for a tfs 1.3 revscript onTradeRequest, from Pos x y z to Pos x y z to Block Trade, all items.

I See i need change my player.lua ( i got onTrade = 1 , activated on events ), but i dont know how to done that.

Thanks in advance
 
You can use this one, Taken from here and slightly edited.
Lua:
local protectedArea = {
    from = Position(1073, 1110, 7),
    to = Position(1078, 1110, 7)
}

local ec = EventCallback

function ec.onTradeRequest(self, target, item)
    local position
    position = self:getPosition()
    if position and position:isInRange(protectedArea.from, protectedArea.to) then
        self:sendTextMessage(MESSAGE_INFO_DESCR, "You cannot trade here.")
        return false
    end
    return true
end

ec:register(-666)
 
You can use this one, Taken from here and slightly edited.
Lua:
local protectedArea = {
    from = Position(1073, 1110, 7),
    to = Position(1078, 1110, 7)
}

local ec = EventCallback

function ec.onTradeRequest(self, target, item)
    local position
    position = self:getPosition()
    if position and position:isInRange(protectedArea.from, protectedArea.to) then
        self:sendTextMessage(MESSAGE_INFO_DESCR, "You cannot trade here.")
        return false
    end
    return true
end

ec:register(-666)
Oh right, forget to announce, i didn't have EventCallback.
Post automatically merged:

You can use this one, Taken from here and slightly edited.
Lua:
local protectedArea = {
    from = Position(1073, 1110, 7),
    to = Position(1078, 1110, 7)
}

local ec = EventCallback

function ec.onTradeRequest(self, target, item)
    local position
    position = self:getPosition()
    if position and position:isInRange(protectedArea.from, protectedArea.to) then
        self:sendTextMessage(MESSAGE_INFO_DESCR, "You cannot trade here.")
        return false
    end
    return true
end

ec:register(-666)
Sorry, corrected, without EventCallback working.
Very nice and thanks!
 
Last edited:
Back
Top