/town Em Battle~

Akuron
Por Akuron
em Scripts

Akuron

avatar
Campones
Campones

INFOS

Grupo: CamponesRegistrado: 09/10/08Posts: 12

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

Vodkart

Sumus Validus
avatar
Herói
Herói

INFOS

Grupo: HeróiRegistrado: 21/05/10Posts: 3406Gênero: Masculino
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

bossisg.png

Akuron

avatar
Campones
Campones

INFOS

Grupo: CamponesRegistrado: 09/10/08Posts: 12

Agradeço. ^^

luisfe23

avatar
Conde
Conde

INFOS

Grupo: CondeRegistrado: 31/10/08Posts: 871Char no Tibia: Luis Felipe Knight

Tópico movido para a subseção referente a esta área.

Caso o usuário necessite de ajuda avançada, deverá utilizar o mesmo tópico.

 

Abraços.

luisfe23 here