Ir para conteúdo
  • 0

/town Em Battle~


Akuron

Pergunta

Eu libero o /town para os players, mas gostaria de saber como fazer para que esse comando não desse para usar em modo de batalha, para evitar fujões de "PKs".

 

Meu script é assim.

 

function onSay(cid, words, param, channel)

if(param == '') then

doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command requires param.")

return true

end

 

local tid = cid

local t = string.explode(param, ",")

if(t[2]) then

tid = getPlayerByNameWildcard(t[2])

if(not tid or (isPlayerGhost(tid) and getPlayerGhostAccess(tid) > getPlayerGhostAccess(cid))) then

doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Player " .. t[2] .. " not found.")

return true

end

end

 

local tmp = t[1]

if(not tonumber(tmp)) then

tmp = getTownId(tmp)

if(not tmp) then

doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Town " .. t[1] .. " does not exists.")

return true

end

end

 

local pos = getTownTemplePosition(tmp, false)

if(not pos or isInArray({pos.x, pos.y}, 0)) then

doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Town " .. t[1] .. " does not exists or has invalid temple position.")

return true

end

 

pos = getClosestFreeTile(tid, pos)

if(not pos or isInArray({pos.x, pos.y}, 0)) then

doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Destination not reachable.")

return true

end

 

tmp = getCreaturePosition(tid)

if(doTeleportThing(tid, pos, true) and not isPlayerGhost(tid)) then

doSendMagicEffect(tmp, CONST_ME_POFF)

doSendMagicEffect(pos, CONST_ME_TELEPORT)

end

 

return true

end

Editado por Akuron
Link para o comentário
Compartilhar em outros sites

3 respostass a esta questão

Posts Recomendados

  • 0
function onSay(cid, words, param, channel)

local config ={
skull = "no", -- players podem estar com skull? ("yes" or "no").
protection_zone = "no", -- players precisam estar em protection zone? ("yes" or "no").
battle = "yes" -- players precisam estar sem fight? ("yes" or "no").
}

if(param == '') then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command requires param.")
return true
end

local tid = cid
local t = string.explode(param, ",")
if(t[2]) then
tid = getPlayerByNameWildcard(t[2])
if(not tid or (isPlayerGhost(tid) and getPlayerGhostAccess(tid) > getPlayerGhostAccess(cid))) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Player " .. t[2] .. " not found.")
return true
end
end

local tmp = t[1]
if(not tonumber(tmp)) then
tmp = getTownId(tmp)
if(not tmp) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Town " .. t[1] .. " does not exists.")
return true
end
end

local pos = getTownTemplePosition(tmp, false)
if(not pos or isInArray({pos.x, pos.y}, 0)) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Town " .. t[1] .. " does not exists or has invalid temple position.")
return true
end

pos = getClosestFreeTile(tid, pos)
if(not pos or isInArray({pos.x, pos.y}, 0)) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Destination not reachable.")
return true
end


if(config.skull == "no") and (getCreatureSkullType(cid) >= 3) then
doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, "apenas players sem skulls podem usar este comando.")
elseif(config.protection_zone == "yes") and (getTilePzInfo(getCreaturePosition(cid)) == FALSE) then
doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT,"você precisa estar em protection zone para usar este comando.")
elseif(config.battle == "yes") and (getCreatureCondition(cid, CONDITION_INFIGHT) == TRUE) then
doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, "Você precisa estar sem battler para usar este comando.")
return TRUE
end

tmp = getCreaturePosition(tid)
if(doTeleportThing(tid, pos, true) and not isPlayerGhost(tid)) then
doSendMagicEffect(tmp, CONST_ME_POFF)
doSendMagicEffect(pos, CONST_ME_TELEPORT)
end

return TRUE
end

Editado por Vodkart
Link para o comentário
Compartilhar em outros sites

×
×
  • Criar Novo...