• 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 War and CTF event

drifter8779

Member
Joined
Oct 17, 2009
Messages
160
Reaction score
7
So i have a few issues with these scripts.
1, the CTF event seems to work fine, only issue, teams both start with 10 points and it says "10 points to win" so the game doesnt win by points it wins by most points when the mode times out at 25 minutes. How do i fix it so teams start with 0 points?
2, the War event, (tested with 2 players) after one player is left, there are no winners and the game never ends
3rd issue, i would like to also start the event by a talkaction, how can i convert the globalevents script to a talkaction script?
Specs: tfs 0.4 rev 3884 8.6

The event trigger
Globalevents/scripts/war_event.lua

LUA:
local configWar = {

MessageType = MESSAGE_INFO_DESCR,
wallPos = {x=512,y=846,z=5,stackpos=1},
wallPos1 = {x=513,y=846,z=5,stackpos=1},
wallPos2 = {x=513,y=847,z=5,stackpos=1},
wallPos3 = {x=513,y=848,z=5,stackpos=1},
wallPos4 = {x=513,y=849,z=5,stackpos=1},
wallPos5 = {x=512,y=849,z=5,stackpos=1},
AccessMessage = "Only Gods and Gamemasters can execute an event!",

FirstMessage = "Event Notice!",
SecondMessage = "War Arena has been opened to join go through the portal on the top floor of depot.",
ThirdMessage = "War Arena will begin in 5 minutes!",
FourthMessage = "War Arena will begin in 3 minutes!",
ClosingMessage = "War Arena will close and begin in 1 minute!",
CloseMessage = "War Arena portal has closed and the event has begun!"

}
local configCTF = {

MessageType = MESSAGE_INFO_DESCR,
wallPos = {x=512,y=840,z=5,stackpos=1},
wallPos1 = {x=513,y=840,z=5,stackpos=1},
wallPos2 = {x=513,y=841,z=5,stackpos=1},
wallPos3 = {x=513,y=842,z=5,stackpos=1},
wallPos4 = {x=513,y=843,z=5,stackpos=1},
wallPos5 = {x=512,y=843,z=5,stackpos=1},
AccessMessage = "Only Gods and Gamemasters can execute an event!",

FirstMessage = "Event Notice!",
SecondMessage = "Capture The Flag has been opened to join go through the portal on the top floor of depot.",
ThirdMessage = "Capture The Flag will begin in 5 minutes!",
FourthMessage = "Capture The Flag will begin in 3 minutes!",
ClosingMessage = "Capture The Flag will close and begin in 1 minute!",
CloseMessage = "Capture The Flag portal has closed and the event has begun!\n Gametime: 25 minutes",
timeLimitMessage = "25 minutes has elapsed and ",
timeLimitTieMessage = ""

}

local waitingRoomFrompos = {x=617, y=625, z=7, stackpos=253}
local waitingRoomTopos = {x=652, y=654, z=7, stackpos=253}

local CTF = {
fromPos = {x=660, y=495, z=7, stackpos=253},
toPos = {x=765, y=550, z=7, stackpos=253},
deTile = {x=720,y=626,z=7,stackpos=1}}
function TeleportWinners()
for _, pid in ipairs(getPlayersOnline()) do
if isInArea(getPlayerPosition(pid), CTF.fromPos, CTF.toPos) then
doTeleportThing(pid, CTF.deTile, false)
end
end
end

function endCtf(cid)
if getGlobalStorageValue(2010) ~= 4 then
redStorage = getGlobalStorageValue(2001)
blueStorage = getGlobalStorageValue(2002)
if redStorage < blueStorage then
doBroadcastMessage("25 minutes has elapsed, red team wins!",configCTF.MessageType)
setGlobalStorageValue(2010, 1)
TeleportWinners()
elseif blueStorage < redStorage then
doBroadcastMessage("25 minutes has elapsed, blue team wins!",configCTF.MessageType)
setGlobalStorageValue(2010, 2)
TeleportWinners()
elseif redStorage == blueStorage then
doBroadcastMessage("25 minutes has elapsed and the scores are tied, next score wins!",configCTF.MessageType)
setGlobalStorageValue(2010, 3)
end
end
end
--Functions for war.
function EventNotice11(cid)
addEvent(EventNotice21,5000,cid)
doBroadcastMessage(configWar.FirstMessage,configWar.MessageType)
end
function EventNotice21(cid)
addEvent(EventNotice31,10*1000,cid)
doBroadcastMessage(configWar.SecondMessage,configWar.MessageType)
end
function EventNotice31(cid)
addEvent(EventNotice41,120*1000,cid)
doBroadcastMessage(configWar.ThirdMessage,configWar.MessageType)
end
function EventNotice41(cid)
addEvent(EventNotice51,120*1000,cid)
doBroadcastMessage(configWar.FourthMessage,configWar.MessageType)
end
function EventNotice51(cid)
addEvent(EventNotice61,60*1000,cid)
doBroadcastMessage(configWar.ClosingMessage,configWar.MessageType)
end
function EventNotice61(cid)
doCreateItem(1600,1,configWar.wallPos)
doCreateItem(1595,1,configWar.wallPos1)
doCreateItem(1596,1,configWar.wallPos2)
doCreateItem(1596,1,configWar.wallPos3)
doCreateItem(1601,1,configWar.wallPos4)
doCreateItem(1600,1,configWar.wallPos5)
doBroadcastMessage(configWar.CloseMessage,configWar.MessageType)
addEvent(BeginWAR,5*1000,cid)
end

--Functions for CTF.
function EventNotice1(cid)
addEvent(EventNotice2,5000,cid)
doBroadcastMessage(configCTF.FirstMessage,configCTF.MessageType)
end
function EventNotice2(cid)
addEvent(EventNotice3,10*1000,cid)
doBroadcastMessage(configCTF.SecondMessage,configCTF.MessageType)
end
function EventNotice3(cid)
addEvent(EventNotice4,120*1000,cid)
doBroadcastMessage(configCTF.ThirdMessage,configCTF.MessageType)
end
function EventNotice4(cid)
addEvent(EventNotice5,120*1000,cid)
doBroadcastMessage(configCTF.FourthMessage,configCTF.MessageType)
end
function EventNotice5(cid)
addEvent(EventNotice6,60*1000,cid)
doBroadcastMessage(configCTF.ClosingMessage,configCTF.MessageType)
end
function EventNotice6(cid)
doCreateItem(1600,1,configCTF.wallPos)
doCreateItem(1595,1,configCTF.wallPos1)
doCreateItem(1596,1,configCTF.wallPos2)
doCreateItem(1596,1,configCTF.wallPos3)
doCreateItem(1601,1,configCTF.wallPos4)
doCreateItem(1600,1,configCTF.wallPos5)
doBroadcastMessage(configCTF.CloseMessage,configCTF.MessageType)
addEvent(BeginCTF,5*1000,cid)
end
--Start for War Event
function BeginWAR(cid)
for _, pid in ipairs(getPlayersOnline()) do
if isInArea(getPlayerPosition(pid), waitingRoomFrompos, waitingRoomTopos) then
doTeleportThing(pid, {x=635,y=614,z=7,stackpos=1}, false)
end
end
end
--Start for CTF Event
function BeginCTF(cid)
for _, pid in ipairs(getPlayersOnline()) do
if isInArea(getPlayerPosition(pid), waitingRoomFrompos, waitingRoomTopos) then
doTeleportThing(pid, {x=720,y=629,z=7,stackpos=1}, false)
end
end
end
function SetEventWAR(cid)
setGlobalStorageValue(1005, 0)--WAR
end
function SetEventCTF(cid)
doRemoveItem(getThingFromPos(configCTF.wallPos).uid,1)
doRemoveItem(getThingFromPos(configCTF.wallPos1).uid,1)
doRemoveItem(getThingFromPos(configCTF.wallPos2).uid,1)
doRemoveItem(getThingFromPos(configCTF.wallPos3).uid,1)
doRemoveItem(getThingFromPos(configCTF.wallPos4).uid,1)
doRemoveItem(getThingFromPos(configCTF.wallPos5).uid,1)
setGlobalStorageValue(1005, 0)
setGlobalStorageValue(2001, 0)
setGlobalStorageValue(2002, 0)
setGlobalStorageValue(2010, 0)
blueFlagPos = {x=698, y=607, z=7}
redFlagPos = {x=742, y=607, z=7}
blueFlagPlate = getThingFromPos(blueFlagPos)
redFlagPlate = getThingFromPos(redFlagPos)
doSetItemActionId(blueFlagPlate.uid,100)
doSetItemActionId(redFlagPlate.uid,100)
addEvent(EventNotice1,2000,cid)
addEvent(endCtf,1800000,cid) --30 minutes, 5 in lobby 25 in CTF
setGlobalStorageValue(28001, os.time(t))
end
local WAR = 0
local CTF = 1
local eventType = getGlobalStorageValue(1005)
function onThink(cid, item, fromPosition, toPosition)
if getGlobalStorageValue(1005) <= WAR then
doRemoveItem(getThingFromPos(configWar.wallPos).uid,1)
doRemoveItem(getThingFromPos(configWar.wallPos1).uid,1)
doRemoveItem(getThingFromPos(configWar.wallPos2).uid,1)
doRemoveItem(getThingFromPos(configWar.wallPos3).uid,1)
doRemoveItem(getThingFromPos(configWar.wallPos4).uid,1)
doRemoveItem(getThingFromPos(configWar.wallPos5).uid,1)
setGlobalStorageValue(1005, 1)
setGlobalStorageValue(2001, 0)
setGlobalStorageValue(2002, 0)
addEvent(EventNotice11,2000,cid)
addEvent(SetEventCTF,7200*1000,cid)
setGlobalStorageValue(28000, os.time(t))
else
doBroadcastMessage('Event System:\nEvent System Error, Please notify staff.')
end
return 1
end
CTF scripts
\movements\scripts\events\capture the flag\blue_flag_plate.lua
LUA:
local config = {
redTeam = 3,
blueTeam = 4,
scoreToWin = 10,
redTeamStorage = 2001,
blueTeamStorage = 2002,
redSide = {x=698, y=629, z=7, stackpos=253},
blueSide = {x=660, y=629, z=7, stackpos=253}
}


function onStepIn(cid, item, position, fromPosition)



local CTF = {
fromPos = {x=660, y=495, z=7, stackpos=253},
toPos = {x=765, y=550, z=7, stackpos=253},
deTile = {x=720,y=626,z=7,stackpos=1}}
function TeleportWinners(cid)
    for _, pid in ipairs(getPlayersOnline()) do
        if isInArea(getPlayerPosition(pid), CTF.fromPos, CTF.toPos) then
            doTeleportThing(pid, CTF.deTile, false)
        end
    end
end


local flagPosRed = {x=676,y=503,z=7,stackpos=0}
local hasFlag = getPlayerStorageValue(cid,2015)
local checkTeam = getPlayerStorageValue(cid,1000)
local checkRedScore = getGlobalStorageValue(2001)
local checkBlueScore = getGlobalStorageValue(2002)
local currentCaps = getPlayerStorageValue(cid,65535)

function checkScore(cid)
local RedScore = getGlobalStorageValue(2001)
local BlueScore = getGlobalStorageValue(2002)
doBroadcastMessage('Current CTF Game Score:\nRed Team: '.. config.scoreToWin - RedScore ..'\nBlue Team: '.. config.scoreToWin - BlueScore ..'\nFlag captures to win: 10.',MESSAGE_STATUS_CONSOLE_ORANGE)
doPlayerSendChannelMessage(cid, false, 'Current CTF Game Score:\nRed Team: '.. config.scoreToWin - RedScore ..'\nBlue Team: '.. config.scoreToWin - BlueScore ..'\nFlag captures to win: 10.',TALKTYPE_CHANNEL_W,11)
end


function more(cid)
local pos = getPlayerPosition(cid)
local Effects = {
{x=pos.x + 1,y=pos.y + 1,z=pos.z},
{x=pos.x - 1,y=pos.y - 1,z=pos.z},
{x=pos.x - 1,y=pos.y + 1,z=pos.z},
{x=pos.x + 1,y=pos.y - 1,z=pos.z},
{x=pos.x + 1,y=pos.y,z=pos.z},
{x=pos.x - 1,y=pos.y,z=pos.z},
{x=pos.x + 2,y=pos.y,z=pos.z},
{x=pos.x - 2,y=pos.y,z=pos.z},
{x=pos.x,y=pos.y + 2,z=pos.z},
{x=pos.x,y=pos.y + 1,z=pos.z},
{x=pos.x,y=pos.y - 1,z=pos.z},
{x=pos.x,y=pos.y - 2,z=pos.z}
}
if getPlayerStorageValue(cid,2015) == 1 then
for i = 1,12 do
doSendMagicEffect(Effects[i], 8)
end
        doSendMagicEffect(getPlayerPosition(cid), 28)
        doSendAnimatedText(getPlayerPosition(cid), 'FLAG!',math.random(1,255))
        addEvent(more, 1000, cid)
        else
        stopEvent(cid, more)
        end
        return 1
        end
local Team = getPlayerStorageValue(cid,1000)
local hasFlag = getPlayerStorageValue(cid,2015)
        
if Team == config.redTeam then       
    if item.actionid == 100 then
        if Team == config.redTeam and hasFlag <= 0 then
        addEvent(more, 1000, cid)
        doSetItemActionId(item.uid,item.actionid+1)
        doSendMagicEffect(getPlayerPosition(cid), 30)
        doBroadcastMessage('The red team has stolen the blue team flag!')
        doPlayerSendChannelMessage(cid, false, 'Your team has stolen the blue flag!',TALKTYPE_CHANNEL_W,12)
        setPlayerStorageValue(cid, 2015, 1)
        end
    else
        doCreatureSay(cid, 'The flag is not at home!', TALKTYPE_ORANGE_1)
    end
else
end
if Team == config.blueTeam then
if hasFlag > 0 then
    if item.actionid == 100 then   
        if checkTeam == config.blueTeam then
            addEvent(checkScore, 3000, cid)
            doTeleportThing(cid,fromPosition,false)
            doBroadcastMessage(''.. getCreatureName(cid) ..' scored 1 point for the blue team')
            doPlayerSendChannelMessage(cid, false,''.. getCreatureName(cid) ..' scored 1 point for your team!',TALKTYPE_CHANNEL_W,11)
            setPlayerStorageValue(cid, 2015, 0)
            setGlobalStorageValue(config.blueTeamStorage, getGlobalStorageValue(2002)-1)
            doSendMagicEffect(getPlayerPosition(cid), 27)
            doSendAnimatedText(getPlayerPosition(cid), 'Score!',23)
            doSetItemActionId(getThingFromPos(flagPosRed).uid,100)
            if currentCaps < 1 then
                setPlayerStorageValue(cid,65535,1)
                else
                setPlayerStorageValue(cid,65535,currentCaps+1)
            end   
            if checkBlueScore == 1 or getGlobalStorageValue(2010) == 3 then
                TeleportWinners(cid)
                doBroadcastMessage("Blue Team has won the event!")
                setGlobalStorageValue(config.blueTeamStorage, 0)
            end
        end
    else
        doCreatureSay(cid, 'Your flag must be at home to capture!', TALKTYPE_ORANGE_1)
    end
else
    doTeleportThing(cid,fromPosition,false)
    doPlayerSendCancel(cid, 'Sorry you do not have the flag!')
end
else
end
return 1
end

movements\scripts\events\capture the flag\red_flag_plate.lua

LUA:
local config = {
redTeam = 3,
blueTeam = 4,
scoreToWin = 10,
redTeamStorage = 2001,
blueTeamStorage = 2002,
redSide = {x=698, y=629, z=7, stackpos=253},
blueSide = {x=660, y=629, z=7, stackpos=253}
}


function onStepIn(cid, item, position, fromPosition)



local CTF = {
fromPos = {x=660, y=495, z=7, stackpos=253},
toPos = {x=765, y=550, z=7, stackpos=253},
deTile = {x=720,y=626,z=7,stackpos=1}}
function TeleportWinners(cid)
    for _, pid in ipairs(getPlayersOnline()) do
        if isInArea(getPlayerPosition(pid), CTF.fromPos, CTF.toPos) then
            doTeleportThing(pid, CTF.deTile, false)
        end
    end
end


local flagPosBlue = {x=744,y=523,z=7,stackpos=0}
local hasFlag = getPlayerStorageValue(cid,2015)
local checkTeam = getPlayerStorageValue(cid,1000)
local checkRedScore = getGlobalStorageValue(2001)
local checkBlueScore = getGlobalStorageValue(2002)
local currentCaps = getPlayerStorageValue(cid,65535)

function checkScore(cid)
local RedScore = getGlobalStorageValue(2001)
local BlueScore = getGlobalStorageValue(2002)
doBroadcastMessage('Current CTF Game Score:\nRed Team: '.. config.scoreToWin - RedScore ..'\nBlue Team: '.. config.scoreToWin - BlueScore ..'\nFlag captures to win: 10.',MESSAGE_STATUS_CONSOLE_ORANGE)
doPlayerSendChannelMessage(cid, false, 'Current CTF Game Score:\nRed Team: '.. config.scoreToWin - RedScore ..'\nBlue Team: '.. config.scoreToWin - BlueScore ..'\nFlag captures to win: 10.',TALKTYPE_CHANNEL_W,12)
end



function more(cid)
local pos = getPlayerPosition(cid)
local Effects = {
{x=pos.x + 1,y=pos.y + 1,z=pos.z},
{x=pos.x - 1,y=pos.y - 1,z=pos.z},
{x=pos.x - 1,y=pos.y + 1,z=pos.z},
{x=pos.x + 1,y=pos.y - 1,z=pos.z},
{x=pos.x + 1,y=pos.y,z=pos.z},
{x=pos.x - 1,y=pos.y,z=pos.z},
{x=pos.x + 2,y=pos.y,z=pos.z},
{x=pos.x - 2,y=pos.y,z=pos.z},
{x=pos.x,y=pos.y + 2,z=pos.z},
{x=pos.x,y=pos.y + 1,z=pos.z},
{x=pos.x,y=pos.y - 1,z=pos.z},
{x=pos.x,y=pos.y - 2,z=pos.z}
}
if getPlayerStorageValue(cid,2015) == 1 then
for i = 1,12 do
doSendMagicEffect(Effects[i], 8)
end
        doSendMagicEffect(getPlayerPosition(cid), 28)
        doSendAnimatedText(getPlayerPosition(cid), 'FLAG!',math.random(1,255))
        addEvent(more, 1000, cid)
        else
        stopEvent(cid, more)
        end
        return 1
        end
local Team = getPlayerStorageValue(cid,1000)
local hasFlag = getPlayerStorageValue(cid,2015)

if Team == config.blueTeam then       
    if item.actionid == 100 then
        if Team == config.blueTeam and hasFlag <= 0 then
        addEvent(more, 1000, cid)
        doSetItemActionId(item.uid,item.actionid+1)
        doSendMagicEffect(getPlayerPosition(cid), 30)
        doBroadcastMessage('The blue team has stolen red team flag!')
        doPlayerSendChannelMessage(cid, false, 'Your team has stolen the red flag!',TALKTYPE_CHANNEL_W,12)
        setPlayerStorageValue(cid, 2015, 1)
        end
    else
        doCreatureSay(cid, 'The flag is not at home!', TALKTYPE_ORANGE_1)
    end
else
end
if Team == config.redTeam then
if hasFlag > 0 then
    if item.actionid == 100 then   
        if Team == config.redTeam then
            addEvent(checkScore, 3000, cid)
            doTeleportThing(cid,fromPosition,false)
            doBroadcastMessage(''.. getCreatureName(cid) ..' scored 1 point for the red team!')
            doPlayerSendChannelMessage(cid, false,''.. getCreatureName(cid) ..' scored 1 point for your team!',TALKTYPE_CHANNEL_W,12)
            setPlayerStorageValue(cid, 2015, 0)
            setGlobalStorageValue(config.redTeamStorage, getGlobalStorageValue(2001)-1)
            doSendMagicEffect(getPlayerPosition(cid), 27)
            doSendAnimatedText(getPlayerPosition(cid), 'Score!',23)
            doSetItemActionId(getThingFromPos(flagPosBlue).uid,100)
            if currentCaps < 1 then
                setPlayerStorageValue(cid,65535,1)
                else
                setPlayerStorageValue(cid,65535,currentCaps+1)
            end
            if checkRedScore == 1 or getGlobalStorageValue(2010) == 3 then
                TeleportWinners(cid)
                doBroadcastMessage("Red Team has won the event!")
                setGlobalStorageValue(config.redTeamStorage, 0)
            end
        end
    else
        doCreatureSay(cid, 'Your flag must be at home to capture!', TALKTYPE_ORANGE_1)
    end
else
    doTeleportThing(cid,fromPosition,false)
    doPlayerSendCancel(cid, 'Sorry you do not have the flag!')
end
else
end
return 1
end

movements\scripts\events\capture the flag\ctf_set_teams.lua

LUA:
function onStepIn(cid, item, position, fromPosition)
local config = {
gametime = -1, --time in mins
redSide = {x=676, y=499, z=7, stackpos=253},
blueSide = {x=744, y=520, z=7, stackpos=253},
outfitRed = {lookType = 229, lookHead = 94, lookAddons = 1, lookLegs = 94, lookBody = 94, lookFeet = 94},
outfitBlue = {lookType = 248, lookHead = 88, lookAddons = 1, lookLegs = 88, lookBody = 88, lookFeet = 88}
}


local redStorage = getGlobalStorageValue(2001)
local blueStorage = getGlobalStorageValue(2002)
if getPlayerIp(cid) == 0 then
    doSendMagicEffect(position,69)
    doRemoveCreature(cid)
    return false
end
    if item.actionid == 100 then
        doSetCreatureOutfit(cid, config.outfitRed , config.gametime)
        doSetItemActionId(item.uid,item.actionid+1)
        doTeleportThing(cid,config.redSide,false)
        doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "You are on the Red team")
        doPlayerSetStorageValue(cid, 1000, 3)
    elseif item.actionid == 101 then
        doSetCreatureOutfit(cid, config.outfitBlue , config.gametime)
        doSetItemActionId(item.uid,item.actionid-1)
        doTeleportThing(cid,config.blueSide,false)
        doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "You are on the Blue team")
        doPlayerSetStorageValue(cid, 1000, 4)
end
    return true
end

\movements\scripts\events\capture the flag\ctf-determine_winner.lua

LUA:
function onStepIn(cid, item, position, fromPosition)
local config = {
redTeam = 3,
blueTeam = 4,
depot = {x=517,y=840,z=7,stackpos=1},
rewardRoom = {x=636,y=662,z=7,stackpos=1}
}
local Team = getPlayerStorageValue(cid,1000)
local redStorage = getGlobalStorageValue(2001)
local blueStorage = getGlobalStorageValue(2002)
local currentWins = getPlayerStorageValue(cid,65533)
local currentPlays = getPlayerStorageValue(cid,65534)

local CHANNEL_BLUE, CHANNEL_RED = 12, 11

--If Red Team Wins
    if redStorage < blueStorage or getGlobalStorageValue(2010) == 1 then
        if Team == config.redTeam then
        if currentWins < 1 then
            setPlayerStorageValue(cid,65533,1)
            else
            setPlayerStorageValue(cid,65533,currentWins+1)
        end
        if currentPlays < 1 then
            setPlayerStorageValue(cid,65534,1)
            else
            setPlayerStorageValue(cid,65534,currentPlays+1)
        end
            doRemoveCondition(cid,CONDITION_INFIGHT)
            doRemoveCondition(cid, CONDITION_OUTFIT)   
            doTeleportThing(cid,config.rewardRoom,false)
            doPlayerCloseChannel(cid, CHANNEL_RED)
            setPlayerStorageValue(cid, 1000, 0)
            setPlayerStorageValue(cid, 2015, 0)
            setGlobalStorageValue(2010, 4)
            doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "Congratulations, your team won the event!")
        else
        if currentPlays < 1 then
            setPlayerStorageValue(cid,65534,1)
            else
            setPlayerStorageValue(cid,65534,currentPlays+1)
        end
            doTeleportThing(cid,config.depot,false)
            doPlayerCloseChannel(cid, CHANNEL_BLUE)
            doRemoveCondition(cid,CONDITION_INFIGHT)
            doRemoveCondition(cid, CONDITION_OUTFIT)
            setPlayerStorageValue(cid, 1000, 0)
            setPlayerStorageValue(cid, 2015, 0)
            setGlobalStorageValue(2010, 4)
        end
    end
--If Blue Team Wins   
    if redStorage > blueStorage or getGlobalStorageValue(2010) == 2 then
        if Team == config.blueTeam then
        if currentWins < 1 then
            setPlayerStorageValue(cid,65533,1)
            else
            setPlayerStorageValue(cid,65533,currentWins+1)
        end
        if currentPlays < 1 then
            setPlayerStorageValue(cid,65534,1)
            else
            setPlayerStorageValue(cid,65534,currentPlays+1)
        end
            doRemoveCondition(cid,CONDITION_INFIGHT)
            doRemoveCondition(cid, CONDITION_OUTFIT)   
            doTeleportThing(cid,config.rewardRoom,false)
            doPlayerCloseChannel(cid, CHANNEL_BLUE)
            setPlayerStorageValue(cid, 1000, 0)
            setPlayerStorageValue(cid, 2015, 0)
            setGlobalStorageValue(2010, 4)
            doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "Congratulations, your team won the event!")
            else
        if currentPlays < 1 then
            setPlayerStorageValue(cid,65534,1)
            else
            setPlayerStorageValue(cid,65534,currentPlays+1)
        end
            doTeleportThing(cid,config.depot,false)
            doPlayerCloseChannel(cid, CHANNEL_RED)
            doRemoveCondition(cid,CONDITION_INFIGHT)
            doRemoveCondition(cid, CONDITION_OUTFIT)
            setPlayerStorageValue(cid, 1000, 0)
            setPlayerStorageValue(cid, 2015, 0)
            setGlobalStorageValue(2010, 4)
        end
    end
    return true
end

War Event Scripts

\movements\scripts\events\war arena\set_teams.lua

LUA:
function onStepIn(cid, item, position, fromPosition)
local config = {
gametime = -1, --time in mins
redSide = {x=658, y=725, z=7, stackpos=253},
blueSide = {x=726, y=745, z=7, stackpos=253},
outfitRed = {lookType = 229, lookHead = 94, lookAddons = 1, lookLegs = 94, lookBody = 94, lookFeet = 94},
outfitBlue = {lookType = 248, lookHead = 88, lookAddons = 1, lookLegs = 88, lookBody = 88, lookFeet = 88}
}


local redStorage = getGlobalStorageValue(2001)
local blueStorage = getGlobalStorageValue(2002)
if getPlayerIp(cid) == 0 then
    doSendMagicEffect(position,69)
    doRemoveCreature(cid)
    return false
end
    if item.actionid == 100 then
        doSetCreatureOutfit(cid, config.outfitRed , config.gametime)
        doSetItemActionId(item.uid,item.actionid+1)
        doTeleportThing(cid,config.redSide,false)
        doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "You are on the Red team")
        doPlayerSetStorageValue(cid, 1001, 1)
        setGlobalStorageValue(2001, redStorage+1)
    elseif item.actionid == 101 then
        doSetCreatureOutfit(cid, config.outfitBlue , config.gametime)
        doSetItemActionId(item.uid,item.actionid-1)
        doTeleportThing(cid,config.blueSide,false)
        doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "You are on the Blue team")
        doPlayerSetStorageValue(cid, 1001, 2)
        setGlobalStorageValue(2002, blueStorage+1)
end
    return true
end
 
Back
Top