• 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!

[MOD] Map Change (for war servers)

The db.query fucks everything up so I'm working on a solution myself. I'll post whenever I get it working fully :)
 
Tested it out on my own server. Teleport back and forth between Thais, Venore and Kazordoon.

Everything seems to be working fine.

Globalevent:

Code:
local conditions = {
CONDITION_POISON,
CONDITION_FIRE,
CONDITION_ENERGY,
CONDITION_CURSED,
CONDITION_DAZZLED
}


function onThink(interval, lastExecution)
    local town = Game.getStorageValue(1000)
    if town == 1 then
        Game.setStorageValue(1000, 2)
    elseif town == 2 then
        Game.setStorageValue(1000, 3)
    else
        Game.setStorageValue(1000, 1)
    end
     
    for _, pid in ipairs(Game.getPlayers()) do
        local player = Player(pid)
        local town = Town(Game.getStorageValue(1000))
        player:teleportTo(town:getTemplePosition())
        player:removeCondition(CONDITION_INFIGHT, CONDITIONID_DEFAULT)
        player:addHealth(player:getMaxHealth())
        player:addMana(player:getMaxMana())
        for i=1, #conditions do
        Player(pid):removeCondition(conditions[i])
        end
    end
    Game.broadcastMessage("Map has been changed! Next map change will be in 25 minutes!", MESSAGE_STATUS_WARNING)
    db.query("UPDATE players SET town_id = ".. Game.getStorageValue(1000) ..", posx = 0, posy = 0, posz = 0;")
return true
end

Creaturescript:
Code:
function onLogin(cid)
    local player = Player(cid)
    local town = Town(Game.getStorageValue(1000))
    player:setTown(town:getId())
    player:teleportTo(player:getTown():getTemplePosition())
    return true
end
 
Last edited:
The globalevent is working fine (except broadcast)

The creaturescript though is not really doing it's job.
 
Tested it out on my own server. Teleport back and forth between Thais, Venore and Kazordoon.

Everything seems to be working fine.

Globalevent:

Code:
local conditions = {
CONDITION_POISON,
CONDITION_FIRE,
CONDITION_ENERGY,
CONDITION_CURSED,
CONDITION_DAZZLED
}


function onThink(interval, lastExecution)
    local town = Game.getStorageValue(1000)
    if town == 1 then
        Game.setStorageValue(1000, 2)
    elseif town == 2 then
        Game.setStorageValue(1000, 3)
    else
        Game.setStorageValue(1000, 1)
    end
     
    for _, pid in ipairs(Game.getPlayers()) do
        local player = Player(pid)
        local town = Town(Game.getStorageValue(1000))
        player:teleportTo(town:getTemplePosition())
        player:removeCondition(CONDITION_INFIGHT, CONDITIONID_DEFAULT)
        player:addHealth(player:getMaxHealth())
        player:addMana(player:getMaxMana())
        for i=1, #conditions do
        Player(pid):removeCondition(conditions[i])
        end
    end
    Game.broadcastMessage("Map has been changed! Next map change will be in 25 minutes!", MESSAGE_STATUS_WARNING)
    db.query("UPDATE players SET town_id = ".. Game.getStorageValue(1000) ..", posx = 0, posy = 0, posz = 0;")
return true
end

Creaturescript:
Code:
function onLogin(cid)
local player = Player(cid)
    if new ~= nil then
        player:setTown(new)
        player:teleportTo(player:getTown():getTemplePosition())
    else
        player:setTown(1)
        player:teleportTo(player:getTown():getTemplePosition())
    end
return true
end
where is declared new?
 
Sorry I pasted the wrong one, I uploaded my current one now. The last one was part of the old system when we were still using the variable new.

I'm not having any problems with the broadcast. What errors are you having with that?
 
This is what I'm getting when I'm trying to login with the one you updated.

a4c53083d5bc8085900cb4a8166c3a7c.png


I only get this error when I have restarted the server.
If I disable this script, login, let it change map or whatever, then activate this and relog then it works.
But if I have this script activated when starting the server and try to login I get the error shown on the image above.

Also the broadcasting works now, I replaced my things to original TFS, must have had some bad shit in my data pack before.
 
Try this:
@Pnurt
So for the global event you will have to register startup now as well:
Code:
    <globalevent name="MapChange" interval="100000" script="mapchange.lua"/>
    <globalevent type="startup" name="MapStart" script="mapchange.lua"/>

Globalevent:
Code:
local conditions = {
CONDITION_POISON,
CONDITION_FIRE,
CONDITION_ENERGY,
CONDITION_CURSED,
CONDITION_DAZZLED
}


function onThink(interval, lastExecution)
    local town = Game.getStorageValue(1000)
    if town == 1 then
        Game.setStorageValue(1000, 2)
    elseif town == 2 then
        Game.setStorageValue(1000, 3)
    else
        Game.setStorageValue(1000, 1)
    end
      
    for _, pid in ipairs(Game.getPlayers()) do
        local player = Player(pid)
        local town = Town(Game.getStorageValue(1000))
        player:teleportTo(town:getTemplePosition())
        player:removeCondition(CONDITION_INFIGHT, CONDITIONID_DEFAULT)
        player:addHealth(player:getMaxHealth())
        player:addMana(player:getMaxMana())
        for i=1, #conditions do
        Player(pid):removeCondition(conditions[i])
        end
    end
    Game.broadcastMessage("Map has been changed! Next map change will be in 25 minutes!", MESSAGE_STATUS_WARNING)
    db.query("UPDATE players SET town_id = ".. Game.getStorageValue(1000) ..", posx = 0, posy = 0, posz = 0;")
return true
end

function onStartup()
Game.setStorageValue(1000, 3)
db.query("UPDATE players SET town_id = ".. Game.getStorageValue(1000) ..", posx = 0, posy = 0, posz = 0;")
end

Creaturescript:
Code:
function onLogin(cid)
    local player = Player(cid)
    player:setTown(Game.getStorageValue(1000))
    player:teleportTo(player:getTown():getTemplePosition())
    return true
end
 
Last edited:
I already just added Game.setStorageValue(1000, 2)
to startup.lua :)
 
@LucasFerraz hello..

Lucas i need some help!

I am searching for war team event. Red vs blue..

But i want not change mape i mean when event start you use same mAp of city...

And i want you got double exp in red vs blue event.

Pls sir help me if u can
 
Back
Top