I know it's a lot to ask, but can anyone convert this script to TFS 1.5? If possible in revscript?
lib folder:
movements folder:
talkactions folder:
lib folder:
Lua:
COH_PUSHTIME = 10800 -- Tempo (em segundos) de exhausted para usar o comando !gocastle - Padrão (3 horas)
COH_AREA = {{x = 11107, y = 1104, z = 7}, {x = 1109, y = 1106, z = 7}} -- Canto superior esquerdo / inferior direito do Castle
-- // Não mexa daqui para baixo
COH_STATUS = 201320111714
COH_PREPARE1 = 201320111715
COH_PUSHSTOR = 201320111716
COH_PREPARE2 = 201320111717
function guildVencedora()
local name
local consulta = db.getResult("SELECT `guild` FROM `castelo_guerra` ORDER BY `id` DESC;")
if (consulta:getID() ~= -1) then
name = tonumber(consulta:getDataInt('guild'))
else
return 0
end
return name
end
function doCastleRemoveEnemies()
for index, creature in ipairs(getPlayersOnline()) do
if isInArea(getThingPos(creature), COH_AREA[1], COH_AREA[2]) then
if (guildVencedora() ~= getPlayerGuildId(cid)) then
doTeleportThing(creature, getTownTemplePosition(getPlayerTown(creature)))
end
end
end
return true
end
movements folder:
Lua:
function onStepIn(cid, item, pos, fromPosition)
local pos = getThingPos(cid)
if item.actionid == 16203 then
if not isPlayer(cid) then
return true
end
if (getPlayerGuildId(cid) == guildVencedora()) then
doSendMagicEffect(getThingPos(cid), 14)
doSendAnimatedText(pos, "CW", math.random(1, 255))
else
doSendMagicEffect(getThingPos(cid), 2)
doTeleportThing(cid, fromPosition, false)
doPlayerSendCancel(cid, "[CASTLE WAR 24H] Você não pertence á guild dominante.")
end
return true
end
if item.actionid == 16202 then
if not isPlayer(cid) then
return true
end
if getPlayerGuildId(cid) > 0 then
if (getPlayerGuildId(cid) == guildVencedora()) then
doPlayerSendCancel(cid, "[CASTLE WAR 24H] Sua guild ja esta dominando.")
return false
end
if (getPlayerGuildId(cid) ~= guildVencedora()) and (getPlayerLevel(cid) >= 100) then
doPlayerSendTextMessage(cid, 20, "[CASTLE WAR 24H] Você e sua guild estão no comando, os antigos donos podem se vingar!")
setGlobalStorageValue(COH_PREPARE1, -1)
setGlobalStorageValue(COH_PREPARE2, -1)
db.query("INSERT INTO `castelo_guerra` (`guild`) VALUES (" .. getPlayerGuildId(cid) .. ");")
doCastleRemoveEnemies()
doBroadcastMessage("[CASTLE WAR 24H] O jogador ["..getCreatureName(cid).."] e sua guild ["..getPlayerGuildName(cid).."] estão no comando do castelo, vá dominar e impedir isso!")
end
else
doSendMagicEffect(pos, 2)
doTeleportThing(cid, fromPosition, false)
doPlayerSendCancel(cid, "[CASTLE WAR 24H] Você não possui uma guild.")
end
return true
end
if item.actionid == 16200 then
if not isPlayer(cid) then
return true
end
if getPlayerGuildId(cid) > 0 then
doSendAnimatedText(pos, "CW", math.random(1, 255))
if (getPlayerGuildId(cid) == guildVencedora()) and (getGlobalStorageValue(COH_PREPARE1) ~= getPlayerGuildName(cid)) and ((getGlobalStorageValue(COH_PREPARE2) ~= getPlayerGuildName(cid))) then
setGlobalStorageValue(COH_PREPARE1, getPlayerGuildName(cid))
doBroadcastMessage("[CASTLE WAR 24H] Atenção! A guild "..getPlayerGuildName(cid).." está tentando dominar o castelo, preparem-se!")
end
else
doSendMagicEffect(pos, 2)
doTeleportThing(cid, fromPosition, false)
doPlayerSendCancel(cid, "[CASTLE WAR 24H] Você não possui uma guild.")
return true
end
end
if item.actionid == 16201 then
if not isPlayer(cid) then
return true
end
doSendAnimatedText(pos, "CW", math.random(1, 255))
if (getPlayerGuildId(cid) == guildVencedora()) and (getGlobalStorageValue(COH_PREPARE2) ~= getPlayerGuildName(cid)) then
setGlobalStorageValue(COH_PREPARE2, getPlayerGuildName(cid))
doBroadcastMessage("[CASTLE WAR 24H] Atenção! A guild "..getPlayerGuildName(cid).." está muito próxima do domínio, ataquem!")
end
end
return true
end
talkactions folder:
Lua:
function onSay(cid, words, param)
if getPlayerGuildLevel(cid) == GUILDLEVEL_LEADER then
if getPlayerStorageValue(cid, COH_PUSHSTOR) < os.time() then
if (getPlayerGuildId(cid) == guildVencedora()) then
if isInArea(getThingPos(cid), COH_AREA[1], COH_AREA[2]) then
if #getMembersOnline(getPlayerGuildId(cid)) > 0 then
for index, creature in ipairs(getMembersOnline(getPlayerGuildId(cid))) do
if (getTileInfo(getThingPos(creature)).protection ~= true) then
return doPlayerSendCancel(cid, "[CoH] Os membros devem estar em área PZ.")
end
doTeleportThing(creature, getThingPos(cid))
end
setPlayerStorageValue(cid, COH_PUSHSTOR, os.time() + COH_PUSHTIME)
doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "[Castle of Honor] Você teleportou seus membros, comando pode ser usado a cada "..tostring(COH_PUSHTIME / 60).." minuto(s).")
else
doPlayerSendCancel(cid, "[CoH] Para executar isso, sua guild deve ter 2 ou mais membros online.")
end
else
doPlayerSendCancel(cid, "[CoH] Você deve estar no castelo.")
end
else
doPlayerSendCancel(cid, "[CoH] Sua guild não é dona do castelo.")
end
else
doPlayerSendCancel(cid, "[CoH] Você deve aguardar "..tostring(math.ceil((getPlayerStorageValue(cid, COH_PUSHSTOR) - os.time()) / 60)).." minuto(s) para usar este comando.")
end
else
doPlayerSendCancel(cid, "[CoH] Você deve ser líder de uma guild para executar este comando.")
end
return true
end
function getMembersOnline(id)
local mbr = {}
for index, creature in ipairs(getPlayersOnline()) do
if getPlayerGuildId(creature) == id then
if getCreatureSkullType(creature) < 3 then
table.insert(mbr, creature)
end
end
end
return mbr or #mbr
end