Grillo1995
New Member
Hello, I am new to TFS 1.3, I have always worked with TFS 0.4 and I am facing some difficulties until I adapt.
I have a 24Hours Castle system that works perfectly on TFS0.4.
However I need to update it to my TFS 1.3 now, The function of this script below is as follows:
guildOwner (): It has the function of taking from the database who is dominating the castle at the moment.
castleRemoveEnemies (): This function will remove from the castle all enemies of the guild that dominate the castle when ascending the throne (which is a movement that does not matter now)
If you can do a check on the code and tell me what is missing to work properly I would appreciate it! Thanks
In data/lib
015-COH.lua
I have a 24Hours Castle system that works perfectly on TFS0.4.
However I need to update it to my TFS 1.3 now, The function of this script below is as follows:
guildOwner (): It has the function of taking from the database who is dominating the castle at the moment.
castleRemoveEnemies (): This function will remove from the castle all enemies of the guild that dominate the castle when ascending the throne (which is a movement that does not matter now)
If you can do a check on the code and tell me what is missing to work properly I would appreciate it! Thanks
In data/lib
015-COH.lua
Code:
COH_PUSHTIME = 10800
COH_PREPARE1 = 20132011171599
COH_PUSHSTOR = 20132011171699
COH_PREPARE2 = 20132011171799
NW = Position(33186, 32124, 8), Position(33186, 32124, 7), Position(33186, 32124, 6), Position(33186, 32124, 5), Position(33186, 32124, 4), -- Posiçao NW do quadrado minimo envolvente do castelo.
SE = Position(33207, 32167, 8), Position(33207, 32167, 7), Position(33207, 32167, 6), Position(33207, 32167, 5), Position(33207, 32167, 5), -- Posiçao SE do quadrado minimo envolvente do castelo.
function guildOwner()
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 castleRemoveEnemies()
local players = Game.getPlayers()
for i = 1, #players do
local pos = players[i]:getPosition()
local temple = players[i]:getTown():getTemplePosition()
if pos.x >= config.NW.x and pos.y >= config.NW.y and pos.x <= config.SE.x and pos.y <= config.SE.y then
if (guildVencedora() ~= player[i]:getGuild()) then
players[i]:teleportTo(temple)
temple:sendMagicEffect(CONST_ME_TELEPORT)
player[i]:setStorageValue(COH_PREPARE1, -1)
player[i]:setStorageValue(COH_PREPARE2, -1)
end
end
end
return true
end