só usar a função isInRange
local from,to = {x=, y=, z=}, {x=, y=, z=} -- pos começo e pos final da area
if isInRange(getCreaturePosition(cid), from, to) then
---continue o script---
else
doPlayerSendCancel(cid, "Você não está na posição coreta")
end
Por popohat7, 11 de out. de 2012 em Scripts
info
Grupo: Herói
Registrado: 20/05/10
Posts: 3.4k
Reputação: +1.5k
Gênero: Masculino

só usar a função isInRange
local from,to = {x=, y=, z=}, {x=, y=, z=} -- pos começo e pos final da area
if isInRange(getCreaturePosition(cid), from, to) then
---continue o script---
else
doPlayerSendCancel(cid, "Você não está na posição coreta")
end
Editado Outubro 11 por Vodkart
info
Grupo: Campones
Registrado: 20/01/08
Posts: 56
Reputação: 0
Char no Tibia: SKyDevILFiRe

Hmm, e não é possivel por em actionid ?
Pra area não ficar quadradona =)
Editado Outubro 11 por SkyDevilFire
info
Grupo: Príncipe
Registrado: 19/08/10
Posts: 4k
Reputação: +1.1k
Gênero: Masculino

local action = 1111 local pos = getPlayerPosition(cid) pos.stackpos = 0 if getTileThingByPos(pos).actionid == action then ---continue o script--- else doPlayerSendCancel(cid, "Você não está na posição coreta") end
info
Grupo: Campones
Registrado: 20/01/08
Posts: 56
Reputação: 0
Char no Tibia: SKyDevILFiRe

Gente mais um pedido só... =)
Eu adicionei na talkaction e aparece a menssagem mas a talkaction usa...
local function tabletama(tb)
local tam = 0
for i, v in pairs(tb) do
tam = tam + 1
end
return tam
end
function onSay(cid, words, param)
local pos = getPlayerPosition(cid)
pos.stackpos = 0
if getTileThingByPos(pos).actionid == action then
else
doPlayerSendCancelcid, "Você não está na posição coreta")
end
local funcs = {"on", "off", "add", "remove", "list", "help", "list"}
local param = param:lower()
local params = string.explode(param, ",")
local param = params[1]
local action = 7871
local configs = _PV_SHOP_CONFIG
if (configs.pz) == true and getTilePzInfo(getCreaturePosition(cid)) == FALSE then
return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Voce so pode usar os comandos em area pz.")
end
if (getPlayerLevel(cid) < configs.level) then
return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You must be at least level " .. configs.level .. " to use this system.")
end
if not(isInArray(funcs, param)) then
return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Essa alternativa nao existe fale ".. words .. " help.")
end
if (param == "on") then
if (getCreatureCondition(cid, CONDITION_INFIGHT)) then
return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Voce nao pode ativar o shop com seu pz bloqueado.")
end
local pos = getThingPos(cid)
local pos1 = {x = pos.x-5, y = pos.y-5, z = pos.z}
local pos2 = {x = pos.x+5, y = pos.y+5, z = pos.z}
local uids = getUidsInArea(pos1, pos2)
for _, b in pairs(uids) do
if (not(isPlayer(b)) and not (isMonster(b))) then
return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You're near a npc.")
end
end
local pikznelis = 0
for _, a in pairs(getPlayerShopItens(getPlayerGUIDByName(getCreatureName(cid)))) do
pikznelis = 1
break
end
if (pikznelis == 0) then
return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Antes de ativar voce precisa adicionar algum item(s) na lista de venda.")
end
setPlayerStorageValue(cid, 75431, 1)
addEvent(doRemoveCreature, 1, cid)
elseif (param == "add") then
if not(params[4]) then
return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Voce digitou uma alternativa invalida diga ".. words .. " help.")
end
local item = getItemIdByName(params[2])
if not (item) then
return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, params[2] .." isn't a valid item.")
end
if (tabletama(getPlayerShopItens(getPlayerGUIDByName(getCreatureName(cid)))) >= configs.maxitens) then
return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You can't have more than ".. configs.maxitens.." types of items in your Private Shop.")
end
if (isInArray(configs.notadd, item)) then
return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You can't add " .. params[2] .. " to Private Shop.")
end
if not(tonumber(params[3])) or (tonumber(params[3]) < 1) then
return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, params[3] .. " isn't a valid quanty.")
end
if (getPlayerItemCount(cid, item) < tonumber(params[3])) then
return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You haven't ".. params[3] .." " .. params[2] .."(s).")
end
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You added with successful ".. params[3] .. " ".. params[2] .."(s) to your Private Shop.")
doAddItemForPlayerShop(getPlayerGUIDByName(getCreatureName(cid)), item, params[3], params[4])
doPlayerRemoveItem(cid, item, tonumber(params[3]))
elseif (param == "list") then
local itens = getPlayerShopItens(getPlayerGUIDByName(getCreatureName(cid)))
local msgiteins = "Itens in your Private Shop:\n"
for a, b in pairs(itens) do
msgiteins = msgiteins .. "\n".. b[1] .. " " .. getItemNameById(a) .. getPrefix(b[1]) .. " - ".. b[2] .. " Gold Coins"
end
local msgiteins = msgiteins .. "\nX-X-X-X-X-X-X-X-X-X-X-X-X"
doShowTextDialog(cid, 2160, msgiteins)
elseif (param == "remove") then
if not(params[3]) then
return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Voce digitou uma alternativa invalida diga ".. words .. " help.")
end
if not(tonumber(params[3])) or (tonumber(params[3]) < 1) then
return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, params[3] .. " isn't a valid quanty.")
end
local item = getItemIdByName(params[2])
if not (item) then
return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, params[2] .." isn't a item.")
end
local shopt = getPlayerShopItens(getPlayerGUIDByName(getCreatureName(cid)))
if not(shopt[item]) or (tonumber(shopt[item][1]) < tonumber(params[3])) then
return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You haven't ".. params[3] .." " .. params[2] .."(s) in Private Shop.")
end
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You removed with successful ".. params[3] .. " ".. params[2] .."(s) from your Private Shop.")
doRemoveItemFromPlayerShop(getPlayerGUIDByName(getCreatureName(cid)), item, params[3])
doPlayerAddItem(cid, item, tonumber(params[3]))
elseif (param == "help") then
local msg = "Private Shop System Help: \n \n * add - is used to add a item to your Private Shop. \n"
local msg = msg .." Usage Example: " .. words .. " add, item, quanty, price by unit"
local msg = msg .."\n" .. words .. " add, demon armor, 1, 60000\n"
local msg = msg .."\n * remove - is used to remove a item from your Private Shop. \n"
local msg = msg .." Usage Example: " .. words .. " remove, item, quanty"
local msg = msg .."\n" .. words .. " remove, demon armor, 5\n"
local msg = msg .."\n * on - is used to active your Private Shop\n"
local msg = msg .. "\n * list - displays in screen a window containing all items that you have in your Private Shop."
doShowTextDialog(cid, 2160, msg)
end
return true
end
info
Grupo: Príncipe
Registrado: 19/08/10
Posts: 4k
Reputação: +1.1k
Gênero: Masculino

ta ae..
local function tabletama(tb)
local tam = 0
for i, v in pairs(tb) do
tam = tam + 1
end
return tam
end
function onSay(cid, words, param)
local funcs = {"on", "off", "add", "remove", "list", "help", "list"}
local param = param:lower()
local params = string.explode(param, ",")
local param = params[1]
local action = 7871
local configs = _PV_SHOP_CONFIG
local pos = getPlayerPosition(cid)
pos.stackpos = 0
if getTileThingByPos(pos).actionid ~= action then
doPlayerSendCancel(cid, "Você não está na posição coreta")
return true
end
if (configs.pz) == true and getTilePzInfo(getCreaturePosition(cid)) == FALSE then
return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Voce so pode usar os comandos em area pz.")
end
if (getPlayerLevel(cid) < configs.level) then
return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You must be at least level " .. configs.level .. " to use this system.")
end
if not(isInArray(funcs, param)) then
return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Essa alternativa nao existe fale ".. words .. " help.")
end
if (param == "on") then
if (getCreatureCondition(cid, CONDITION_INFIGHT)) then
return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Voce nao pode ativar o shop com seu pz bloqueado.")
end
local pos = getThingPos(cid)
local pos1 = {x = pos.x-5, y = pos.y-5, z = pos.z}
local pos2 = {x = pos.x+5, y = pos.y+5, z = pos.z}
local uids = getUidsInArea(pos1, pos2)
for _, b in pairs(uids) do
if (not(isPlayer(b)) and not (isMonster(b))) then
return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You're near a npc.")
end
end
local pikznelis = 0
for _, a in pairs(getPlayerShopItens(getPlayerGUIDByName(getCreatureName(cid)))) do
pikznelis = 1
break
end
if (pikznelis == 0) then
return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Antes de ativar voce precisa adicionar algum item(s) na lista de venda.")
end
setPlayerStorageValue(cid, 75431, 1)
addEvent(doRemoveCreature, 1, cid)
elseif (param == "add") then
if not(params[4]) then
return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Voce digitou uma alternativa invalida diga ".. words .. " help.")
end
local item = getItemIdByName(params[2])
if not (item) then
return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, params[2] .." isn't a valid item.")
end
if (tabletama(getPlayerShopItens(getPlayerGUIDByName(getCreatureName(cid)))) >= configs.maxitens) then
return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You can't have more than ".. configs.maxitens.." types of items in your Private Shop.")
end
if (isInArray(configs.notadd, item)) then
return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You can't add " .. params[2] .. " to Private Shop.")
end
if not(tonumber(params[3])) or (tonumber(params[3]) < 1) then
return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, params[3] .. " isn't a valid quanty.")
end
if (getPlayerItemCount(cid, item) < tonumber(params[3])) then
return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You haven't ".. params[3] .." " .. params[2] .."(s).")
end
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You added with successful ".. params[3] .. " ".. params[2] .."(s) to your Private Shop.")
doAddItemForPlayerShop(getPlayerGUIDByName(getCreatureName(cid)), item, params[3], params[4])
doPlayerRemoveItem(cid, item, tonumber(params[3]))
elseif (param == "list") then
local itens = getPlayerShopItens(getPlayerGUIDByName(getCreatureName(cid)))
local msgiteins = "Itens in your Private Shop:\n"
for a, b in pairs(itens) do
msgiteins = msgiteins .. "\n".. b[1] .. " " .. getItemNameById(a) .. getPrefix(b[1]) .. " - ".. b[2] .. " Gold Coins"
end
local msgiteins = msgiteins .. "\nX-X-X-X-X-X-X-X-X-X-X-X-X"
doShowTextDialog(cid, 2160, msgiteins)
elseif (param == "remove") then
if not(params[3]) then
return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Voce digitou uma alternativa invalida diga ".. words .. " help.")
end
if not(tonumber(params[3])) or (tonumber(params[3]) < 1) then
return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, params[3] .. " isn't a valid quanty.")
end
local item = getItemIdByName(params[2])
if not (item) then
return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, params[2] .." isn't a item.")
end
local shopt = getPlayerShopItens(getPlayerGUIDByName(getCreatureName(cid)))
if not(shopt[item]) or (tonumber(shopt[item][1]) < tonumber(params[3])) then
return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You haven't ".. params[3] .." " .. params[2] .."(s) in Private Shop.")
end
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You removed with successful ".. params[3] .. " ".. params[2] .."(s) from your Private Shop.")
doRemoveItemFromPlayerShop(getPlayerGUIDByName(getCreatureName(cid)), item, params[3])
doPlayerAddItem(cid, item, tonumber(params[3]))
elseif (param == "help") then
local msg = "Private Shop System Help: \n \n * add - is used to add a item to your Private Shop. \n"
local msg = msg .." Usage Example: " .. words .. " add, item, quanty, price by unit"
local msg = msg .."\n" .. words .. " add, demon armor, 1, 60000\n"
local msg = msg .."\n * remove - is used to remove a item from your Private Shop. \n"
local msg = msg .." Usage Example: " .. words .. " remove, item, quanty"
local msg = msg .."\n" .. words .. " remove, demon armor, 5\n"
local msg = msg .."\n * on - is used to active your Private Shop\n"
local msg = msg .. "\n * list - displays in screen a window containing all items that you have in your Private Shop."
doShowTextDialog(cid, 2160, msg)
end
return true
end
Editado Outubro 11 por Slicer
info
Grupo: Campones
Registrado: 20/01/08
Posts: 56
Reputação: 0
Char no Tibia: SKyDevILFiRe

Duvida Sanada. Por favor Mover topico.
info
Grupo: Infante
Registrado: 04/03/11
Posts: 1.6k
Reputação: +393
Char no Tibia: No Have

Tópico Movido
info
Grupo: Campones
Registrado: 20/01/08
Posts: 56
Reputação: 0
Char no Tibia: SKyDevILFiRe
Olá, gostaria de pedir um script(ou Função não sei ao certo) que faça com que a talkaction seja usada apenas em um tile(s) determinado.
Pedido: Por favor, se possivel gostaria de por actionid ou uniqueid no tile ao invés de position no script.
Possuo esse aqui, mas prefiriria um por actionid pois gostaria de por em uma area e nao apenas 1 tile.
local pos = {x = 123, y = 123, z = 7} if getPlayerPosition(cid) == pos then ---continue o script--- else doPlayerSendCancel(cid, "Você não está na posição coreta") endGrato, anciosamente na espera.
Editado Outubro 11 por SkyDevilFire