Ir para conteúdo
  • 0

Como coloco para não poder usar talkaction em determinada area?


roriscrave

Pergunta

O script da talkaction é esse:

 

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 configs = _PV_SHOP_CONFIG

 

if (configs.premmy) and not(isPremium(cid)) then

return doPlayerSendTextMessage(cid,

 

MESSAGE_STATUS_CONSOLE_ORANGE, "You must have a premium account to use this

 

system.")

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, "You typed a invalid option, to see help window

 

type ".. words .. " help.")

end

 

if (param == "on") then

if (getCreatureCondition(cid, CONDITION_INFIGHT)) then

return doPlayerSendTextMessage(cid,

 

MESSAGE_STATUS_CONSOLE_ORANGE, "You can't activate the system with your pz

 

locked.")

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, "Voce deve adicionar um item no shop antes de

 

ativar.")

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 opcao invalida, para sua

 

ajuda digite ".. words .. " help.")

end

 

local item = getItemIdByName(params[2])

 

if not (item) then

return doPlayerSendTextMessage(cid,

 

MESSAGE_STATUS_CONSOLE_ORANGE, params[2] .." nao eh um item valido.")

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, "You typed a invalid option, to see help window

 

type ".. 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 .." Use como exemplo: " .. words .. " add,

 

item, quandidade, preco por unidade"

local msg = msg .."\n" .. words .. " add, chunnin armor, 1,

 

1000\n"

local msg = msg .."\n * remove - usado para remover o item do

 

seu shop privado. \n"

local msg = msg .." Example: " .. words .. " remove, item,

 

quantidade"

local msg = msg .."\n" .. words .. " remove, chunnin armor,

 

5\n"

local msg = msg .."\n * on - usado para ativar o 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

 

 

E a função que teria que adicionar a ele é +- essa, so que nao ta pegando:

teria que fazer algumas alterações onde esta de vermelho. mas nao sei o que por no lugar delas

 

function onCastSpell(cid, var)

local fromPosition = {x = 959, y = 1111, z = 7} -- top left cornor of the playground

local toPosition = {x = 977, y = 1123, z = 7} -- bottom right cornor of the playground

if isInArea(getThingPosition(cid), fromPosition, toPosition) then

return false, doPlayerSendCancel(cid, "Voce nao pode usar essa runa nesta área.")

end

return doCombat(cid, combat, var)

end

Link para o comentário
Compartilhar em outros sites

4 respostass a esta questão

Posts Recomendados

  • 0

Tenta assim:

 

 

local function tabletama(tb)
local tam = 0

for i, v in pairs(tb) do
tam = tam + 1
end

return tam
end

----------------------------------------
local fromPosition {x = 1, y = 1, z = 1}
local toPosition = {x = 1, y = 1, z = 1}
----------------------------------------

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 configs = _PV_SHOP_CONFIG

if (configs.premmy) and not(isPremium(cid)) then
return doPlayerSendTextMessage(cid,MESSAGE_STATUS_CONSOLE_ORANGE, "You must have a premium account to use thissystem.")
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 isInArea(getThingPosition(cid), fromPosition, toPosition) then
return doPlayerSendTextMessage(cid,MESSAGE_STATUS_CONSOLE_ORANGE, "Você nao pode usar essa talkaction nesta área.")
end

if not(isInArray(funcs, param)) then
return doPlayerSendTextMessage(cid,MESSAGE_STATUS_CONSOLE_ORANGE, "You typed a invalid option, to see help windowtype ".. words .. " help.")
end

if (param == "on") then
if (getCreatureCondition(cid, CONDITION_INFIGHT)) then
return doPlayerSendTextMessage(cid,MESSAGE_STATUS_CONSOLE_ORANGE, "You can't activate the system with your pzlocked.")
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, "Voce deve adicionar um item no shop antes deativar.")
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 opcao invalida, para suaajuda digite ".. words .. " help.")
end

local item = getItemIdByName(params[2])

if not (item) then
return doPlayerSendTextMessage(cid,MESSAGE_STATUS_CONSOLE_ORANGE, params[2] .." nao eh um item valido.")
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 PrivateShop.")
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, "You typed a invalid option, to see help window type ".. 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 usedto add a item to your Private Shop. \n"
local msg = msg .."  Use como exemplo: " .. words .. " add,item, quandidade, preco por unidade"
local msg = msg .."\n" .. words .. " add, chunnin armor, 1,1000\n"
local msg = msg .."\n * remove - usado para remover o item do seu shop privado. \n"
local msg = msg .."  Example: " .. words .. " remove, item, quantidade"
local msg = msg .."\n" .. words .. " remove, chunnin armor,5\n"
local msg = msg .."\n * on - usado para ativar o 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 por SmiX
Link para o comentário
Compartilhar em outros sites

×
×
  • Criar Novo...