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

Map changing

Chava

New Member
Joined
Jul 6, 2009
Messages
280
Reaction score
0
Requesting a script where after a certain amount of time (30 minutes) the players online gets tped to the next town (if you're in town 1 you get to 2, if you are in 2 you get to 3 etc.) And I also want that once a player gets tpd to another town ALL the towd ids of every char on the server gets changed to the current town they are in. << I have already foudn a script that works liek that but I have another thing I want in the script. I want the two teams to get tpd to different locations, example, blue gets tpd to on position and red to another. I'd appreciate it if anyone could help me with this :p
 
its kinda like this, theres gonna be 2 different teams and im gonna put a storage value on every player on each team (every player of team 1 are gna have the same and every player of 2 team the same) so like this, after 30 min all players with team 1 storage gets tpd to one place and all players with team 2 storage gets tpd to other place and then again after 30 miin they get tped back and its goes on like that every 30 min
 
Try this:
data/globalevents/scripts/mapchange.lua
LUA:
function onThink(interval, lastExecution)
---------------------------------------
----------------------toY200--------------------------
----------------------------------------------------
-------fromX100----------------------toX200-----------      ---------- explanation of area
-------------------------------------------
--------------------------------------------------
---------------------fromY100----------------------
----------------------------------------------


local t = {}
local s = {}

local storages = { ----- [STORAGE] = {bang[dont edit], fromX, toX, fromY, toY(points that creates an area)
[8888] = {bang = t, fromX = 100, toX = 200, fromY = 100, toY = 200}, ------Change this to ur storages
[8889] = {bang = s, fromX = 500, toX = 600, fromY = 500, toY = 600} ------Change this to ur storages
}

local Globalstorages = {
[2] = {{x=EDIT, y=EDIT, z=EDIT}, {x=EDIT, y=EDIT, z=EDIT}}, ---- 1st will tp team1(storage 8888) 2nd will tp team2(storage 8889)
[3] = {{x=EDIT, y=EDIT, z=EDIT}, {x=EDIT, y=EDIT, z=EDIT}}
}


if interval == 60 then
   doBroadcastMessage("Map will change in 1 minute! Get ready")
end

q = getGlobalStorageValue(cid,8888)
if q <= 0 then
 j = 1 
else
j = q
end

for k, j in pairs(storages) do
    if getPlayerStorageValue(cid,k) > 0 then 
       for x = j.fromX, j.toX do
	       for y = j.fromY, j.toY do
	           for z = 1, 15 do
		       local v = getTopCreature({x=x, y=y, z=z}).uid
               if isPlayer(v) then
                  table.insert(j.bang, v)
                  setGlobalStorageValue(cid,8888,1+j)
               end
               end
           end
        end
     end
end
local x = Globalstorages[getGlobalStorageValue(cid,8888)]
if x then
   for i = 1, #t do
       doTeleportThing(t[i],x[1])
   end
   for m = 1, #s do
       doTeleportThing(s[i],x[2])
   end
setGlobalStorageValue(q(cid,8888)+1)
elseif q(cid,8888) == 3 then
       setGlobalStorageValue(cid,8888,0)
end
return true
end

globalevents.xml
XML:
<globalevent name="mapchange" interval="7200" event="script" value="mapchange.lua"/>
 
Last edited:
Yes, it contains only for 2 cities.
It will go to 1 city, and then go back to the 1st one, you can put more too, but you need a small edit in script.
Edited script, forgot bout area thingy.
 
Could you explain? Because this is how I want it, after 30 min team1 automatically gets to their temple and team2 gets to their temple and then again after 30 min i want team1 to get to their temple in the first city and team2 to get to theirs
 
Works like this
City 1 ------ 30minutes -> TP to city 2 -----> 30 minutes -> TP to city 1 -----> 30 minutes -> TP to city 2.......
You only want it for 1 city?
Like:
City 1 ------> 30 mins -> TP to city 1 ---> 30 mins -> TP to city 1 [temple obviously]
 
This is how I want it; lets say they get tpd to the baot and the temple
city 1 --- 30 min ----> team1 gets tpd to boat and team2 gets tpd to temple of city2
city 2 --- 30 min ----> team1 gets tpd to boat and team2 gets tpd to temple of city1

and it goes on like that, in your script i dont see enough positions? i mean there should be 4 locations specified and i only see 2 in ur script
 
Nop, 4 positions look
LUA:
local Globalstorages = {
[2] = {{x=EDIT, y=EDIT, z=EDIT}, {x=EDIT, y=EDIT, z=EDIT}}, ---- 1st will tp team1(storage 8888) 2nd will tp team2(storage 8889)
[3] = {{x=EDIT, y=EDIT, z=EDIT}, {x=EDIT, y=EDIT, z=EDIT}}
}
Test it anyway, Im pretty sure it will be bugged.
 
Could sell you a full working map change, with msges, time for next map change, giving rewards on mapchange according to storage to winner, a login script which will make players who login get tped to their team's temple according to the current map.Fully configurable, on change show map name time for next change.
 
I made this system a while ago too, here is my version for my teambattle server I made:
This works 100% for me so you shouldnt have any problem with it

Globalevent changeMap.lua:
Code:
function onThink(interval, lastExecution, thinkInterval)
    local maps = {
        [1] = {mapName = "Ignitos", redTemple = {x = 1153, y = 1069, z = 6}, blueTemple = {x = 1146, y = 1120, z = 6}},
        [2] = {mapName = "Dust2", redTemple = {x = 1169, y = 1192, z = 7}, blueTemple = {x = 1107, y = 1176, z = 6}},
        [3] = {mapName = "Fridge", redTemple = {x = 1277, y = 1035, z = 3}, blueTemple = {x = 1225, y = 1035, z = 3}},
    }
    
    local teams = {
        blueName = "Blue Bangbabies",
        redName = "Red Rageboys",
        blueScore = 101,
        redScore = 102,
        bluePlayerScore = 1004,
        redPlayerScore = 1006,
    }
    
    local map = maps[getGlobalStorageValue(100)]

    if getGlobalStorageValue(100) <= 0 then
        setGlobalStorageValue(100, 1)
    elseif getGlobalStorageValue(100) >= math.max(1, #maps) then
        setGlobalStorageValue(100, 1)
    elseif getGlobalStorageValue(100) >= 1 then
        setGlobalStorageValue(100, getGlobalStorageValue(100)+1)
    end
    
    if map then
        for _, cid in ipairs(getPlayersOnline()) do
            if getPlayerStorageValue(cid, 1002) == 1 then
                doTeleportThing(cid, map.blueTemple)
                doSendMagicEffect(getPlayerPosition(cid), CONST_ME_TELEPORT)
            elseif getPlayerStorageValue(cid, 1003) == 1 then
                doTeleportThing(cid, map.redTemple)
                doSendMagicEffect(getPlayerPosition(cid), CONST_ME_TELEPORT)
            end
            if getGlobalStorageValue(teams.blueScore) > getGlobalStorageValue(teams.redScore) then
                str = "\n\nThe " .. teams.blueName .. " won!\n\nScores:\n" .. teams.blueName .. " " .. getGlobalStorageValue(blueScore) .. " - " .. getGlobalStorageValue(redScore) .. " " .. teams.redName .. "."
            elseif getGlobalStorageValue(teams.redScore) > getGlobalStorageValue(teams.blueScore) then
                str = "\n\nThe " .. teams.redName .. " won!\n\nScores:\n" .. teams.blueName .. " " .. getGlobalStorageValue(blueScore) .. " - " .. getGlobalStorageValue(redScore) .. " " .. teams.redName .. "."
            end
        doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "Map has been changed to " .. map.mapName .. "! Next map in 30 minutes!" .. str)
        end
        setGlobalStorageValue(teams.blueScore, 0)
        setGlobalStorageValue(teams.redScore, 0)
    end
return true
end
Globalevent teamScores.lua:
Code:
local blueScore = 101
local redScore = 102
local teams = {
    blueName = "Blue Bangbabies",
    redName = "Red Rageboys",
    }

function onThink(interval, lastExecution, thinkInterval)
    if getGlobalStorageValue(blueScore) > getGlobalStorageValue(redScore) then
        str = "The leading team is the " .. teams.blueName .. "!\n\nScores:\n" .. teams.blueName .. " " .. getGlobalStorageValue(blueScore) .. " - " .. getGlobalStorageValue(redScore) .. " " .. teams.redName .. "."
    elseif getGlobalStorageValue(redScore) > getGlobalStorageValue(blueScore) then
        str = "The leading team is the " .. teams.redName .. "!\n\nScores:\n" .. teams.redName .. " " .. getGlobalStorageValue(redScore) .. " - " .. getGlobalStorageValue(blueScore) .. " " .. teams.blueName .. "."
    elseif getGlobalStorageValue(redScore) == getGlobalStorageValue(blueScore) then
        str = "The teams is tied to the lead!\n\nScores:\n" .. teams.redName .. " " .. getGlobalStorageValue(redScore) .. " - " .. getGlobalStorageValue(blueScore) .. " " .. teams.blueName .. "."
    end
    doBroadcastMessage(str .. "\n\nPlayers:\n" .. teams.blueName .. " - " .. getGlobalStorageValue(1000) .. " vs " .. getGlobalStorageValue(1001) .. " - " .. teams.redName .. ".", MESSAGE_EVENT_ORANGE)
return true
end
Globalevent teams.lua:
Code:
local conditionBlue = createConditionObject(CONDITION_OUTFIT)
        setConditionParam(conditionBlue, CONDITION_PARAM_TICKS, 1800 * 1000)
        addOutfitCondition(conditionBlue, {lookType = 130, lookHead = 87, lookBody = 87, lookLegs = 87, lookFeet = 87})
local conditionRed = createConditionObject(CONDITION_OUTFIT)
        setConditionParam(conditionRed, CONDITION_PARAM_TICKS, 1800 * 1000)
        addOutfitCondition(conditionRed, {lookType = 130, lookHead = 94, lookBody = 94, lookLegs = 94, lookFeet = 94})

function onThink(interval, lastExecution, thinkInterval)
    for _, cid in ipairs(getPlayersOnline()) do    
        if getPlayerStorageValue(cid, 1002) == 1 then
            doAddCondition(cid, conditionBlue)
        elseif getPlayerStorageValue(cid, 1003) == 1 then
            doAddCondition(cid, conditionRed)
        end
    end
return true
end
Globalevent.xml:
Code:
<globalevent name="changeMap" interval="1800" event="script" value="changeMap.lua"/>
<globalevent name="teamScores" interval="80" event="script" value="teamScores.lua"/>
<globalevent name="teams" interval="1800" event="script" value="teams.lua"/>



Creaturescript teamLogin.lua (sets the team of a player and teleports to the right map):

Code:
local maps = {
        [1] = {mapName = "Ignitos", redTemple = {x = 1153, y = 1069, z = 6}, blueTemple = {x = 1146, y = 1120, z = 6}},
        [2] = {mapName = "Dust2", redTemple = {x = 1169, y = 1192, z = 7}, blueTemple = {x = 1107, y = 1176, z = 6}},
        [3] = {mapName = "Fridge", redTemple = {x = 1277, y = 1035, z = 3}, blueTemple = {x = 1225, y = 1035, z = 3}},
    }
local teams = {
    blueName = "Blue Bangbabies",
    redName = "Red Rageboys",
    blueScore = 101,
    redScore = 102,
    bluePlayerScore = 1004,
    redPlayerScore = 1006,
    }
    
local blueScore = 101
local redScore = 102

local conditionBlue = createConditionObject(CONDITION_OUTFIT)
        setConditionParam(conditionBlue, CONDITION_PARAM_TICKS, 1800 * 1000)
        addOutfitCondition(conditionBlue, {lookType = 130, lookHead = 87, lookBody = 87, lookLegs = 87, lookFeet = 87})
local conditionRed = createConditionObject(CONDITION_OUTFIT)
        setConditionParam(conditionRed, CONDITION_PARAM_TICKS, 1800 * 1000)
        addOutfitCondition(conditionRed, {lookType = 130, lookHead = 94, lookBody = 94, lookLegs = 94, lookFeet = 94})

function onLogin(cid)
setPlayerStorageValue(cid, 1002, 0)
setPlayerStorageValue(cid, 1003, 0)
local map = maps[getGlobalStorageValue(100)]
    if map then
        if getGlobalStorageValue(1000) > getGlobalStorageValue(1001) then
            setPlayerStorageValue(cid, 1003, 1)
            doAddCondition(cid, conditionRed)
            doTeleportThing(cid, map.redTemple)
            doSendMagicEffect(getPlayerPosition(cid), CONST_ME_TELEPORT)
            setGlobalStorageValue(1001, getGlobalStorageValue(1001)+1)
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You were sent to fight for the " .. teams.redName .. "!\nYour team have scored " .. getGlobalStorageValue(redScore) .. " kills.\nCurrent map is " .. map.mapName .. ".")
            
        else
            setPlayerStorageValue(cid, 1002, 1)
            doAddCondition(cid, conditionBlue)
            doTeleportThing(cid, map.blueTemple)
            doSendMagicEffect(getPlayerPosition(cid), CONST_ME_TELEPORT)
            setGlobalStorageValue(1000, getGlobalStorageValue(1000)+1)
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You were sent to fight for the " .. teams.blueName .. "!\nYour team have scored " .. getGlobalStorageValue(blueScore) .. " kills.\nCurrent map is " .. map.mapName .. ".")
        end
    end
    if getPlayerStorageValue(cid, 10000) == 1 then
        doPlayerAddExperience(cid, -getPlayerExperience(cid) + getExperienceForLevel(130))
    elseif getPlayerStorageValue(cid, 10000) ~= 1 then
        doPlayerAddExperience(cid, -getPlayerExperience(cid) + getExperienceForLevel(100))
    end
        if isSorcerer(cid) or isDruid(cid) then
            if getPlayerStorageValue(cid, 10000) == 1 then
                setCreatureMaxHealth(cid, 795)
                setCreatureMaxMana(cid, 3695)
                for i = 1, -getPlayerMagLevel(cid)+60 do doPlayerAddMagLevel(cid, 1) end
            else
                setCreatureMaxHealth(cid, 645)
                setCreatureMaxMana(cid, 2795)
                for i = 1, -getPlayerMagLevel(cid)+50 do doPlayerAddMagLevel(cid, 1) end
            end
        elseif isPaladin(cid) then
            if getPlayerStorageValue(cid, 10000) == 1 then
                setCreatureMaxHealth(cid, 1405)
                setCreatureMaxMana(cid, 1865)
                for i = 1, -getPlayerMagLevel(cid)+16 do doPlayerAddMagLevel(cid, 1) end
                for i = 1, -getPlayerSkillLevel(cid, SKILL_DIST)+80 do addEvent(delayDist, 0.2 * 1000, cid) end
            else
                setCreatureMaxHealth(cid, 1105)
                setCreaureMaxMana(cid, 1415)
                for i = 1, -getPlayerMagLevel(cid)+14 do doPlayerAddMagLevel(cid, 1) end
                for i = 1, -getPlayerSkillLevel(cid, SKILL_DIST)+70 do addEvent(delayDist, 0.2 * 1000, cid) end
            end
        elseif isKnight(cid) then
            if getPlayerStorageValue(cid, 10000) == 1 then
                setCreatureMaxHealth(cid, 2015)
                setCreatureMaxMana(cid, 645)
                for i = 1, -getPlayerMagLevel(cid)+9 do doPlayerAddMagLevel(cid, 1) end
                for i = 1, -getPlayerMeleeSkill(cid)+75 do addEvent(delaySkill, 0.2 * 1000, cid) end
                for i = 1, -getPlayerSkillLevel(cid, SKILL_SHIELD)+75 do addEvent(delayShield, 0.2 * 1000, cid) end
            else
                setCreatureMaxHealth(cid, 1565)
                setCreatureMaxMana(cid, 495)
                for i = 1, -getPlayerMagLevel(cid)+8 do doPlayerAddMagLevel(cid, 1) end
                for i = 1, -getPlayerMeleeSkill(cid)+65 do addEvent(delaySkill, 0.2 * 1000, cid) end
                for i = 1, -getPlayerSkillLevel(cid, SKILL_SHIELD)+65 do addEvent(delayShield, 0.2 * 1000, cid) end
            end
            
            doCreatureAddHealth(cid, -getCreatureHealth(cid)+getCreatureMaxHealth(cid))
            doCreatureAddMana(cid, -getCreatureMana(cid)+getCreatureMaxMana(cid))
        end
return true
end

function delaySkill(cid)
    doPlayerAddMeleeSkill(cid, 1)
end

function delayShield(cid)
    doPlayerAddSkill(cid, SKILL_SHIELD, 1)
end

function delayDist(cid)
    doPlayerAddSkill(cid, SKILL_DIST, 1)
end


Creaturescript teamLogout.lua:

Code:
function onLogout(cid)
    if getPlayerStorageValue(cid, 1002) == 1 then
        setGlobalStorageValue(1000, getGlobalStorageValue(1000)-1)
    elseif getPlayerStorageValue(cid, 1003) == 1 then
        setGlobalStorageValue(1001, getGlobalStorageValue(1001)-1)
        setPlayerStorageValue(cid, 1003, -1)
    end
return true
end


Creaturescript fixTeams.lua:

Code:
local maps = {
        [1] = {mapName = "Ignitos", redTemple = {x = 1153, y = 1069, z = 6}, blueTemple = {x = 1146, y = 1120, z = 6}},
        [2] = {mapName = "Dust2", redTemple = {x = 1169, y = 1192, z = 7}, blueTemple = {x = 1107, y = 1176, z = 6}},
        [3] = {mapName = "Fridge", redTemple = {x = 1277, y = 1035, z = 3}, blueTemple = {x = 1225, y = 1035, z = 3}},
    }
local teams = {
    blueName = "Blue Bangbabies",
    redName = "Red Rageboys",
    blueScore = 101,
    redScore = 102,
    bluePlayerScore = 1004,
    bluePlayerDScore = 1005,
    redPlayerScore = 1006,
    redPlayerDScore = 1007,
    }

function onStatsChange(cid, attacker, type, combat, value)
local map = maps[getGlobalStorageValue(100)]
local expGain = (getPlayerLevel(cid) + 50)*0.01 * 50 * (getPlayerLevel(cid) * getPlayerLevel(cid)) - (5 * getPlayerLevel(cid) + 8)
    if type == 1 then
        if getCreatureHealth(cid) <= value then
            if isPlayer(cid) and isCreature(attacker) then
                if getPlayerStorageValue(cid, 1003) == 1 then
                    local corpse = doCreateItem(3058, 1, getPlayerPosition(cid))
                    doItemSetAttribute(corpse, "description", "You recognize " .. getCreatureName(cid) .. "[" .. teams.redName .. ", level " .. getPlayerLevel(cid) .. "]. He was killed by "..(isMonster(attacker) and "a "..string.lower(getCreatureName(attacker)) or isCreature(attacker) and getCreatureName(attacker) or "a field item")..".")
                    doTeleportThing(cid, map.redTemple, true)
                    doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "You got pwned by the " .. teams.blueName .. "!")
                    doPlayerSendTextMessage(attacker, MESSAGE_EVENT_ADVANCE, "You pwned one of the " .. teams.redName .. "!")
                    setGlobalStorageValue(teams.blueScore, getGlobalStorageValue(teams.blueScore)+1)
                    setPlayerStorageValue(attacker, teams.bluePlayerScore, getPlayerStorageValue(attacker, teams.bluePlayerScore)+1)
                    setPlayerStorageValue(cid, teams.bluePlayerDScore, getPlayerStorageValue(cid, teams.bluePlayerDScore)+1)
                    doSendMagicEffect(getPlayerPosition(cid), CONST_ME_STUN)
                    doCreatureAddHealth(cid, getCreatureMaxHealth(cid), true)
                    doCreatureAddMana(cid, getCreatureMaxMana(cid), true)
                    doPlayerAddExperience(attacker, expGain)
                    doPlayerAddExperience(cid, -expGain)
                    doSendAnimatedText(getPlayerPosition(attacker), expGain, TEXTCOLOR_WHITE)
                elseif getPlayerStorageValue(cid, 1002) == 1 then
                    local corpse = doCreateItem(3058, 1, getPlayerPosition(cid))
                    doItemSetAttribute(corpse, "description", "You recognize " .. getCreatureName(cid) .. "[" .. teams.blueName .. ", level " .. getPlayerLevel(cid) .. "]. He was killed by "..(isMonster(attacker) and "a "..string.lower(getCreatureName(attacker)) or isCreature(attacker) and getCreatureName(attacker) or "a field item")..".")
                    doTeleportThing(cid, map.blueTemple, true)
                    doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "You got pwned by the " .. teams.redName .. "!")
                    doPlayerSendTextMessage(attacker, MESSAGE_EVENT_ADVANCE, "You pwned one of the " .. teams.blueName .. "!")
                    setGlobalStorageValue(teams.redScore, getGlobalStorageValue(teams.redScore)+1)
                    setPlayerStorageValue(attacker, teams.redPlayerScore, getPlayerStorageValue(attacker, teams.redPlayerScore)+1)
                    setPlayerStorageValue(cid, teams.redPlayerDScore, getPlayerStorageValue(cid, teams.redPlayerDScore)+1)
                    doSendMagicEffect(getPlayerPosition(cid), CONST_ME_STUN)
                    doCreatureAddHealth(cid, getCreatureMaxHealth(cid), true)
                    doCreatureAddMana(cid, getCreatureMaxMana(cid), true)
                    doPlayerAddExperience(attacker, expGain)
                    doPlayerAddExperience(cid, -expGain)
                    doSendAnimatedText(getPlayerPosition(attacker), expGain, TEXTCOLOR_WHITE)
                end
            end
        return false
        end
    end
return true
end
Creaturescript combat.lua
Code:
function onCombat(cid, target)
    if isPlayer(cid) and isPlayer(target) then
        if getPlayerStorageValue(cid, 1003) == 1 and getPlayerStorageValue(target, 1003) == 1 then
            return doPlayerSendCancel(cid, "You may not attack your teammates.") and false
        elseif getPlayerStorageValue(cid, 1002) == 1 and getPlayerStorageValue(target, 1002) == 1 then
            return doPlayerSendCancel(cid, "You may not attack your teammates.") and false
        end
    end
    return true
end
Creaturescript LookScores.lua:
Code:
local teams = {
    blueName = "Blue Bangbabies",
    redName = "Red Rageboys",
    blueScore = 101,
    redScore = 102,
    bluePlayerScore = 1004,
    redPlayerScore = 1006,
    }

function onLook(cid, thing, position, lookDistance)
    if isPlayer(thing.uid) then
        if getPlayerStorageValue(thing.uid, 1002) == 1 then
            doPlayerSetSpecialDescription(thing.uid, ".\nPwned " .. getPlayerStorageValue(thing.uid, teams.bluePlayerScore) .. " " .. teams.redName .. ".\nPwned " .. getPlayerStorageValue(thing.uid, teams.bluePlayerDScore) .. " times by the " .. teams.redName .. "")
        elseif getPlayerStorageValue(thing.uid, 1003) == 1 then
            doPlayerSetSpecialDescription(thing.uid, ".\nPwned " .. getPlayerStorageValue(thing.uid, teams.redPlayerScore) .. " " .. teams.blueName .. ".\nPwned " .. getPlayerStorageValue(thing.uid, teams.redPlayerDScore) .. " times by the " .. teams.blueName .. "")
        end
    end
return true
end
Creaturescripts.xml:
Code:
    <event type="login" name="teamLogin" event="script" value="teamLogin.lua"/>
    <event type="logout" name="teamLogout" event="script" value="teamLogout.lua"/>
    <event type="combat" name="teamCombat" event="script" value="combat.lua"/>
    <event type="statschange" name="fixTeam" event="script" value="fixTeam.lua"/>
    <event type="look" name="lookScores" event="script" value="lookScores.lua"/>
Just set the interval between the mapchanges in globalevents.xml. 1800 = 30 min in tfs 0.3.6
 
Last edited:
I made this system a while ago too, here is my version for my teambattle server I made:
This works 100% for me so you shouldnt have any problem with it

Globalevent changeMap.lua:
Code:
function onThink(interval, lastExecution, thinkInterval)
    local maps = {
        [1] = {mapName = "Ignitos", redTemple = {x = 1153, y = 1069, z = 6}, blueTemple = {x = 1146, y = 1120, z = 6}},
        [2] = {mapName = "Dust2", redTemple = {x = 1169, y = 1192, z = 7}, blueTemple = {x = 1107, y = 1176, z = 6}},
        [3] = {mapName = "Fridge", redTemple = {x = 1277, y = 1035, z = 3}, blueTemple = {x = 1225, y = 1035, z = 3}},
    }
    
    local teams = {
        blueName = "Blue Bangbabies",
        redName = "Red Rageboys",
        blueScore = 101,
        redScore = 102,
        bluePlayerScore = 1004,
        redPlayerScore = 1006,
    }
    
    local map = maps[getGlobalStorageValue(100)]

    if getGlobalStorageValue(100) <= 0 then
        setGlobalStorageValue(100, 1)
    elseif getGlobalStorageValue(100) >= math.max(1, #maps) then
        setGlobalStorageValue(100, 1)
    elseif getGlobalStorageValue(100) >= 1 then
        setGlobalStorageValue(100, getGlobalStorageValue(100)+1)
    end
    
    if map then
        for _, cid in ipairs(getPlayersOnline()) do
            if getPlayerStorageValue(cid, 1002) == 1 then
                doTeleportThing(cid, map.blueTemple)
                doSendMagicEffect(getPlayerPosition(cid), CONST_ME_TELEPORT)
            elseif getPlayerStorageValue(cid, 1003) == 1 then
                doTeleportThing(cid, map.redTemple)
                doSendMagicEffect(getPlayerPosition(cid), CONST_ME_TELEPORT)
            end
            if getGlobalStorageValue(teams.blueScore) > getGlobalStorageValue(teams.redScore) then
                str = "\n\nThe " .. teams.blueName .. " won!\n\nScores:\n" .. teams.blueName .. " " .. getGlobalStorageValue(blueScore) .. " - " .. getGlobalStorageValue(redScore) .. " " .. teams.redName .. "."
            elseif getGlobalStorageValue(teams.redScore) > getGlobalStorageValue(teams.blueScore) then
                str = "\n\nThe " .. teams.redName .. " won!\n\nScores:\n" .. teams.blueName .. " " .. getGlobalStorageValue(blueScore) .. " - " .. getGlobalStorageValue(redScore) .. " " .. teams.redName .. "."
            end
        doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "Map has been changed to " .. map.mapName .. "! Next map in 30 minutes!" .. str)
        end
        setGlobalStorageValue(teams.blueScore, 0)
        setGlobalStorageValue(teams.redScore, 0)
    end
return true
end
Globalevent teamScores.lua:
Code:
local blueScore = 101
local redScore = 102
local teams = {
    blueName = "Blue Bangbabies",
    redName = "Red Rageboys",
    }

function onThink(interval, lastExecution, thinkInterval)
    if getGlobalStorageValue(blueScore) > getGlobalStorageValue(redScore) then
        str = "The leading team is the " .. teams.blueName .. "!\n\nScores:\n" .. teams.blueName .. " " .. getGlobalStorageValue(blueScore) .. " - " .. getGlobalStorageValue(redScore) .. " " .. teams.redName .. "."
    elseif getGlobalStorageValue(redScore) > getGlobalStorageValue(blueScore) then
        str = "The leading team is the " .. teams.redName .. "!\n\nScores:\n" .. teams.redName .. " " .. getGlobalStorageValue(redScore) .. " - " .. getGlobalStorageValue(blueScore) .. " " .. teams.blueName .. "."
    elseif getGlobalStorageValue(redScore) == getGlobalStorageValue(blueScore) then
        str = "The teams is tied to the lead!\n\nScores:\n" .. teams.redName .. " " .. getGlobalStorageValue(redScore) .. " - " .. getGlobalStorageValue(blueScore) .. " " .. teams.blueName .. "."
    end
    doBroadcastMessage(str .. "\n\nPlayers:\n" .. teams.blueName .. " - " .. getGlobalStorageValue(1000) .. " vs " .. getGlobalStorageValue(1001) .. " - " .. teams.redName .. ".", MESSAGE_EVENT_ORANGE)
return true
end
Globalevent teams.lua:
Code:
local conditionBlue = createConditionObject(CONDITION_OUTFIT)
        setConditionParam(conditionBlue, CONDITION_PARAM_TICKS, 1800 * 1000)
        addOutfitCondition(conditionBlue, {lookType = 130, lookHead = 87, lookBody = 87, lookLegs = 87, lookFeet = 87})
local conditionRed = createConditionObject(CONDITION_OUTFIT)
        setConditionParam(conditionRed, CONDITION_PARAM_TICKS, 1800 * 1000)
        addOutfitCondition(conditionRed, {lookType = 130, lookHead = 94, lookBody = 94, lookLegs = 94, lookFeet = 94})

function onThink(interval, lastExecution, thinkInterval)
    for _, cid in ipairs(getPlayersOnline()) do    
        if getPlayerStorageValue(cid, 1002) == 1 then
            doAddCondition(cid, conditionBlue)
        elseif getPlayerStorageValue(cid, 1003) == 1 then
            doAddCondition(cid, conditionRed)
        end
    end
return true
end
Globalevent.xml:
Code:
<globalevent name="changeMap" interval="1800" event="script" value="changeMap.lua"/>
<globalevent name="teamScores" interval="80" event="script" value="teamScores.lua"/>
<globalevent name="teams" interval="1800" event="script" value="teams.lua"/>



Creaturescript teamLogin.lua (sets the team of a player and teleports to the right map):

Code:
local maps = {
        [1] = {mapName = "Ignitos", redTemple = {x = 1153, y = 1069, z = 6}, blueTemple = {x = 1146, y = 1120, z = 6}},
        [2] = {mapName = "Dust2", redTemple = {x = 1169, y = 1192, z = 7}, blueTemple = {x = 1107, y = 1176, z = 6}},
        [3] = {mapName = "Fridge", redTemple = {x = 1277, y = 1035, z = 3}, blueTemple = {x = 1225, y = 1035, z = 3}},
    }
local teams = {
    blueName = "Blue Bangbabies",
    redName = "Red Rageboys",
    blueScore = 101,
    redScore = 102,
    bluePlayerScore = 1004,
    redPlayerScore = 1006,
    }
    
local blueScore = 101
local redScore = 102

local conditionBlue = createConditionObject(CONDITION_OUTFIT)
        setConditionParam(conditionBlue, CONDITION_PARAM_TICKS, 1800 * 1000)
        addOutfitCondition(conditionBlue, {lookType = 130, lookHead = 87, lookBody = 87, lookLegs = 87, lookFeet = 87})
local conditionRed = createConditionObject(CONDITION_OUTFIT)
        setConditionParam(conditionRed, CONDITION_PARAM_TICKS, 1800 * 1000)
        addOutfitCondition(conditionRed, {lookType = 130, lookHead = 94, lookBody = 94, lookLegs = 94, lookFeet = 94})

function onLogin(cid)
setPlayerStorageValue(cid, 1002, 0)
setPlayerStorageValue(cid, 1003, 0)
local map = maps[getGlobalStorageValue(100)]
    if map then
        if getGlobalStorageValue(1000) > getGlobalStorageValue(1001) then
            setPlayerStorageValue(cid, 1003, 1)
            doAddCondition(cid, conditionRed)
            doTeleportThing(cid, map.redTemple)
            doSendMagicEffect(getPlayerPosition(cid), CONST_ME_TELEPORT)
            setGlobalStorageValue(1001, getGlobalStorageValue(1001)+1)
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You were sent to fight for the " .. teams.redName .. "!\nYour team have scored " .. getGlobalStorageValue(redScore) .. " kills.\nCurrent map is " .. map.mapName .. ".")
            
        else
            setPlayerStorageValue(cid, 1002, 1)
            doAddCondition(cid, conditionBlue)
            doTeleportThing(cid, map.blueTemple)
            doSendMagicEffect(getPlayerPosition(cid), CONST_ME_TELEPORT)
            setGlobalStorageValue(1000, getGlobalStorageValue(1000)+1)
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You were sent to fight for the " .. teams.blueName .. "!\nYour team have scored " .. getGlobalStorageValue(blueScore) .. " kills.\nCurrent map is " .. map.mapName .. ".")
        end
    end
    if getPlayerStorageValue(cid, 10000) == 1 then
        doPlayerAddExperience(cid, -getPlayerExperience(cid) + getExperienceForLevel(130))
    elseif getPlayerStorageValue(cid, 10000) ~= 1 then
        doPlayerAddExperience(cid, -getPlayerExperience(cid) + getExperienceForLevel(100))
    end
        if isSorcerer(cid) or isDruid(cid) then
            if getPlayerStorageValue(cid, 10000) == 1 then
                setCreatureMaxHealth(cid, 795)
                setCreatureMaxMana(cid, 3695)
                for i = 1, -getPlayerMagLevel(cid)+60 do doPlayerAddMagLevel(cid, 1) end
            else
                setCreatureMaxHealth(cid, 645)
                setCreatureMaxMana(cid, 2795)
                for i = 1, -getPlayerMagLevel(cid)+50 do doPlayerAddMagLevel(cid, 1) end
            end
        elseif isPaladin(cid) then
            if getPlayerStorageValue(cid, 10000) == 1 then
                setCreatureMaxHealth(cid, 1405)
                setCreatureMaxMana(cid, 1865)
                for i = 1, -getPlayerMagLevel(cid)+16 do doPlayerAddMagLevel(cid, 1) end
                for i = 1, -getPlayerSkillLevel(cid, SKILL_DIST)+80 do addEvent(delayDist, 0.2 * 1000, cid) end
            else
                setCreatureMaxHealth(cid, 1105)
                setCreaureMaxMana(cid, 1415)
                for i = 1, -getPlayerMagLevel(cid)+14 do doPlayerAddMagLevel(cid, 1) end
                for i = 1, -getPlayerSkillLevel(cid, SKILL_DIST)+70 do addEvent(delayDist, 0.2 * 1000, cid) end
            end
        elseif isKnight(cid) then
            if getPlayerStorageValue(cid, 10000) == 1 then
                setCreatureMaxHealth(cid, 2015)
                setCreatureMaxMana(cid, 645)
                for i = 1, -getPlayerMagLevel(cid)+9 do doPlayerAddMagLevel(cid, 1) end
                for i = 1, -getPlayerMeleeSkill(cid)+75 do addEvent(delaySkill, 0.2 * 1000, cid) end
                for i = 1, -getPlayerSkillLevel(cid, SKILL_SHIELD)+75 do addEvent(delayShield, 0.2 * 1000, cid) end
            else
                setCreatureMaxHealth(cid, 1565)
                setCreatureMaxMana(cid, 495)
                for i = 1, -getPlayerMagLevel(cid)+8 do doPlayerAddMagLevel(cid, 1) end
                for i = 1, -getPlayerMeleeSkill(cid)+65 do addEvent(delaySkill, 0.2 * 1000, cid) end
                for i = 1, -getPlayerSkillLevel(cid, SKILL_SHIELD)+65 do addEvent(delayShield, 0.2 * 1000, cid) end
            end
            
            doCreatureAddHealth(cid, -getCreatureHealth(cid)+getCreatureMaxHealth(cid))
            doCreatureAddMana(cid, -getCreatureMana(cid)+getCreatureMaxMana(cid))
        end
return true
end

function delaySkill(cid)
    doPlayerAddMeleeSkill(cid, 1)
end

function delayShield(cid)
    doPlayerAddSkill(cid, SKILL_SHIELD, 1)
end

function delayDist(cid)
    doPlayerAddSkill(cid, SKILL_DIST, 1)
end


Creaturescript teamLogout.lua:

Code:
function onLogout(cid)
    if getPlayerStorageValue(cid, 1002) == 1 then
        setGlobalStorageValue(1000, getGlobalStorageValue(1000)-1)
    elseif getPlayerStorageValue(cid, 1003) == 1 then
        setGlobalStorageValue(1001, getGlobalStorageValue(1001)-1)
        setPlayerStorageValue(cid, 1003, -1)
    end
return true
end


Creaturescript fixTeams.lua:

Code:
local maps = {
        [1] = {mapName = "Ignitos", redTemple = {x = 1153, y = 1069, z = 6}, blueTemple = {x = 1146, y = 1120, z = 6}},
        [2] = {mapName = "Dust2", redTemple = {x = 1169, y = 1192, z = 7}, blueTemple = {x = 1107, y = 1176, z = 6}},
        [3] = {mapName = "Fridge", redTemple = {x = 1277, y = 1035, z = 3}, blueTemple = {x = 1225, y = 1035, z = 3}},
    }
local teams = {
    blueName = "Blue Bangbabies",
    redName = "Red Rageboys",
    blueScore = 101,
    redScore = 102,
    bluePlayerScore = 1004,
    bluePlayerDScore = 1005,
    redPlayerScore = 1006,
    redPlayerDScore = 1007,
    }

function onStatsChange(cid, attacker, type, combat, value)
local map = maps[getGlobalStorageValue(100)]
local expGain = (getPlayerLevel(cid) + 50)*0.01 * 50 * (getPlayerLevel(cid) * getPlayerLevel(cid)) - (5 * getPlayerLevel(cid) + 8)
    if type == 1 then
        if getCreatureHealth(cid) <= value then
            if isPlayer(cid) and isCreature(attacker) then
                if getPlayerStorageValue(cid, 1003) == 1 then
                    local corpse = doCreateItem(3058, 1, getPlayerPosition(cid))
                    doItemSetAttribute(corpse, "description", "You recognize " .. getCreatureName(cid) .. "[" .. teams.redName .. ", level " .. getPlayerLevel(cid) .. "]. He was killed by "..(isMonster(attacker) and "a "..string.lower(getCreatureName(attacker)) or isCreature(attacker) and getCreatureName(attacker) or "a field item")..".")
                    doTeleportThing(cid, map.redTemple, true)
                    doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "You got pwned by the " .. teams.blueName .. "!")
                    doPlayerSendTextMessage(attacker, MESSAGE_EVENT_ADVANCE, "You pwned one of the " .. teams.redName .. "!")
                    setGlobalStorageValue(teams.blueScore, getGlobalStorageValue(teams.blueScore)+1)
                    setPlayerStorageValue(attacker, teams.bluePlayerScore, getPlayerStorageValue(attacker, teams.bluePlayerScore)+1)
                    setPlayerStorageValue(cid, teams.bluePlayerDScore, getPlayerStorageValue(cid, teams.bluePlayerDScore)+1)
                    doSendMagicEffect(getPlayerPosition(cid), CONST_ME_STUN)
                    doCreatureAddHealth(cid, getCreatureMaxHealth(cid), true)
                    doCreatureAddMana(cid, getCreatureMaxMana(cid), true)
                    doPlayerAddExperience(attacker, expGain)
                    doPlayerAddExperience(cid, -expGain)
                    doSendAnimatedText(getPlayerPosition(attacker), expGain, TEXTCOLOR_WHITE)
                elseif getPlayerStorageValue(cid, 1002) == 1 then
                    local corpse = doCreateItem(3058, 1, getPlayerPosition(cid))
                    doItemSetAttribute(corpse, "description", "You recognize " .. getCreatureName(cid) .. "[" .. teams.blueName .. ", level " .. getPlayerLevel(cid) .. "]. He was killed by "..(isMonster(attacker) and "a "..string.lower(getCreatureName(attacker)) or isCreature(attacker) and getCreatureName(attacker) or "a field item")..".")
                    doTeleportThing(cid, map.blueTemple, true)
                    doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "You got pwned by the " .. teams.redName .. "!")
                    doPlayerSendTextMessage(attacker, MESSAGE_EVENT_ADVANCE, "You pwned one of the " .. teams.blueName .. "!")
                    setGlobalStorageValue(teams.redScore, getGlobalStorageValue(teams.redScore)+1)
                    setPlayerStorageValue(attacker, teams.redPlayerScore, getPlayerStorageValue(attacker, teams.redPlayerScore)+1)
                    setPlayerStorageValue(cid, teams.redPlayerDScore, getPlayerStorageValue(cid, teams.redPlayerDScore)+1)
                    doSendMagicEffect(getPlayerPosition(cid), CONST_ME_STUN)
                    doCreatureAddHealth(cid, getCreatureMaxHealth(cid), true)
                    doCreatureAddMana(cid, getCreatureMaxMana(cid), true)
                    doPlayerAddExperience(attacker, expGain)
                    doPlayerAddExperience(cid, -expGain)
                    doSendAnimatedText(getPlayerPosition(attacker), expGain, TEXTCOLOR_WHITE)
                end
            end
        return false
        end
    end
return true
end
Creaturescript combat.lua
Code:
function onCombat(cid, target)
    if isPlayer(cid) and isPlayer(target) then
        if getPlayerStorageValue(cid, 1003) == 1 and getPlayerStorageValue(target, 1003) == 1 then
            return doPlayerSendCancel(cid, "You may not attack your teammates.") and false
        elseif getPlayerStorageValue(cid, 1002) == 1 and getPlayerStorageValue(target, 1002) == 1 then
            return doPlayerSendCancel(cid, "You may not attack your teammates.") and false
        end
    end
    return true
end
Creaturescript LookScores.lua:
Code:
local teams = {
    blueName = "Blue Bangbabies",
    redName = "Red Rageboys",
    blueScore = 101,
    redScore = 102,
    bluePlayerScore = 1004,
    redPlayerScore = 1006,
    }

function onLook(cid, thing, position, lookDistance)
    if isPlayer(thing.uid) then
        if getPlayerStorageValue(thing.uid, 1002) == 1 then
            doPlayerSetSpecialDescription(thing.uid, ".\nPwned " .. getPlayerStorageValue(thing.uid, teams.bluePlayerScore) .. " " .. teams.redName .. ".\nPwned " .. getPlayerStorageValue(thing.uid, teams.bluePlayerDScore) .. " times by the " .. teams.redName .. "")
        elseif getPlayerStorageValue(thing.uid, 1003) == 1 then
            doPlayerSetSpecialDescription(thing.uid, ".\nPwned " .. getPlayerStorageValue(thing.uid, teams.redPlayerScore) .. " " .. teams.blueName .. ".\nPwned " .. getPlayerStorageValue(thing.uid, teams.redPlayerDScore) .. " times by the " .. teams.blueName .. "")
        end
    end
return true
end
Creaturescripts.xml:
Code:
    <event type="login" name="teamLogin" event="script" value="teamLogin.lua"/>
    <event type="logout" name="teamLogout" event="script" value="teamLogout.lua"/>
    <event type="combat" name="teamCombat" event="script" value="combat.lua"/>
    <event type="statschange" name="fixTeam" event="script" value="fixTeam.lua"/>
    <event type="look" name="lookScores" event="script" value="lookScores.lua"/>
Just set the interval between the mapchanges in globalevents.xml. 1800 = 30 min in tfs 0.3.6

Looks like legit scripts, I'm gonna try them now, I'll get back to you. If i'm not mistaken, there's an auto team balance script in there, right?
 
Give me a second, I'm gonna try it soon just gotta change so you don't get level 100 and that stuff when you get in.
 
Back
Top