• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Lua Castle War

_M4G0_

Well-Known Member
Joined
Feb 6, 2016
Messages
509
Solutions
16
Reaction score
99
I need help in this script, all function work perfectly but function for remove Enemies don't work
unsing tfs 1.2 10.99
Globalents
Lua:
function onTime()

    Game.broadcastMessage("[Castle Of Honor] Castle is open! All guilds have 1 HOUR to dominate it, after that it will be closed again and opened only in 24hrs!", MESSAGE_EVENT_ADVANCE)
    Game.createItem(469, 1, Position(6260, 6744, 7))
    addEvent(COH, 2 * 60 * 1000)
end

function COH()
    Game.broadcastMessage("[Castle Of Honor] Closed!", MESSAGE_EVENT_ADVANCE)
    local gatepos = {x=6260, y=6744, z=7, stackpos=1}
    local getgate = getTileItemById(gatepos, 469)
  
    doRemoveItem(getgate.uid,1)
    Game.createItem(4532, 1, Position(6260, 6744, 7))
    doCastleRemoveEnemies()
end

Lib
Lua:
COH_PUSHTIME = 10800
COH_AREA = {{x = 6371, y = 6592, z = 7}, {x = 6394, y = 6636, z = 7}}
COH_STATUS = 201320111714
COH_PREPARE1 = 201320111715
COH_PUSHSTOR = 201320111716
COH_PREPARE2 = 201320111717
function doCastleRemoveEnemies()
    for index, player in ipairs(Game.getPlayers()) do
        if isInRange(player:getPosition(), COH_AREA[1], COH_AREA[2]) then
            local guild = player:getGuild()
            if guild and guild:getName() ~= Game.getStorageValue(COH_STATUS) then
                player:teleportTo(player:getTown():getTemplePosition())
            end
        end
    end
    return true
end
 
Solution
I need help in this script, all function work perfectly but function for remove Enemies don't work
unsing tfs 1.2 10.99
Globalents
Lua:
function onTime()

    Game.broadcastMessage("[Castle Of Honor] Castle is open! All guilds have 1 HOUR to dominate it, after that it will be closed again and opened only in 24hrs!", MESSAGE_EVENT_ADVANCE)
    Game.createItem(469, 1, Position(6260, 6744, 7))
    addEvent(COH, 2 * 60 * 1000)
end

function COH()
    Game.broadcastMessage("[Castle Of Honor] Closed!", MESSAGE_EVENT_ADVANCE)
    local gatepos = {x=6260, y=6744, z=7, stackpos=1}
    local getgate = getTileItemById(gatepos, 469)
 
    doRemoveItem(getgate.uid,1)
    Game.createItem(4532, 1, Position(6260, 6744, 7))
    doCastleRemoveEnemies()...
I need help in this script, all function work perfectly but function for remove Enemies don't work
unsing tfs 1.2 10.99
Globalents
Lua:
function onTime()

    Game.broadcastMessage("[Castle Of Honor] Castle is open! All guilds have 1 HOUR to dominate it, after that it will be closed again and opened only in 24hrs!", MESSAGE_EVENT_ADVANCE)
    Game.createItem(469, 1, Position(6260, 6744, 7))
    addEvent(COH, 2 * 60 * 1000)
end

function COH()
    Game.broadcastMessage("[Castle Of Honor] Closed!", MESSAGE_EVENT_ADVANCE)
    local gatepos = {x=6260, y=6744, z=7, stackpos=1}
    local getgate = getTileItemById(gatepos, 469)
 
    doRemoveItem(getgate.uid,1)
    Game.createItem(4532, 1, Position(6260, 6744, 7))
    doCastleRemoveEnemies()
end

Lib
Lua:
COH_PUSHTIME = 10800
COH_AREA = {{x = 6371, y = 6592, z = 7}, {x = 6394, y = 6636, z = 7}}
COH_STATUS = 201320111714
COH_PREPARE1 = 201320111715
COH_PUSHSTOR = 201320111716
COH_PREPARE2 = 201320111717
function doCastleRemoveEnemies()
    for index, player in ipairs(Game.getPlayers()) do
        if isInRange(player:getPosition(), COH_AREA[1], COH_AREA[2]) then
            local guild = player:getGuild()
            if guild and guild:getName() ~= Game.getStorageValue(COH_STATUS) then
                player:teleportTo(player:getTown():getTemplePosition())
            end
        end
    end
    return true
end

Use print to see what is false in the if statments.
Lua:
        if isInRange(player:getPosition(), COH_AREA[1], COH_AREA[2]) then
            local guild = player:getGuild()
            if guild and guild:getName() ~= Game.getStorageValue(COH_STATUS) then

Ex
Lua:
print(isInRange(player:getPosition(), COH_AREA[1], COH_AREA[2]))
If that dosn't print true you have your problem, ex positions etc
 
Solution
Ok thanks.
large storage works normally?

Use print to see what is false in the if statments.
Lua:
        if isInRange(player:getPosition(), COH_AREA[1], COH_AREA[2]) then
            local guild = player:getGuild()
            if guild and guild:getName() ~= Game.getStorageValue(COH_STATUS) then

Ex
Lua:
print(isInRange(player:getPosition(), COH_AREA[1], COH_AREA[2]))
If that dosn't print true you have your problem, ex positions etc
 
Back
Top